Merge branch 'rs/daemon-sanitize-dir-sep'
[git.git] / t / t6001-rev-list-graft.sh
blob90d93f77fa79c2694ebd9b2229c8620859e6a36a
1 #!/bin/sh
3 test_description='Revision traversal vs grafts and path limiter'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
8 . ./test-lib.sh
10 test_expect_success setup '
11 mkdir subdir &&
12 echo >fileA fileA &&
13 echo >subdir/fileB fileB &&
14 git add fileA subdir/fileB &&
15 git commit -a -m "Initial in one history." &&
16 A0=$(git rev-parse --verify HEAD) &&
18 echo >fileA fileA modified &&
19 git commit -a -m "Second in one history." &&
20 A1=$(git rev-parse --verify HEAD) &&
22 echo >subdir/fileB fileB modified &&
23 git commit -a -m "Third in one history." &&
24 A2=$(git rev-parse --verify HEAD) &&
26 rm -f .git/refs/heads/main .git/index &&
28 echo >fileA fileA again &&
29 echo >subdir/fileB fileB again &&
30 git add fileA subdir/fileB &&
31 git commit -a -m "Initial in alternate history." &&
32 B0=$(git rev-parse --verify HEAD) &&
34 echo >fileA fileA modified in alternate history &&
35 git commit -a -m "Second in alternate history." &&
36 B1=$(git rev-parse --verify HEAD) &&
38 echo >subdir/fileB fileB modified in alternate history &&
39 git commit -a -m "Third in alternate history." &&
40 B2=$(git rev-parse --verify HEAD) &&
41 : done
44 check () {
45 type=$1
46 shift
48 arg=
49 which=arg
50 rm -f test.expect
51 for a
53 if test "z$a" = z--
54 then
55 which=expect
56 child=
57 continue
59 if test "$which" = arg
60 then
61 arg="$arg$a "
62 continue
64 if test "$type" = basic
65 then
66 echo "$a"
67 else
68 if test "z$child" != z
69 then
70 echo "$child $a"
72 child="$a"
74 done >test.expect
75 if test "$type" != basic && test "z$child" != z
76 then
77 echo >>test.expect $child
79 if test $type = basic
80 then
81 git rev-list $arg >test.actual
82 elif test $type = parents
83 then
84 git rev-list --parents $arg >test.actual
85 elif test $type = parents-raw
86 then
87 git rev-list --parents --pretty=raw $arg |
88 sed -n -e 's/^commit //p' >test.actual
90 test_cmp test.expect test.actual
93 for type in basic parents parents-raw
95 test_expect_success 'without grafts' "
96 rm -f .git/info/grafts &&
97 check $type $B2 -- $B2 $B1 $B0
100 test_expect_success 'with grafts' "
101 echo '$B0 $A2' >.git/info/grafts &&
102 check $type $B2 -- $B2 $B1 $B0 $A2 $A1 $A0
105 test_expect_success 'without grafts, with pathlimit' "
106 rm -f .git/info/grafts &&
107 check $type $B2 subdir -- $B2 $B0
110 test_expect_success 'with grafts, with pathlimit' "
111 echo '$B0 $A2' >.git/info/grafts &&
112 check $type $B2 subdir -- $B2 $B0 $A2 $A0
115 done
117 test_expect_success 'show advice that grafts are deprecated' '
118 git show HEAD 2>err &&
119 test_i18ngrep "git replace" err &&
120 test_config advice.graftFileDeprecated false &&
121 git show HEAD 2>err &&
122 test_i18ngrep ! "git replace" err
125 test_done