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
cc2447da
Commit
cc2447da
authored
Nov 06, 2013
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add git_packbuilder_hash to query pack filename
parent
e87d9d3d
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
2 deletions
+32
-2
include/git2/pack.h
+10
-0
src/pack-objects.c
+10
-2
tests-clar/pack/packbuilder.c
+12
-0
No files found.
include/git2/pack.h
View file @
cc2447da
...
@@ -130,6 +130,16 @@ GIT_EXTERN(int) git_packbuilder_write(
...
@@ -130,6 +130,16 @@ GIT_EXTERN(int) git_packbuilder_write(
git_transfer_progress_callback
progress_cb
,
git_transfer_progress_callback
progress_cb
,
void
*
progress_cb_payload
);
void
*
progress_cb_payload
);
/**
* Get the packfile's hash
*
* A packfile's name is derived from the sorted hashing of all object
* names. This is only correct after the packfile has been written.
*
* @param pb The packbuilder object
*/
GIT_EXTERN
(
const
git_oid
*
)
git_packbuilder_hash
(
git_packbuilder
*
pb
);
typedef
int
(
*
git_packbuilder_foreach_cb
)(
void
*
buf
,
size_t
size
,
void
*
payload
);
typedef
int
(
*
git_packbuilder_foreach_cb
)(
void
*
buf
,
size_t
size
,
void
*
payload
);
/**
/**
* Create the new pack and pass each object to the callback
* Create the new pack and pass each object to the callback
...
...
src/pack-objects.c
View file @
cc2447da
...
@@ -560,6 +560,7 @@ static int write_pack(git_packbuilder *pb,
...
@@ -560,6 +560,7 @@ static int write_pack(git_packbuilder *pb,
git_buf
buf
=
GIT_BUF_INIT
;
git_buf
buf
=
GIT_BUF_INIT
;
enum
write_one_status
status
;
enum
write_one_status
status
;
struct
git_pack_header
ph
;
struct
git_pack_header
ph
;
git_oid
entry_oid
;
unsigned
int
i
=
0
;
unsigned
int
i
=
0
;
int
error
=
0
;
int
error
=
0
;
...
@@ -596,10 +597,10 @@ static int write_pack(git_packbuilder *pb,
...
@@ -596,10 +597,10 @@ static int write_pack(git_packbuilder *pb,
}
while
(
pb
->
nr_remaining
&&
i
<
pb
->
nr_objects
);
}
while
(
pb
->
nr_remaining
&&
i
<
pb
->
nr_objects
);
if
((
error
=
git_hash_final
(
&
pb
->
pack
_oid
,
&
pb
->
ctx
))
<
0
)
if
((
error
=
git_hash_final
(
&
entry
_oid
,
&
pb
->
ctx
))
<
0
)
goto
done
;
goto
done
;
error
=
cb
(
pb
->
pack
_oid
.
id
,
GIT_OID_RAWSZ
,
data
);
error
=
cb
(
entry
_oid
.
id
,
GIT_OID_RAWSZ
,
data
);
done
:
done
:
git__free
(
write_order
);
git__free
(
write_order
);
...
@@ -1269,12 +1270,19 @@ int git_packbuilder_write(
...
@@ -1269,12 +1270,19 @@ int git_packbuilder_write(
return
-
1
;
return
-
1
;
}
}
git_oid_cpy
(
&
pb
->
pack_oid
,
git_indexer_hash
(
indexer
));
git_indexer_free
(
indexer
);
git_indexer_free
(
indexer
);
return
0
;
return
0
;
}
}
#undef PREPARE_PACK
#undef PREPARE_PACK
const
git_oid
*
git_packbuilder_hash
(
git_packbuilder
*
pb
)
{
return
&
pb
->
pack_oid
;
}
static
int
cb_tree_walk
(
const
char
*
root
,
const
git_tree_entry
*
entry
,
void
*
payload
)
static
int
cb_tree_walk
(
const
char
*
root
,
const
git_tree_entry
*
entry
,
void
*
payload
)
{
{
struct
tree_walk_context
*
ctx
=
payload
;
struct
tree_walk_context
*
ctx
=
payload
;
...
...
tests-clar/pack/packbuilder.c
View file @
cc2447da
...
@@ -128,6 +128,18 @@ void test_pack_packbuilder__create_pack(void)
...
@@ -128,6 +128,18 @@ void test_pack_packbuilder__create_pack(void)
cl_assert_equal_s
(
hex
,
"5d410bdf97cf896f9007681b92868471d636954b"
);
cl_assert_equal_s
(
hex
,
"5d410bdf97cf896f9007681b92868471d636954b"
);
}
}
void
test_pack_packbuilder__get_hash
(
void
)
{
char
hex
[
41
];
hex
[
40
]
=
'\0'
;
seed_packbuilder
();
git_packbuilder_write
(
_packbuilder
,
"."
,
NULL
,
NULL
);
git_oid_fmt
(
hex
,
git_packbuilder_hash
(
_packbuilder
));
cl_assert_equal_s
(
hex
,
"80e61eb315239ef3c53033e37fee43b744d57122"
);
}
static
git_transfer_progress
stats
;
static
git_transfer_progress
stats
;
static
int
foreach_cb
(
void
*
buf
,
size_t
len
,
void
*
payload
)
static
int
foreach_cb
(
void
*
buf
,
size_t
len
,
void
*
payload
)
{
{
...
...
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