Skip to content

Commit b49e74e

Browse files
ttaylorrgitster
authored andcommitted
list-objects.c: handle unexpected non-tree entries
Apply similar treatment as the previous commit for non-tree entries, too. Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 23c2044 commit b49e74e

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

list-objects.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ static void process_tree_contents(struct traversal_context *ctx,
125125

126126
if (S_ISDIR(entry.mode)) {
127127
struct tree *t = lookup_tree(ctx->revs->repo, &entry.oid);
128+
if (!t) {
129+
die(_("entry '%s' in tree %s has tree mode, "
130+
"but is not a tree"),
131+
entry.path, oid_to_hex(&tree->object.oid));
132+
}
128133
t->object.flags |= NOT_USER_GIVEN;
129134
process_tree(ctx, t, base, entry.path);
130135
}

t/t6102-rev-list-unexpected-objects.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ test_expect_failure 'traverse unexpected non-tree entry (lone)' '
3434
test_must_fail git rev-list --objects $broken_tree
3535
'
3636

37-
test_expect_failure 'traverse unexpected non-tree entry (seen)' '
38-
test_must_fail git rev-list --objects $blob $broken_tree
37+
test_expect_success 'traverse unexpected non-tree entry (seen)' '
38+
test_must_fail git rev-list --objects $blob $broken_tree >output 2>&1 &&
39+
test_i18ngrep "is not a tree" output
3940
'
4041

4142
test_expect_success 'setup unexpected non-commit parent' '

0 commit comments

Comments
 (0)