diff options
-rw-r--r-- | list-objects.c | 5 | ||||
-rw-r--r-- | pack-bitmap.c | 2 | ||||
-rw-r--r-- | revision.c | 8 | ||||
-rw-r--r-- | revision.h | 3 | ||||
-rwxr-xr-x | t/t5310-pack-bitmaps.sh | 31 |
5 files changed, 44 insertions, 5 deletions
diff --git a/list-objects.c b/list-objects.c index 6cbedf0280..b2db6ba0d3 100644 --- a/list-objects.c +++ b/list-objects.c @@ -81,8 +81,11 @@ static void process_tree(struct rev_info *revs, die("bad tree object"); if (obj->flags & (UNINTERESTING | SEEN)) 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)); + } obj->flags |= SEEN; show(obj, path, name, cb_data); me.up = path; diff --git a/pack-bitmap.c b/pack-bitmap.c index ae0b57b950..91e4101531 100644 --- a/pack-bitmap.c +++ b/pack-bitmap.c @@ -727,8 +727,10 @@ int prepare_bitmap_walk(struct rev_info *revs) revs->pending.objects = NULL; if (haves) { + revs->ignore_missing_links = 1; haves_bitmap = find_objects(revs, haves, NULL); reset_revision_walk(); + revs->ignore_missing_links = 0; if (haves_bitmap == NULL) die("BUG: failed to perform bitmap walk"); diff --git a/revision.c b/revision.c index cddd6051e3..520b3e7df6 100644 --- a/revision.c +++ b/revision.c @@ -2866,9 +2866,11 @@ static struct commit *get_revision_1(struct rev_info *revs) if (revs->max_age != -1 && (commit->date < revs->max_age)) continue; - if (add_parents_to_list(revs, commit, &revs->commits, NULL) < 0) - die("Failed to traverse parents of commit %s", - sha1_to_hex(commit->object.sha1)); + if (add_parents_to_list(revs, commit, &revs->commits, NULL) < 0) { + if (!revs->ignore_missing_links) + die("Failed to traverse parents of commit %s", + sha1_to_hex(commit->object.sha1)); + } } switch (simplify_commit(revs, commit)) { diff --git a/revision.h b/revision.h index 9957f3c6e5..4f051d2ea2 100644 --- a/revision.h +++ b/revision.h @@ -69,7 +69,8 @@ struct rev_info { enum rev_sort_order sort_order; unsigned int early_output:1, - ignore_missing:1; + ignore_missing:1, + ignore_missing_links:1; /* Traversal flags */ unsigned int dense:1, diff --git a/t/t5310-pack-bitmaps.sh b/t/t5310-pack-bitmaps.sh index f13525caa3..f4f02ba918 100755 --- a/t/t5310-pack-bitmaps.sh +++ b/t/t5310-pack-bitmaps.sh @@ -3,6 +3,10 @@ test_description='exercise basic bitmap functionality' . ./test-lib.sh +objpath () { + echo ".git/objects/$(echo "$1" | sed -e 's|\(..\)|\1/|')" +} + test_expect_success 'setup repo with moderate-sized history' ' for i in $(test_seq 1 10); do test_commit $i @@ -115,6 +119,33 @@ test_expect_success 'fetch (full bitmap)' ' 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 ' type jgit ' |