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
51e82492
Commit
51e82492
authored
Oct 03, 2013
by
Carlos Martín Nieto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pack: move the object header function here
parent
cf0582b4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
35 deletions
+35
-35
src/pack-objects.c
+1
-35
src/pack.c
+32
-0
src/pack.h
+2
-0
No files found.
src/pack-objects.c
View file @
51e82492
...
...
@@ -228,40 +228,6 @@ int git_packbuilder_insert(git_packbuilder *pb, const git_oid *oid,
return
0
;
}
/*
* The per-object header is a pretty dense thing, which is
* - first byte: low four bits are "size",
* then three bits of "type",
* with the high bit being "size continues".
* - each byte afterwards: low seven bits are size continuation,
* with the high bit being "size continues"
*/
static
int
gen_pack_object_header
(
unsigned
char
*
hdr
,
unsigned
long
size
,
git_otype
type
)
{
unsigned
char
*
hdr_base
;
unsigned
char
c
;
assert
(
type
>=
GIT_OBJ_COMMIT
&&
type
<=
GIT_OBJ_REF_DELTA
);
/* TODO: add support for chunked objects; see git.git 6c0d19b1 */
c
=
(
unsigned
char
)((
type
<<
4
)
|
(
size
&
15
));
size
>>=
4
;
hdr_base
=
hdr
;
while
(
size
)
{
*
hdr
++
=
c
|
0x80
;
c
=
size
&
0x7f
;
size
>>=
7
;
}
*
hdr
++
=
c
;
return
(
int
)(
hdr
-
hdr_base
);
}
static
int
get_delta
(
void
**
out
,
git_odb
*
odb
,
git_pobject
*
po
)
{
git_odb_object
*
src
=
NULL
,
*
trg
=
NULL
;
...
...
@@ -323,7 +289,7 @@ static int write_object(git_buf *buf, git_packbuilder *pb, git_pobject *po)
}
/* Write header */
hdr_len
=
g
en_pack
_object_header
(
hdr
,
size
,
type
);
hdr_len
=
g
it_packfile_
_object_header
(
hdr
,
size
,
type
);
if
(
git_buf_put
(
buf
,
(
char
*
)
hdr
,
hdr_len
)
<
0
)
goto
on_error
;
...
...
src/pack.c
View file @
51e82492
...
...
@@ -364,6 +364,38 @@ static unsigned char *pack_window_open(
return
git_mwindow_open
(
&
p
->
mwf
,
w_cursor
,
offset
,
20
,
left
);
}
/*
* The per-object header is a pretty dense thing, which is
* - first byte: low four bits are "size",
* then three bits of "type",
* with the high bit being "size continues".
* - each byte afterwards: low seven bits are size continuation,
* with the high bit being "size continues"
*/
int
git_packfile__object_header
(
unsigned
char
*
hdr
,
unsigned
long
size
,
git_otype
type
)
{
unsigned
char
*
hdr_base
;
unsigned
char
c
;
assert
(
type
>=
GIT_OBJ_COMMIT
&&
type
<=
GIT_OBJ_REF_DELTA
);
/* TODO: add support for chunked objects; see git.git 6c0d19b1 */
c
=
(
unsigned
char
)((
type
<<
4
)
|
(
size
&
15
));
size
>>=
4
;
hdr_base
=
hdr
;
while
(
size
)
{
*
hdr
++
=
c
|
0x80
;
c
=
size
&
0x7f
;
size
>>=
7
;
}
*
hdr
++
=
c
;
return
(
int
)(
hdr
-
hdr_base
);
}
static
int
packfile_unpack_header1
(
unsigned
long
*
usedp
,
size_t
*
sizep
,
...
...
src/pack.h
View file @
51e82492
...
...
@@ -112,6 +112,8 @@ typedef struct git_packfile_stream {
git_mwindow
*
mw
;
}
git_packfile_stream
;
int
git_packfile__object_header
(
unsigned
char
*
hdr
,
unsigned
long
size
,
git_otype
type
);
int
git_packfile_unpack_header
(
size_t
*
size_p
,
git_otype
*
type_p
,
...
...
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