tree-diff: respect max_allowed_tree_depth
commit7b61bd18b13223064db01d89e3b8af106661efd5
authorJeff King <peff@peff.net>
Thu, 31 Aug 2023 06:22:08 +0000 (31 02:22 -0400)
committerJunio C Hamano <gitster@pobox.com>
Thu, 31 Aug 2023 22:51:08 +0000 (31 15:51 -0700)
treea141fa6fa4bd6fad3ded7cb5b52aaaa12d64e2d4
parent670a1dadc7d98b774cc0f870a4c75f57d1cfa9d4
tree-diff: respect max_allowed_tree_depth

When diffing trees, we recurse to handle subtrees. That means we may run
out of stack space and segfault. Let's teach this code path about
core.maxTreeDepth in order to fail more gracefully.

As with the previous patch, we have no way to return an error (and other
tree-loading problems would just cause us to die()). So we'll likewise
call die() if we exceed the maximum depth.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t6700-tree-depth.sh
tree-diff.c