3 test_description
='handling of deep trees in various commands'
5 TEST_PASSES_SANITIZE_LEAK
=true
8 # We'll test against two depths here: a small one that will let us check the
9 # behavior of the config setting easily, and a large one that should be
10 # forbidden by default. Testing the default depth will let us know whether our
11 # default is enough to prevent segfaults on systems that run the tests.
15 small_ok
="-c core.maxtreedepth=$small_depth"
16 small_no
="-c core.maxtreedepth=$((small_depth-1))"
18 # usage: mkdeep <name> <depth>
19 # Create a tag <name> containing a file whose path has depth <depth>.
21 # We'll use fast-import here for two reasons:
23 # 1. It's faster than creating $big_depth tree objects.
25 # 2. As we tighten tree limits, it's more likely to allow large sizes
26 # than trying to stuff a deep path into the index.
29 echo "commit refs/tags/$1" &&
30 echo "committer foo <foo@example.com> 1234 -0000" &&
32 echo "the commit message
" &&
35 printf 'M 100644 inline ' &&
45 echo "the file contents" &&
51 test_expect_success 'create small tree' '
52 mkdeep small $small_depth
55 test_expect_success 'create big tree' '
59 test_expect_success 'limit recursion of git-archive' '
60 git $small_ok archive small >/dev/null &&
61 test_must_fail git $small_no archive small >/dev/null
64 test_expect_success 'default limit for git-archive fails gracefully' '
65 test_must_fail git archive big >/dev/null
68 test_expect_success 'limit recursion of ls-tree -r' '
69 git $small_ok ls-tree -r small &&
70 test_must_fail git $small_no ls-tree -r small
73 test_expect_success 'default limit for ls-tree fails gracefully' '
74 test_must_fail git ls-tree -r big >/dev/null
77 test_expect_success 'limit recursion of rev-list --objects' '
78 git $small_ok rev-list --objects small >/dev/null &&
79 test_must_fail git $small_no rev-list --objects small >/dev/null
82 test_expect_success 'default limit for rev-list fails gracefully' '
83 test_must_fail git rev-list --objects big >/dev/null
86 test_expect_success 'limit recursion of diff-tree -r' '
87 git $small_ok diff-tree -r $EMPTY_TREE small &&
88 test_must_fail git $small_no diff-tree -r $EMPTY_TREE small
91 test_expect_success 'default limit for diff-tree fails gracefully' '
92 test_must_fail git diff-tree -r $EMPTY_TREE big