gc: add `gc.repackFilter` config option
[git.git] / t / t6700-tree-depth.sh
blobe410c41234c7d36069c27a69598e02a3f354322f
1 #!/bin/sh
3 test_description='handling of deep trees in various commands'
4 . ./test-lib.sh
6 # We'll test against two depths here: a small one that will let us check the
7 # behavior of the config setting easily, and a large one that should be
8 # forbidden by default. Testing the default depth will let us know whether our
9 # default is enough to prevent segfaults on systems that run the tests.
10 small_depth=50
11 big_depth=4100
13 small_ok="-c core.maxtreedepth=$small_depth"
14 small_no="-c core.maxtreedepth=$((small_depth-1))"
16 # usage: mkdeep <name> <depth>
17 # Create a tag <name> containing a file whose path has depth <depth>.
19 # We'll use fast-import here for two reasons:
21 # 1. It's faster than creating $big_depth tree objects.
23 # 2. As we tighten tree limits, it's more likely to allow large sizes
24 # than trying to stuff a deep path into the index.
25 mkdeep () {
27 echo "commit refs/tags/$1" &&
28 echo "committer foo <foo@example.com> 1234 -0000" &&
29 echo "data <<EOF" &&
30 echo "the commit message" &&
31 echo "EOF" &&
33 printf 'M 100644 inline ' &&
34 i=0 &&
35 while test $i -lt $2
37 printf 'a/'
38 i=$((i+1))
39 done &&
40 echo "file" &&
42 echo "data <<EOF" &&
43 echo "the file contents" &&
44 echo "EOF" &&
45 echo
46 } | git fast-import
49 test_expect_success 'create small tree' '
50 mkdeep small $small_depth
53 test_expect_success 'create big tree' '
54 mkdeep big $big_depth
57 test_expect_success 'limit recursion of git-archive' '
58 git $small_ok archive small >/dev/null &&
59 test_must_fail git $small_no archive small >/dev/null
62 test_expect_success 'default limit for git-archive fails gracefully' '
63 test_must_fail git archive big >/dev/null
66 test_expect_success 'limit recursion of ls-tree -r' '
67 git $small_ok ls-tree -r small &&
68 test_must_fail git $small_no ls-tree -r small
71 test_expect_success 'default limit for ls-tree fails gracefully' '
72 test_must_fail git ls-tree -r big >/dev/null
75 test_expect_success 'limit recursion of rev-list --objects' '
76 git $small_ok rev-list --objects small >/dev/null &&
77 test_must_fail git $small_no rev-list --objects small >/dev/null
80 test_expect_success 'default limit for rev-list fails gracefully' '
81 test_must_fail git rev-list --objects big >/dev/null
84 test_expect_success 'limit recursion of diff-tree -r' '
85 git $small_ok diff-tree -r $EMPTY_TREE small &&
86 test_must_fail git $small_no diff-tree -r $EMPTY_TREE small
89 test_expect_success 'default limit for diff-tree fails gracefully' '
90 test_must_fail git diff-tree -r $EMPTY_TREE big
93 test_done