summaryrefslogtreecommitdiffstats
path: root/t/t6700-tree-depth.sh
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2023-08-31 08:22:08 +0200
committerJunio C Hamano <gitster@pobox.com>2023-09-01 00:51:08 +0200
commit7b61bd18b13223064db01d89e3b8af106661efd5 (patch)
treea141fa6fa4bd6fad3ded7cb5b52aaaa12d64e2d4 /t/t6700-tree-depth.sh
parentlist-objects: respect max_allowed_tree_depth (diff)
downloadgit-7b61bd18b13223064db01d89e3b8af106661efd5.tar.xz
git-7b61bd18b13223064db01d89e3b8af106661efd5.zip
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>
Diffstat (limited to 't/t6700-tree-depth.sh')
-rwxr-xr-xt/t6700-tree-depth.sh9
1 files changed, 9 insertions, 0 deletions
diff --git a/t/t6700-tree-depth.sh b/t/t6700-tree-depth.sh
index f5d284b16e..e410c41234 100755
--- a/t/t6700-tree-depth.sh
+++ b/t/t6700-tree-depth.sh
@@ -81,4 +81,13 @@ test_expect_success 'default limit for rev-list fails gracefully' '
test_must_fail git rev-list --objects big >/dev/null
'
+test_expect_success 'limit recursion of diff-tree -r' '
+ git $small_ok diff-tree -r $EMPTY_TREE small &&
+ test_must_fail git $small_no diff-tree -r $EMPTY_TREE small
+'
+
+test_expect_success 'default limit for diff-tree fails gracefully' '
+ test_must_fail git diff-tree -r $EMPTY_TREE big
+'
+
test_done