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
989abe9b
Commit
989abe9b
authored
Feb 25, 2013
by
Vicent Martí
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1362 from schu/packbuilder-nits
packbuilder: minor improvements
parents
25a0831f
6774b107
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
1 deletions
+59
-1
include/git2/pack.h
+27
-1
tests-clar/pack/packbuilder.c
+32
-0
No files found.
include/git2/pack.h
View file @
989abe9b
...
...
@@ -13,7 +13,33 @@
/**
* @file git2/pack.h
* @brief Git pack management routines
* @defgroup git_pack Git pack management routines
*
* Packing objects
* ---------------
*
* Creation of packfiles requires two steps:
*
* - First, insert all the objects you want to put into the packfile
* using `git_packbuilder_insert` and `git_packbuilder_insert_tree`.
* It's important to add the objects in recency order ("in the order
* that they are 'reachable' from head").
*
* "ANY order will give you a working pack, ... [but it is] the thing
* that gives packs good locality. It keeps the objects close to the
* head (whether they are old or new, but they are _reachable_ from the
* head) at the head of the pack. So packs actually have absolutely
* _wonderful_ IO patterns." - Linus Torvalds
* git.git/Documentation/technical/pack-heuristics.txt
*
* - Second, use `git_packbuilder_write` or `git_packbuilder_foreach` to
* write the resulting packfile.
*
* libgit2 will take care of the delta ordering and generation.
* `git_packbuilder_set_threads` can be used to adjust the number of
* threads used for the process.
*
* See tests-clar/pack/packbuilder.c for an example.
*
* @ingroup Git
* @{
*/
...
...
tests-clar/pack/packbuilder.c
View file @
989abe9b
#include "clar_libgit2.h"
#include "fileops.h"
#include "hash.h"
#include "iterator.h"
#include "vector.h"
#include "posix.h"
...
...
@@ -76,6 +78,10 @@ static void seed_packbuilder(void)
void
test_pack_packbuilder__create_pack
(
void
)
{
git_transfer_progress
stats
;
git_buf
buf
=
GIT_BUF_INIT
;
git_hash_ctx
ctx
;
git_oid
hash
;
char
hex
[
41
];
hex
[
40
]
=
'\0'
;
seed_packbuilder
();
cl_git_pass
(
git_packbuilder_write
(
_packbuilder
,
"testpack.pack"
));
...
...
@@ -83,6 +89,32 @@ void test_pack_packbuilder__create_pack(void)
cl_git_pass
(
git_indexer_new
(
&
_indexer
,
"testpack.pack"
));
cl_git_pass
(
git_indexer_run
(
_indexer
,
&
stats
));
cl_git_pass
(
git_indexer_write
(
_indexer
));
/*
* By default, packfiles are created with only one thread.
* Therefore we can predict the object ordering and make sure
* we create exactly the same pack as git.git does when *not*
* reusing existing deltas (as libgit2).
*
* $ cd tests-clar/resources/testrepo.git
* $ git rev-list --objects HEAD | \
* git pack-objects -q --no-reuse-delta --threads=1 pack
* $ sha1sum git-80e61eb315239ef3c53033e37fee43b744d57122.pack
* 5d410bdf97cf896f9007681b92868471d636954b
*
*/
cl_git_pass
(
git_futils_readbuffer
(
&
buf
,
"testpack.pack"
));
cl_git_pass
(
git_hash_init
(
&
ctx
));
cl_git_pass
(
git_hash_update
(
&
ctx
,
buf
.
ptr
,
buf
.
size
));
cl_git_pass
(
git_hash_final
(
&
hash
,
&
ctx
));
git_buf_free
(
&
buf
);
git_oid_fmt
(
hex
,
&
hash
);
cl_assert_equal_s
(
hex
,
"5d410bdf97cf896f9007681b92868471d636954b"
);
}
static
git_transfer_progress
stats
;
...
...
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