THIS IS A TEST INSTANCE ONLY! REPOSITORIES CAN BE DELETED AT ANY TIME!

Browse Source

rev-list: detect broken root trees

When the traversal machinery sees a commit without a root tree, it
assumes that the tree was part of a BOUNDARY commit, and quietly ignores
the tree. But it could also be caused by a commit whose root tree is
broken or missing.

Instead, let's die() when we see a NULL root tree. We can differentiate
it from the BOUNDARY case by seeing if the commit was actually parsed.
This covers that case, plus future-proofs us against any others where we
might try to show an unparsed commit.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
tags/v2.22.0-rc0
Jeff King Junio C Hamano 10 months ago
parent
commit
97dd512af7
2 changed files with 7 additions and 2 deletions
  1. +3
    -0
      list-objects.c
  2. +4
    -2
      t/t6102-rev-list-unexpected-objects.sh

+ 3
- 0
list-objects.c View File

@@ -374,6 +374,9 @@ static void do_traverse(struct traversal_context *ctx)
struct tree *tree = get_commit_tree(commit);
tree->object.flags |= NOT_USER_GIVEN;
add_pending_tree(ctx->revs, tree);
} else if (commit->object.parsed) {
die(_("unable to load root tree for commit %s"),
oid_to_hex(&commit->object.oid));
}
ctx->show_commit(commit, ctx->show_data);



+ 4
- 2
t/t6102-rev-list-unexpected-objects.sh View File

@@ -67,8 +67,10 @@ test_expect_success 'traverse unexpected non-tree root (lone)' '
test_must_fail git rev-list --objects $broken_commit
'

test_expect_failure 'traverse unexpected non-tree root (seen)' '
test_must_fail git rev-list --objects $blob $broken_commit
test_expect_success 'traverse unexpected non-tree root (seen)' '
test_must_fail git rev-list --objects $blob $broken_commit \
>output 2>&1 &&
test_i18ngrep "not a tree" output
'

test_expect_success 'setup unexpected non-commit tag' '


Loading…
Cancel
Save