interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / t / t6700-tree-depth.sh

111 lines · 3237 bytes Raw Blame History
1#!/bin/sh
2
3test_description='handling of deep trees in various commands'
4
5. ./test-lib.sh
6
7# We'll test against two depths here: a small one that will let us check the
8# behavior of the config setting easily, and a large one that should be
9# forbidden by default. Testing the default depth will let us know whether our
10# default is enough to prevent segfaults on systems that run the tests.
11small_depth=50
12big_depth=4100
13
14small_ok="-c core.maxtreedepth=$small_depth"
15small_no="-c core.maxtreedepth=$((small_depth-1))"
16
17# usage: mkdeep <name> <depth>
18# Create a tag <name> containing a file whose path has depth <depth>.
19#
20# We'll use fast-import here for two reasons:
21#
22# 1. It's faster than creating $big_depth tree objects.
23#
24# 2. As we tighten tree limits, it's more likely to allow large sizes
25# than trying to stuff a deep path into the index.
26mkdeep () {
27 {
28 echo "commit refs/tags/$1" &&
29 echo "committer foo <foo@example.com> 1234 -0000" &&
30 echo "data <<EOF" &&
31 echo "the commit message" &&
32 echo "EOF" &&
33
34 printf 'M 100644 inline ' &&
35 i=0 &&
36 while test $i -lt $2
37 do
38 printf 'a/'
39 i=$((i+1))
40 done &&
41 echo "file" &&
42
43 echo "data <<EOF" &&
44 echo "the file contents" &&
45 echo "EOF" &&
46 echo
47 } | git fast-import
48}
49
50test_expect_success 'create small tree' '
51 mkdeep small $small_depth
52'
53
54test_expect_success 'create big tree' '
55 mkdeep big $big_depth
56'
57
58test_expect_success 'limit recursion of git-archive' '
59 git $small_ok archive small >/dev/null &&
60 test_must_fail git $small_no archive small >/dev/null
61'
62
63test_expect_success 'default limit for git-archive fails gracefully' '
64 test_must_fail git archive big >/dev/null
65'
66
67test_expect_success 'limit recursion of ls-tree -r' '
68 git $small_ok ls-tree -r small &&
69 test_must_fail git $small_no ls-tree -r small
70'
71
72test_expect_success 'default limit for ls-tree fails gracefully' '
73 test_must_fail git ls-tree -r big >/dev/null
74'
75
76test_expect_success 'limit recursion of rev-list --objects' '
77 git $small_ok rev-list --objects small >/dev/null &&
78 test_must_fail git $small_no rev-list --objects small >/dev/null
79'
80
81test_expect_success 'default limit for rev-list fails gracefully' '
82 test_must_fail git rev-list --objects big >/dev/null
83'
84
85# The incremental check needs a boundary; without negative revisions
86# rev-list falls back to the full check.
87test_expect_success 'limit recursion of incremental check' '
88 boundary=$(git commit-tree $EMPTY_TREE -m boundary) &&
89 git $small_ok rev-list --connectivity-check=incremental \
90 --objects small --not $boundary >/dev/null &&
91 test_must_fail git $small_no rev-list \
92 --connectivity-check=incremental --objects small \
93 --not $boundary >/dev/null
94'
95
96test_expect_success 'default limit for incremental check fails gracefully' '
97 boundary=$(git commit-tree $EMPTY_TREE -m boundary) &&
98 test_must_fail git rev-list --connectivity-check=incremental \
99 --objects big --not $boundary >/dev/null
100'
101
102test_expect_success 'limit recursion of diff-tree -r' '
103 git $small_ok diff-tree -r $EMPTY_TREE small &&
104 test_must_fail git $small_no diff-tree -r $EMPTY_TREE small
105'
106
107test_expect_success 'default limit for diff-tree fails gracefully' '
108 test_must_fail git diff-tree -r $EMPTY_TREE big
109'
110
111test_done