run-command(win32): resolve the path to the Unix shell early
[git.git] / t / t6001-rev-list-graft.sh
blob3553bbbfe73bd085eed955939ed7b721aa1a4892
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_PASSES_SANITIZE_LEAK=true
9 . ./test-lib.sh
11 test_expect_success setup '
12 mkdir subdir &&
13 echo >fileA fileA &&
14 echo >subdir/fileB fileB &&
15 git add fileA subdir/fileB &&
16 git commit -a -m "Initial in one history." &&
17 A0=$(git rev-parse --verify HEAD) &&
19 echo >fileA fileA modified &&
20 git commit -a -m "Second in one history." &&
21 A1=$(git rev-parse --verify HEAD) &&
23 echo >subdir/fileB fileB modified &&
24 git commit -a -m "Third in one history." &&
25 A2=$(git rev-parse --verify HEAD) &&
27 git update-ref -d refs/heads/main &&
28 rm -f .git/index &&
30 echo >fileA fileA again &&
31 echo >subdir/fileB fileB again &&
32 git add fileA subdir/fileB &&
33 git commit -a -m "Initial in alternate history." &&
34 B0=$(git rev-parse --verify HEAD) &&
36 echo >fileA fileA modified in alternate history &&
37 git commit -a -m "Second in alternate history." &&
38 B1=$(git rev-parse --verify HEAD) &&
40 echo >subdir/fileB fileB modified in alternate history &&
41 git commit -a -m "Third in alternate history." &&
42 B2=$(git rev-parse --verify HEAD) &&
43 : done
46 check () {
47 type=$1
48 shift
50 arg=
51 which=arg
52 rm -f test.expect
53 for a
55 if test "z$a" = z--
56 then
57 which=expect
58 child=
59 continue
61 if test "$which" = arg
62 then
63 arg="$arg$a "
64 continue
66 if test "$type" = basic
67 then
68 echo "$a"
69 else
70 if test "z$child" != z
71 then
72 echo "$child $a"
74 child="$a"
76 done >test.expect
77 if test "$type" != basic && test "z$child" != z
78 then
79 echo >>test.expect $child
81 if test $type = basic
82 then
83 git rev-list $arg >test.actual
84 elif test $type = parents
85 then
86 git rev-list --parents $arg >test.actual
87 elif test $type = parents-raw
88 then
89 git rev-list --parents --pretty=raw $arg |
90 sed -n -e 's/^commit //p' >test.actual
92 test_cmp test.expect test.actual
95 for type in basic parents parents-raw
97 test_expect_success 'without grafts' "
98 rm -f .git/info/grafts &&
99 check $type $B2 -- $B2 $B1 $B0
102 test_expect_success 'with grafts' "
103 mkdir -p .git/info &&
104 echo '$B0 $A2' >.git/info/grafts &&
105 check $type $B2 -- $B2 $B1 $B0 $A2 $A1 $A0
108 test_expect_success 'without grafts, with pathlimit' "
109 rm -f .git/info/grafts &&
110 check $type $B2 subdir -- $B2 $B0
113 test_expect_success 'with grafts, with pathlimit' "
114 echo '$B0 $A2' >.git/info/grafts &&
115 check $type $B2 subdir -- $B2 $B0 $A2 $A0
118 done
120 test_expect_success 'show advice that grafts are deprecated' '
121 git show HEAD 2>err &&
122 test_grep "git replace" err &&
123 test_config advice.graftFileDeprecated false &&
124 git show HEAD 2>err &&
125 test_grep ! "git replace" err
128 test_done