mirror of
https://github.com/git/git.git
synced 2024-05-29 22:36:11 +02:00
list-objects.c: handle unexpected non-blob entries
Fix one of the cases described in the previous commit where a tree-entry that is promised to a blob is in fact a non-blob. When 'lookup_blob()' returns NULL, it is because Git has cached the requested object as a non-blob. In this case, prevent a SIGSEGV by 'die()'-ing immediately before attempting to dereference the result. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
0616617c7e
commit
23c204455b
|
@ -133,6 +133,11 @@ static void process_tree_contents(struct traversal_context *ctx,
|
|||
base, entry.path);
|
||||
else {
|
||||
struct blob *b = lookup_blob(ctx->revs->repo, &entry.oid);
|
||||
if (!b) {
|
||||
die(_("entry '%s' in tree %s has blob mode, "
|
||||
"but is not a blob"),
|
||||
entry.path, oid_to_hex(&tree->object.oid));
|
||||
}
|
||||
b->object.flags |= NOT_USER_GIVEN;
|
||||
process_blob(ctx, b, base, entry.path);
|
||||
}
|
||||
|
|
|
@ -20,8 +20,9 @@ test_expect_failure 'traverse unexpected non-blob entry (lone)' '
|
|||
test_must_fail git rev-list --objects $broken_tree
|
||||
'
|
||||
|
||||
test_expect_failure 'traverse unexpected non-blob entry (seen)' '
|
||||
test_must_fail git rev-list --objects $tree $broken_tree
|
||||
test_expect_success 'traverse unexpected non-blob entry (seen)' '
|
||||
test_must_fail git rev-list --objects $tree $broken_tree >output 2>&1 &&
|
||||
test_i18ngrep "is not a blob" output
|
||||
'
|
||||
|
||||
test_expect_success 'setup unexpected non-tree entry' '
|
||||
|
|
Loading…
Reference in New Issue