Merge branch 'jk/pack-bitmap'
* jk/pack-bitmap: pack-objects: do not reuse packfiles without --delta-base-offset add `ignore_missing_links` mode to revwalk
This commit is contained in:
@ -2439,12 +2439,23 @@ static void loosen_unused_packed_objects(struct rev_info *revs)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This tracks any options which a reader of the pack might
|
||||||
|
* not understand, and which would therefore prevent blind reuse
|
||||||
|
* of what we have on disk.
|
||||||
|
*/
|
||||||
|
static int pack_options_allow_reuse(void)
|
||||||
|
{
|
||||||
|
return allow_ofs_delta;
|
||||||
|
}
|
||||||
|
|
||||||
static int get_object_list_from_bitmap(struct rev_info *revs)
|
static int get_object_list_from_bitmap(struct rev_info *revs)
|
||||||
{
|
{
|
||||||
if (prepare_bitmap_walk(revs) < 0)
|
if (prepare_bitmap_walk(revs) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!reuse_partial_packfile_from_bitmap(
|
if (pack_options_allow_reuse() &&
|
||||||
|
!reuse_partial_packfile_from_bitmap(
|
||||||
&reuse_packfile,
|
&reuse_packfile,
|
||||||
&reuse_packfile_objects,
|
&reuse_packfile_objects,
|
||||||
&reuse_packfile_offset)) {
|
&reuse_packfile_offset)) {
|
||||||
|
@ -81,8 +81,11 @@ static void process_tree(struct rev_info *revs,
|
|||||||
die("bad tree object");
|
die("bad tree object");
|
||||||
if (obj->flags & (UNINTERESTING | SEEN))
|
if (obj->flags & (UNINTERESTING | SEEN))
|
||||||
return;
|
return;
|
||||||
if (parse_tree(tree) < 0)
|
if (parse_tree(tree) < 0) {
|
||||||
|
if (revs->ignore_missing_links)
|
||||||
|
return;
|
||||||
die("bad tree object %s", sha1_to_hex(obj->sha1));
|
die("bad tree object %s", sha1_to_hex(obj->sha1));
|
||||||
|
}
|
||||||
obj->flags |= SEEN;
|
obj->flags |= SEEN;
|
||||||
show(obj, path, name, cb_data);
|
show(obj, path, name, cb_data);
|
||||||
me.up = path;
|
me.up = path;
|
||||||
|
@ -727,8 +727,10 @@ int prepare_bitmap_walk(struct rev_info *revs)
|
|||||||
revs->pending.objects = NULL;
|
revs->pending.objects = NULL;
|
||||||
|
|
||||||
if (haves) {
|
if (haves) {
|
||||||
|
revs->ignore_missing_links = 1;
|
||||||
haves_bitmap = find_objects(revs, haves, NULL);
|
haves_bitmap = find_objects(revs, haves, NULL);
|
||||||
reset_revision_walk();
|
reset_revision_walk();
|
||||||
|
revs->ignore_missing_links = 0;
|
||||||
|
|
||||||
if (haves_bitmap == NULL)
|
if (haves_bitmap == NULL)
|
||||||
die("BUG: failed to perform bitmap walk");
|
die("BUG: failed to perform bitmap walk");
|
||||||
|
@ -2960,10 +2960,12 @@ static struct commit *get_revision_1(struct rev_info *revs)
|
|||||||
if (revs->max_age != -1 &&
|
if (revs->max_age != -1 &&
|
||||||
(commit->date < revs->max_age))
|
(commit->date < revs->max_age))
|
||||||
continue;
|
continue;
|
||||||
if (add_parents_to_list(revs, commit, &revs->commits, NULL) < 0)
|
if (add_parents_to_list(revs, commit, &revs->commits, NULL) < 0) {
|
||||||
|
if (!revs->ignore_missing_links)
|
||||||
die("Failed to traverse parents of commit %s",
|
die("Failed to traverse parents of commit %s",
|
||||||
sha1_to_hex(commit->object.sha1));
|
sha1_to_hex(commit->object.sha1));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch (simplify_commit(revs, commit)) {
|
switch (simplify_commit(revs, commit)) {
|
||||||
case commit_ignore:
|
case commit_ignore:
|
||||||
|
@ -75,7 +75,8 @@ struct rev_info {
|
|||||||
enum rev_sort_order sort_order;
|
enum rev_sort_order sort_order;
|
||||||
|
|
||||||
unsigned int early_output:1,
|
unsigned int early_output:1,
|
||||||
ignore_missing:1;
|
ignore_missing:1,
|
||||||
|
ignore_missing_links:1;
|
||||||
|
|
||||||
/* Traversal flags */
|
/* Traversal flags */
|
||||||
unsigned int dense:1,
|
unsigned int dense:1,
|
||||||
|
@ -3,6 +3,10 @@
|
|||||||
test_description='exercise basic bitmap functionality'
|
test_description='exercise basic bitmap functionality'
|
||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
|
|
||||||
|
objpath () {
|
||||||
|
echo ".git/objects/$(echo "$1" | sed -e 's|\(..\)|\1/|')"
|
||||||
|
}
|
||||||
|
|
||||||
test_expect_success 'setup repo with moderate-sized history' '
|
test_expect_success 'setup repo with moderate-sized history' '
|
||||||
for i in $(test_seq 1 10); do
|
for i in $(test_seq 1 10); do
|
||||||
test_commit $i
|
test_commit $i
|
||||||
@ -115,6 +119,33 @@ test_expect_success 'fetch (full bitmap)' '
|
|||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'create objects for missing-HAVE tests' '
|
||||||
|
blob=$(echo "missing have" | git hash-object -w --stdin) &&
|
||||||
|
tree=$(printf "100644 blob $blob\tfile\n" | git mktree) &&
|
||||||
|
parent=$(echo parent | git commit-tree $tree) &&
|
||||||
|
commit=$(echo commit | git commit-tree $tree -p $parent) &&
|
||||||
|
cat >revs <<-EOF
|
||||||
|
HEAD
|
||||||
|
^HEAD^
|
||||||
|
^$commit
|
||||||
|
EOF
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'pack with missing blob' '
|
||||||
|
rm $(objpath $blob) &&
|
||||||
|
git pack-objects --stdout --revs <revs >/dev/null
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'pack with missing tree' '
|
||||||
|
rm $(objpath $tree) &&
|
||||||
|
git pack-objects --stdout --revs <revs >/dev/null
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'pack with missing parent' '
|
||||||
|
rm $(objpath $parent) &&
|
||||||
|
git pack-objects --stdout --revs <revs >/dev/null
|
||||||
|
'
|
||||||
|
|
||||||
test_lazy_prereq JGIT '
|
test_lazy_prereq JGIT '
|
||||||
type jgit
|
type jgit
|
||||||
'
|
'
|
||||||
|
Reference in New Issue
Block a user