Skip to content

Commit 967f8c9

Browse files
committed
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
2 parents d59c12d + 69e4b34 commit 967f8c9

File tree

6 files changed

+56
-6
lines changed

6 files changed

+56
-6
lines changed

builtin/pack-objects.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2439,12 +2439,23 @@ static void loosen_unused_packed_objects(struct rev_info *revs)
24392439
}
24402440
}
24412441

2442+
/*
2443+
* This tracks any options which a reader of the pack might
2444+
* not understand, and which would therefore prevent blind reuse
2445+
* of what we have on disk.
2446+
*/
2447+
static int pack_options_allow_reuse(void)
2448+
{
2449+
return allow_ofs_delta;
2450+
}
2451+
24422452
static int get_object_list_from_bitmap(struct rev_info *revs)
24432453
{
24442454
if (prepare_bitmap_walk(revs) < 0)
24452455
return -1;
24462456

2447-
if (!reuse_partial_packfile_from_bitmap(
2457+
if (pack_options_allow_reuse() &&
2458+
!reuse_partial_packfile_from_bitmap(
24482459
&reuse_packfile,
24492460
&reuse_packfile_objects,
24502461
&reuse_packfile_offset)) {

list-objects.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,11 @@ static void process_tree(struct rev_info *revs,
8181
die("bad tree object");
8282
if (obj->flags & (UNINTERESTING | SEEN))
8383
return;
84-
if (parse_tree(tree) < 0)
84+
if (parse_tree(tree) < 0) {
85+
if (revs->ignore_missing_links)
86+
return;
8587
die("bad tree object %s", sha1_to_hex(obj->sha1));
88+
}
8689
obj->flags |= SEEN;
8790
show(obj, path, name, cb_data);
8891
me.up = path;

pack-bitmap.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,8 +727,10 @@ int prepare_bitmap_walk(struct rev_info *revs)
727727
revs->pending.objects = NULL;
728728

729729
if (haves) {
730+
revs->ignore_missing_links = 1;
730731
haves_bitmap = find_objects(revs, haves, NULL);
731732
reset_revision_walk();
733+
revs->ignore_missing_links = 0;
732734

733735
if (haves_bitmap == NULL)
734736
die("BUG: failed to perform bitmap walk");

revision.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2960,9 +2960,11 @@ static struct commit *get_revision_1(struct rev_info *revs)
29602960
if (revs->max_age != -1 &&
29612961
(commit->date < revs->max_age))
29622962
continue;
2963-
if (add_parents_to_list(revs, commit, &revs->commits, NULL) < 0)
2964-
die("Failed to traverse parents of commit %s",
2965-
sha1_to_hex(commit->object.sha1));
2963+
if (add_parents_to_list(revs, commit, &revs->commits, NULL) < 0) {
2964+
if (!revs->ignore_missing_links)
2965+
die("Failed to traverse parents of commit %s",
2966+
sha1_to_hex(commit->object.sha1));
2967+
}
29662968
}
29672969

29682970
switch (simplify_commit(revs, commit)) {

revision.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ struct rev_info {
7575
enum rev_sort_order sort_order;
7676

7777
unsigned int early_output:1,
78-
ignore_missing:1;
78+
ignore_missing:1,
79+
ignore_missing_links:1;
7980

8081
/* Traversal flags */
8182
unsigned int dense:1,

t/t5310-pack-bitmaps.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
test_description='exercise basic bitmap functionality'
44
. ./test-lib.sh
55

6+
objpath () {
7+
echo ".git/objects/$(echo "$1" | sed -e 's|\(..\)|\1/|')"
8+
}
9+
610
test_expect_success 'setup repo with moderate-sized history' '
711
for i in $(test_seq 1 10); do
812
test_commit $i
@@ -115,6 +119,33 @@ test_expect_success 'fetch (full bitmap)' '
115119
test_cmp expect actual
116120
'
117121

122+
test_expect_success 'create objects for missing-HAVE tests' '
123+
blob=$(echo "missing have" | git hash-object -w --stdin) &&
124+
tree=$(printf "100644 blob $blob\tfile\n" | git mktree) &&
125+
parent=$(echo parent | git commit-tree $tree) &&
126+
commit=$(echo commit | git commit-tree $tree -p $parent) &&
127+
cat >revs <<-EOF
128+
HEAD
129+
^HEAD^
130+
^$commit
131+
EOF
132+
'
133+
134+
test_expect_success 'pack with missing blob' '
135+
rm $(objpath $blob) &&
136+
git pack-objects --stdout --revs <revs >/dev/null
137+
'
138+
139+
test_expect_success 'pack with missing tree' '
140+
rm $(objpath $tree) &&
141+
git pack-objects --stdout --revs <revs >/dev/null
142+
'
143+
144+
test_expect_success 'pack with missing parent' '
145+
rm $(objpath $parent) &&
146+
git pack-objects --stdout --revs <revs >/dev/null
147+
'
148+
118149
test_lazy_prereq JGIT '
119150
type jgit
120151
'

0 commit comments

Comments
 (0)