]> git.ipfire.org Git - thirdparty/git.git/blame - t/t6001-rev-list-graft.sh
tests: mark tests relying on the current default for `init.defaultBranch`
[thirdparty/git.git] / t / t6001-rev-list-graft.sh
CommitLineData
16652170
JH
1#!/bin/sh
2
3test_description='Revision traversal vs grafts and path limiter'
4
334afbc7
JS
5GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
6export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7
16652170
JH
8. ./test-lib.sh
9
10test_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." &&
11da571a 16 A0=$(git rev-parse --verify HEAD) &&
16652170
JH
17
18 echo >fileA fileA modified &&
19 git commit -a -m "Second in one history." &&
11da571a 20 A1=$(git rev-parse --verify HEAD) &&
16652170
JH
21
22 echo >subdir/fileB fileB modified &&
23 git commit -a -m "Third in one history." &&
11da571a 24 A2=$(git rev-parse --verify HEAD) &&
16652170
JH
25
26 rm -f .git/refs/heads/master .git/index &&
27
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." &&
11da571a 32 B0=$(git rev-parse --verify HEAD) &&
16652170
JH
33
34 echo >fileA fileA modified in alternate history &&
35 git commit -a -m "Second in alternate history." &&
11da571a 36 B1=$(git rev-parse --verify HEAD) &&
16652170
JH
37
38 echo >subdir/fileB fileB modified in alternate history &&
39 git commit -a -m "Third in alternate history." &&
11da571a 40 B2=$(git rev-parse --verify HEAD) &&
16652170
JH
41 : done
42'
43
44check () {
45 type=$1
46 shift
47
48 arg=
49 which=arg
50 rm -f test.expect
51 for a
52 do
53 if test "z$a" = z--
54 then
55 which=expect
56 child=
57 continue
58 fi
59 if test "$which" = arg
60 then
61 arg="$arg$a "
62 continue
63 fi
64 if test "$type" = basic
65 then
66 echo "$a"
67 else
68 if test "z$child" != z
69 then
70 echo "$child $a"
71 fi
72 child="$a"
73 fi
74 done >test.expect
75 if test "$type" != basic && test "z$child" != z
76 then
77 echo >>test.expect $child
78 fi
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
89 fi
4fdf71be 90 test_cmp test.expect test.actual
16652170
JH
91}
92
93for type in basic parents parents-raw
94do
95 test_expect_success 'without grafts' "
a48fcd83 96 rm -f .git/info/grafts &&
16652170
JH
97 check $type $B2 -- $B2 $B1 $B0
98 "
99
100 test_expect_success 'with grafts' "
a48fcd83 101 echo '$B0 $A2' >.git/info/grafts &&
16652170
JH
102 check $type $B2 -- $B2 $B1 $B0 $A2 $A1 $A0
103 "
104
105 test_expect_success 'without grafts, with pathlimit' "
a48fcd83 106 rm -f .git/info/grafts &&
16652170
JH
107 check $type $B2 subdir -- $B2 $B0
108 "
109
110 test_expect_success 'with grafts, with pathlimit' "
a48fcd83 111 echo '$B0 $A2' >.git/info/grafts &&
16652170
JH
112 check $type $B2 subdir -- $B2 $B0 $A2 $A0
113 "
114
115done
f9f99b3f
JS
116
117test_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
123'
124
16652170 125test_done