diff options
Diffstat (limited to 'list-objects.c')
-rw-r--r-- | list-objects.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/list-objects.c b/list-objects.c index 8bb6d3c922..f39b68faf5 100644 --- a/list-objects.c +++ b/list-objects.c @@ -14,6 +14,7 @@ #include "packfile.h" #include "object-store-ll.h" #include "trace.h" +#include "environment.h" struct traversal_context { struct rev_info *revs; @@ -21,6 +22,7 @@ struct traversal_context { show_commit_fn show_commit; void *show_data; struct filter *filter; + int depth; }; static void show_commit(struct traversal_context *ctx, @@ -121,7 +123,9 @@ static void process_tree_contents(struct traversal_context *ctx, entry.path, oid_to_hex(&tree->object.oid)); } t->object.flags |= NOT_USER_GIVEN; + ctx->depth++; process_tree(ctx, t, base, entry.path); + ctx->depth--; } else if (S_ISGITLINK(entry.mode)) ; /* ignore gitlink */ @@ -159,6 +163,9 @@ static void process_tree(struct traversal_context *ctx, !revs->include_check_obj(&tree->object, revs->include_check_data)) return; + if (ctx->depth > max_allowed_tree_depth) + die("exceeded maximum allowed tree depth"); + failed_parse = parse_tree_gently(tree, 1); if (failed_parse) { if (revs->ignore_missing_links) @@ -173,7 +180,7 @@ static void process_tree(struct traversal_context *ctx, is_promisor_object(&obj->oid)) return; - if (!revs->do_not_die_on_missing_tree) + if (!revs->do_not_die_on_missing_objects) die("bad tree object %s", oid_to_hex(&obj->oid)); } @@ -352,6 +359,7 @@ static void traverse_non_commits(struct traversal_context *ctx, if (!path) path = ""; if (obj->type == OBJ_TREE) { + ctx->depth = 0; process_tree(ctx, (struct tree *)obj, base, path); continue; } @@ -384,6 +392,9 @@ static void do_traverse(struct traversal_context *ctx) */ if (!ctx->revs->tree_objects) ; /* do not bother loading tree */ + else if (ctx->revs->do_not_die_on_missing_objects && + oidset_contains(&ctx->revs->missing_commits, &commit->object.oid)) + ; else if (repo_get_commit_tree(the_repository, commit)) { struct tree *tree = repo_get_commit_tree(the_repository, commit); |