Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
af7689ea
Commit
af7689ea
authored
May 02, 2013
by
Vicent Martí
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1535 from carlosmn/pack-threading
Switch to index_version as "git_pack_file is ready" flag
parents
8a497ec9
0ddfcb40
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
13 deletions
+12
-13
src/pack.c
+12
-13
No files found.
src/pack.c
View file @
af7689ea
...
@@ -293,8 +293,8 @@ static int pack_index_check(const char *path, struct git_pack_file *p)
...
@@ -293,8 +293,8 @@ static int pack_index_check(const char *path, struct git_pack_file *p)
}
}
}
}
p
->
index_version
=
version
;
p
->
num_objects
=
nr
;
p
->
num_objects
=
nr
;
p
->
index_version
=
version
;
return
0
;
return
0
;
}
}
...
@@ -304,7 +304,7 @@ static int pack_index_open(struct git_pack_file *p)
...
@@ -304,7 +304,7 @@ static int pack_index_open(struct git_pack_file *p)
int
error
=
0
;
int
error
=
0
;
size_t
name_len
,
base_len
;
size_t
name_len
,
base_len
;
if
(
p
->
index_
map
.
data
)
if
(
p
->
index_
version
>
-
1
)
return
0
;
return
0
;
name_len
=
strlen
(
p
->
pack_name
);
name_len
=
strlen
(
p
->
pack_name
);
...
@@ -320,7 +320,7 @@ static int pack_index_open(struct git_pack_file *p)
...
@@ -320,7 +320,7 @@ static int pack_index_open(struct git_pack_file *p)
if
((
error
=
git_mutex_lock
(
&
p
->
lock
))
<
0
)
if
((
error
=
git_mutex_lock
(
&
p
->
lock
))
<
0
)
return
error
;
return
error
;
if
(
!
p
->
index_map
.
data
)
if
(
p
->
index_version
==
-
1
)
error
=
pack_index_check
(
idx_name
,
p
);
error
=
pack_index_check
(
idx_name
,
p
);
git__free
(
idx_name
);
git__free
(
idx_name
);
...
@@ -826,7 +826,7 @@ static int packfile_open(struct git_pack_file *p)
...
@@ -826,7 +826,7 @@ static int packfile_open(struct git_pack_file *p)
git_oid
sha1
;
git_oid
sha1
;
unsigned
char
*
idx_sha1
;
unsigned
char
*
idx_sha1
;
if
(
!
p
->
index_map
.
data
&&
pack_index_open
(
p
)
<
0
)
if
(
p
->
index_version
==
-
1
&&
pack_index_open
(
p
)
<
0
)
return
git_odb__error_notfound
(
"failed to open packfile"
,
NULL
);
return
git_odb__error_notfound
(
"failed to open packfile"
,
NULL
);
/* if mwf opened by another thread, return now */
/* if mwf opened by another thread, return now */
...
@@ -942,6 +942,7 @@ int git_packfile_alloc(struct git_pack_file **pack_out, const char *path)
...
@@ -942,6 +942,7 @@ int git_packfile_alloc(struct git_pack_file **pack_out, const char *path)
p
->
mwf
.
size
=
st
.
st_size
;
p
->
mwf
.
size
=
st
.
st_size
;
p
->
pack_local
=
1
;
p
->
pack_local
=
1
;
p
->
mtime
=
(
git_time_t
)
st
.
st_mtime
;
p
->
mtime
=
(
git_time_t
)
st
.
st_mtime
;
p
->
index_version
=
-
1
;
git_mutex_init
(
&
p
->
lock
);
git_mutex_init
(
&
p
->
lock
);
...
@@ -1050,24 +1051,24 @@ static int pack_entry_find_offset(
...
@@ -1050,24 +1051,24 @@ static int pack_entry_find_offset(
const
git_oid
*
short_oid
,
const
git_oid
*
short_oid
,
size_t
len
)
size_t
len
)
{
{
const
uint32_t
*
level1_ofs
;
const
uint32_t
*
level1_ofs
=
p
->
index_map
.
data
;
const
unsigned
char
*
index
;
const
unsigned
char
*
index
=
p
->
index_map
.
data
;
unsigned
hi
,
lo
,
stride
;
unsigned
hi
,
lo
,
stride
;
int
pos
,
found
=
0
;
int
pos
,
found
=
0
;
const
unsigned
char
*
current
=
0
;
const
unsigned
char
*
current
=
0
;
*
offset_out
=
0
;
*
offset_out
=
0
;
if
(
!
p
->
index_map
.
data
&&
pack_index_open
(
p
)
<
0
)
if
(
p
->
index_version
==
-
1
)
{
return
git_odb__error_notfound
(
"failed to open packfile"
,
NULL
);
int
error
;
if
(
git_mutex_lock
(
&
p
->
lock
)
<
0
)
return
packfile_error
(
"failed to get lock for finding entry offset"
);
if
((
error
=
pack_index_open
(
p
))
<
0
)
return
error
;
assert
(
p
->
index_map
.
data
);
assert
(
p
->
index_map
.
data
);
index
=
p
->
index_map
.
data
;
index
=
p
->
index_map
.
data
;
level1_ofs
=
p
->
index_map
.
data
;
level1_ofs
=
p
->
index_map
.
data
;
}
if
(
p
->
index_version
>
1
)
{
if
(
p
->
index_version
>
1
)
{
level1_ofs
+=
2
;
level1_ofs
+=
2
;
...
@@ -1093,8 +1094,6 @@ static int pack_entry_find_offset(
...
@@ -1093,8 +1094,6 @@ static int pack_entry_find_offset(
/* Use git.git lookup code */
/* Use git.git lookup code */
pos
=
sha1_entry_pos
(
index
,
stride
,
0
,
lo
,
hi
,
p
->
num_objects
,
short_oid
->
id
);
pos
=
sha1_entry_pos
(
index
,
stride
,
0
,
lo
,
hi
,
p
->
num_objects
,
short_oid
->
id
);
git_mutex_unlock
(
&
p
->
lock
);
if
(
pos
>=
0
)
{
if
(
pos
>=
0
)
{
/* An object matching exactly the oid was found */
/* An object matching exactly the oid was found */
found
=
1
;
found
=
1
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment