diff options
| author | Junio C Hamano <gitster@pobox.com> | 2019-05-09 00:37:25 +0900 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2019-05-09 00:37:25 +0900 |
| commit | ea2dab1abbf14bfa7dd5299c9bb86d0f70aae019 (patch) | |
| tree | 053b83263d2b4c5d5ab6b0b51a9dcfdb864808bf /list-objects.c | |
| parent | Merge branch 'nd/sha1-name-c-wo-the-repository' (diff) | |
| parent | rev-list: detect broken root trees (diff) | |
| download | git-ea2dab1abbf14bfa7dd5299c9bb86d0f70aae019.tar.gz git-ea2dab1abbf14bfa7dd5299c9bb86d0f70aae019.zip | |
Merge branch 'tb/unexpected'
Code tightening against a "wrong" object appearing where an object
of a different type is expected, instead of blindly assuming that
the connection between objects are correctly made.
* tb/unexpected:
rev-list: detect broken root trees
rev-list: let traversal die when --missing is not in use
get_commit_tree(): return NULL for broken tree
list-objects.c: handle unexpected non-tree entries
list-objects.c: handle unexpected non-blob entries
t: introduce tests for unexpected object types
t: move 'hex2oct' into test-lib-functions.sh
Diffstat (limited to 'list-objects.c')
| -rw-r--r-- | list-objects.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/list-objects.c b/list-objects.c index dc77361e11..b5651ddd5b 100644 --- a/list-objects.c +++ b/list-objects.c @@ -125,6 +125,11 @@ static void process_tree_contents(struct traversal_context *ctx, if (S_ISDIR(entry.mode)) { struct tree *t = lookup_tree(ctx->revs->repo, &entry.oid); + if (!t) { + die(_("entry '%s' in tree %s has tree mode, " + "but is not a tree"), + entry.path, oid_to_hex(&tree->object.oid)); + } t->object.flags |= NOT_USER_GIVEN; process_tree(ctx, t, base, entry.path); } @@ -133,6 +138,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); } @@ -364,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); |
