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
7cd0bf65
Commit
7cd0bf65
authored
Apr 05, 2020
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pack: use GIT_ASSERT
parent
87d37896
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
17 deletions
+17
-17
src/indexer.c
+2
-2
src/pack-objects.c
+3
-4
src/pack.c
+11
-10
src/pack.h
+1
-1
No files found.
src/indexer.c
View file @
7cd0bf65
...
...
@@ -900,8 +900,8 @@ static int inject_object(git_indexer *idx, git_oid *id)
entry
->
crc
=
crc32
(
0L
,
Z_NULL
,
0
);
/* Write out the object header */
hdr_len
=
git_packfile__object_header
(
hdr
,
len
,
git_odb_object_type
(
obj
));
if
(
(
error
=
append_to_pack
(
idx
,
hdr
,
hdr_len
))
<
0
)
if
((
error
=
git_packfile__object_header
(
&
hdr_len
,
hdr
,
len
,
git_odb_object_type
(
obj
)))
<
0
||
(
error
=
append_to_pack
(
idx
,
hdr
,
hdr_len
))
<
0
)
goto
cleanup
;
idx
->
pack
->
mwf
.
size
+=
hdr_len
;
...
...
src/pack-objects.c
View file @
7cd0bf65
...
...
@@ -347,10 +347,9 @@ static int write_object(
}
/* Write header */
hdr_len
=
git_packfile__object_header
(
hdr
,
data_len
,
type
);
if
((
error
=
write_cb
(
hdr
,
hdr_len
,
cb_data
))
<
0
||
(
error
=
git_hash_update
(
&
pb
->
ctx
,
hdr
,
hdr_len
))
<
0
)
if
((
error
=
git_packfile__object_header
(
&
hdr_len
,
hdr
,
data_len
,
type
))
<
0
||
(
error
=
write_cb
(
hdr
,
hdr_len
,
cb_data
))
<
0
||
(
error
=
git_hash_update
(
&
pb
->
ctx
,
hdr
,
hdr_len
))
<
0
)
goto
done
;
if
(
type
==
GIT_OBJECT_REF_DELTA
)
{
...
...
src/pack.c
View file @
7cd0bf65
...
...
@@ -67,7 +67,6 @@ static void free_cache_object(void *o)
git_pack_cache_entry
*
e
=
(
git_pack_cache_entry
*
)
o
;
if
(
e
!=
NULL
)
{
assert
(
e
->
refcount
.
val
==
0
);
git__free
(
e
->
raw
.
data
);
git__free
(
e
);
}
...
...
@@ -311,8 +310,9 @@ static int pack_index_open(struct git_pack_file *p)
if
(
p
->
index_version
>
-
1
)
return
0
;
/* checked by git_pack_file alloc */
name_len
=
strlen
(
p
->
pack_name
);
assert
(
name_len
>
strlen
(
".pack"
));
/* checked by git_pack_file alloc */
GIT_ASSERT
(
name_len
>
strlen
(
".pack"
));
if
(
git_buf_init
(
&
idx_name
,
name_len
)
<
0
)
return
-
1
;
...
...
@@ -372,12 +372,12 @@ static unsigned char *pack_window_open(
* - each byte afterwards: low seven bits are size continuation,
* with the high bit being "size continues"
*/
size_t
git_packfile__object_header
(
unsigned
char
*
hdr
,
size_t
size
,
git_object_t
type
)
int
git_packfile__object_header
(
size_t
*
out
,
unsigned
char
*
hdr
,
size_t
size
,
git_object_t
type
)
{
unsigned
char
*
hdr_base
;
unsigned
char
c
;
assert
(
type
>=
GIT_OBJECT_COMMIT
&&
type
<=
GIT_OBJECT_REF_DELTA
);
GIT_ASSERT_ARG
(
type
>=
GIT_OBJECT_COMMIT
&&
type
<=
GIT_OBJECT_REF_DELTA
);
/* TODO: add support for chunked objects; see git.git 6c0d19b1 */
...
...
@@ -392,7 +392,8 @@ size_t git_packfile__object_header(unsigned char *hdr, size_t size, git_object_t
}
*
hdr
++
=
c
;
return
(
hdr
-
hdr_base
);
*
out
=
(
hdr
-
hdr_base
);
return
0
;
}
...
...
@@ -899,7 +900,7 @@ int get_delta_base(
off64_t
base_offset
;
git_oid
unused
;
assert
(
delta_base_out
);
GIT_ASSERT_ARG
(
delta_base_out
);
base_info
=
pack_window_open
(
p
,
w_curs
,
*
curpos
,
&
left
);
/* Assumption: the only reason this would fail is because the file is too small */
...
...
@@ -1211,8 +1212,7 @@ int git_pack_foreach_entry(
if
((
error
=
pack_index_open
(
p
))
<
0
)
return
error
;
assert
(
p
->
index_map
.
data
);
GIT_ASSERT
(
p
->
index_map
.
data
);
index
=
p
->
index_map
.
data
;
}
...
...
@@ -1299,7 +1299,8 @@ static int pack_entry_find_offset(
if
((
error
=
pack_index_open
(
p
))
<
0
)
return
error
;
assert
(
p
->
index_map
.
data
);
GIT_ASSERT
(
p
->
index_map
.
data
);
}
index
=
p
->
index_map
.
data
;
...
...
@@ -1388,7 +1389,7 @@ int git_pack_entry_find(
git_oid
found_oid
;
int
error
;
assert
(
p
);
GIT_ASSERT_ARG
(
p
);
if
(
len
==
GIT_OID_HEXSZ
&&
p
->
num_bad_objects
)
{
unsigned
i
;
...
...
src/pack.h
View file @
7cd0bf65
...
...
@@ -133,7 +133,7 @@ typedef struct git_packfile_stream {
git_mwindow
*
mw
;
}
git_packfile_stream
;
size_t
git_packfile__object_header
(
unsigned
char
*
hdr
,
size_t
size
,
git_object_t
type
);
int
git_packfile__object_header
(
size_t
*
out
,
unsigned
char
*
hdr
,
size_t
size
,
git_object_t
type
);
int
git_packfile__name
(
char
**
out
,
const
char
*
path
);
...
...
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