diff options
author | Junio C Hamano <gitster@pobox.com> | 2019-05-08 17:37:25 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-05-08 17:37:25 +0200 |
commit | ea2dab1abbf14bfa7dd5299c9bb86d0f70aae019 (patch) | |
tree | 053b83263d2b4c5d5ab6b0b51a9dcfdb864808bf /commit.c | |
parent | Merge branch 'nd/sha1-name-c-wo-the-repository' (diff) | |
parent | rev-list: detect broken root trees (diff) | |
download | git-ea2dab1abbf14bfa7dd5299c9bb86d0f70aae019.tar.xz 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 'commit.c')
-rw-r--r-- | commit.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -351,10 +351,10 @@ struct tree *repo_get_commit_tree(struct repository *r, if (commit->maybe_tree || !commit->object.parsed) return commit->maybe_tree; - if (commit->graph_pos == COMMIT_NOT_FROM_GRAPH) - BUG("commit has NULL tree, but was not loaded from commit-graph"); + if (commit->graph_pos != COMMIT_NOT_FROM_GRAPH) + return get_commit_tree_in_graph(r, commit); - return get_commit_tree_in_graph(r, commit); + return NULL; } struct object_id *get_commit_tree_oid(const struct commit *commit) |