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
ac44b3d2
Commit
ac44b3d2
authored
Jan 13, 2014
by
Arthur Schreiber
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Incorporate @ethomson's suggestions.
parent
b0b32b43
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
16 deletions
+15
-16
src/indexer.c
+15
-16
No files found.
src/indexer.c
View file @
ac44b3d2
...
@@ -355,7 +355,7 @@ static int hash_and_save(git_indexer *idx, git_rawobj *obj, git_off_t entry_star
...
@@ -355,7 +355,7 @@ static int hash_and_save(git_indexer *idx, git_rawobj *obj, git_off_t entry_star
git_oid
oid
;
git_oid
oid
;
size_t
entry_size
;
size_t
entry_size
;
struct
entry
*
entry
;
struct
entry
*
entry
;
struct
git_pack_entry
*
pentry
;
struct
git_pack_entry
*
pentry
=
NULL
;
entry
=
git__calloc
(
1
,
sizeof
(
*
entry
));
entry
=
git__calloc
(
1
,
sizeof
(
*
entry
));
GITERR_CHECK_ALLOC
(
entry
);
GITERR_CHECK_ALLOC
(
entry
);
...
@@ -373,14 +373,13 @@ static int hash_and_save(git_indexer *idx, git_rawobj *obj, git_off_t entry_star
...
@@ -373,14 +373,13 @@ static int hash_and_save(git_indexer *idx, git_rawobj *obj, git_off_t entry_star
entry
->
crc
=
crc32
(
0L
,
Z_NULL
,
0
);
entry
->
crc
=
crc32
(
0L
,
Z_NULL
,
0
);
entry_size
=
(
size_t
)(
idx
->
off
-
entry_start
);
entry_size
=
(
size_t
)(
idx
->
off
-
entry_start
);
if
(
crc_object
(
&
entry
->
crc
,
&
idx
->
pack
->
mwf
,
entry_start
,
entry_size
)
<
0
)
{
if
(
crc_object
(
&
entry
->
crc
,
&
idx
->
pack
->
mwf
,
entry_start
,
entry_size
)
<
0
)
git__free
(
pentry
);
goto
on_error
;
goto
on_error
;
}
return
save_entry
(
idx
,
entry
,
pentry
,
entry_start
);
return
save_entry
(
idx
,
entry
,
pentry
,
entry_start
);
on_error:
on_error:
git__free
(
pentry
);
git__free
(
entry
);
git__free
(
entry
);
git__free
(
obj
->
data
);
git__free
(
obj
->
data
);
return
-
1
;
return
-
1
;
...
@@ -636,7 +635,7 @@ static int inject_object(git_indexer *idx, git_oid *id)
...
@@ -636,7 +635,7 @@ static int inject_object(git_indexer *idx, git_oid *id)
{
{
git_odb_object
*
obj
;
git_odb_object
*
obj
;
struct
entry
*
entry
;
struct
entry
*
entry
;
struct
git_pack_entry
*
pentry
;
struct
git_pack_entry
*
pentry
=
NULL
;
git_oid
foo
=
{{
0
}};
git_oid
foo
=
{{
0
}};
unsigned
char
hdr
[
64
];
unsigned
char
hdr
[
64
];
git_buf
buf
=
GIT_BUF_INIT
;
git_buf
buf
=
GIT_BUF_INIT
;
...
@@ -666,10 +665,8 @@ static int inject_object(git_indexer *idx, git_oid *id)
...
@@ -666,10 +665,8 @@ static int inject_object(git_indexer *idx, git_oid *id)
idx
->
pack
->
mwf
.
size
+=
hdr_len
;
idx
->
pack
->
mwf
.
size
+=
hdr_len
;
entry
->
crc
=
crc32
(
entry
->
crc
,
hdr
,
hdr_len
);
entry
->
crc
=
crc32
(
entry
->
crc
,
hdr
,
hdr_len
);
if
((
error
=
git__compress
(
&
buf
,
data
,
len
))
<
0
)
{
if
((
error
=
git__compress
(
&
buf
,
data
,
len
))
<
0
)
git__free
(
entry
);
goto
error
;
goto
cleanup
;
}
/* And then the compressed object */
/* And then the compressed object */
git_filebuf_write
(
&
idx
->
pack_file
,
buf
.
ptr
,
buf
.
size
);
git_filebuf_write
(
&
idx
->
pack_file
,
buf
.
ptr
,
buf
.
size
);
...
@@ -678,10 +675,8 @@ static int inject_object(git_indexer *idx, git_oid *id)
...
@@ -678,10 +675,8 @@ static int inject_object(git_indexer *idx, git_oid *id)
git_buf_free
(
&
buf
);
git_buf_free
(
&
buf
);
/* Write a fake trailer so the pack functions play ball */
/* Write a fake trailer so the pack functions play ball */
if
((
error
=
git_filebuf_write
(
&
idx
->
pack_file
,
&
foo
,
GIT_OID_RAWSZ
))
<
0
)
{
if
((
error
=
git_filebuf_write
(
&
idx
->
pack_file
,
&
foo
,
GIT_OID_RAWSZ
))
<
0
)
git__free
(
entry
);
goto
error
;
goto
cleanup
;
}
idx
->
pack
->
mwf
.
size
+=
GIT_OID_RAWSZ
;
idx
->
pack
->
mwf
.
size
+=
GIT_OID_RAWSZ
;
...
@@ -692,10 +687,14 @@ static int inject_object(git_indexer *idx, git_oid *id)
...
@@ -692,10 +687,14 @@ static int inject_object(git_indexer *idx, git_oid *id)
git_oid_cpy
(
&
entry
->
oid
,
id
);
git_oid_cpy
(
&
entry
->
oid
,
id
);
idx
->
off
=
entry_start
+
hdr_len
+
len
;
idx
->
off
=
entry_start
+
hdr_len
+
len
;
if
(
(
error
=
save_entry
(
idx
,
entry
,
pentry
,
entry_start
))
<
0
)
if
(
!
(
error
=
save_entry
(
idx
,
entry
,
pentry
,
entry_start
))
)
g
it__free
(
pentry
)
;
g
oto
done
;
cleanup:
error:
git__free
(
entry
);
git__free
(
pentry
);
done:
git_odb_object_free
(
obj
);
git_odb_object_free
(
obj
);
return
error
;
return
error
;
}
}
...
...
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