]> git.ipfire.org Git - thirdparty/git.git/blame - t/lib-read-tree-m-3way.sh
path.c: don't call the match function without value in trie_find()
[thirdparty/git.git] / t / lib-read-tree-m-3way.sh
CommitLineData
63713028
JH
1: Included from t1000-read-tree-m-3way.sh and others
2# Original tree.
3mkdir Z
4for a in N D M
5do
6 for b in N D M
7 do
8 p=$a$b
9 echo This is $p from the original tree. >$p
10 echo This is Z/$p from the original tree. >Z/$p
11 test_expect_success \
12 "adding test file $p and Z/$p" \
5be60078
JH
13 'git update-index --add $p &&
14 git update-index --add Z/$p'
63713028
JH
15 done
16done
17echo This is SS from the original tree. >SS
18test_expect_success \
19 'adding test file SS' \
5be60078 20 'git update-index --add SS'
63713028
JH
21cat >TT <<\EOF
22This is a trivial merge sample text.
23Branch A is expected to upcase this word, here.
24There are some filler lines to avoid diff context
25conflicts here,
26like this one,
27and this one,
28and this one is yet another one of them.
29At the very end, here comes another line, that is
30the word, expected to be upcased by Branch B.
31This concludes the trivial merge sample file.
32EOF
33test_expect_success \
34 'adding test file TT' \
5be60078 35 'git update-index --add TT'
63713028
JH
36test_expect_success \
37 'prepare initial tree' \
5be60078 38 'tree_O=$(git write-tree)'
63713028
JH
39
40################################################################
41# Branch A and B makes the changes according to the above matrix.
42
43################################################################
44# Branch A
45
46to_remove=$(echo D? Z/D?)
47rm -f $to_remove
48test_expect_success \
49 'change in branch A (removal)' \
5be60078 50 'git update-index --remove $to_remove'
63713028
JH
51
52for p in M? Z/M?
53do
54 echo This is modified $p in the branch A. >$p
55 test_expect_success \
56 'change in branch A (modification)' \
5be60078 57 "git update-index $p"
63713028
JH
58done
59
60for p in AN AA Z/AN Z/AA
61do
62 echo This is added $p in the branch A. >$p
63 test_expect_success \
64 'change in branch A (addition)' \
5be60078 65 "git update-index --add $p"
63713028
JH
66done
67
68echo This is SS from the modified tree. >SS
69echo This is LL from the modified tree. >LL
70test_expect_success \
71 'change in branch A (addition)' \
5be60078
JH
72 'git update-index --add LL &&
73 git update-index SS'
63713028
JH
74mv TT TT-
75sed -e '/Branch A/s/word/WORD/g' <TT- >TT
76rm -f TT-
77test_expect_success \
78 'change in branch A (edit)' \
5be60078 79 'git update-index TT'
63713028
JH
80
81mkdir DF
82echo Branch A makes a file at DF/DF, creating a directory DF. >DF/DF
83test_expect_success \
84 'change in branch A (change file to directory)' \
5be60078 85 'git update-index --add DF/DF'
63713028
JH
86
87test_expect_success \
88 'recording branch A tree' \
5be60078 89 'tree_A=$(git write-tree)'
a6080a0a 90
63713028
JH
91################################################################
92# Branch B
93# Start from O
94
95rm -rf [NDMASLT][NDMASLT] Z DF
96mkdir Z
97test_expect_success \
98 'reading original tree and checking out' \
5be60078
JH
99 'git read-tree $tree_O &&
100 git checkout-index -a'
63713028
JH
101
102to_remove=$(echo ?D Z/?D)
103rm -f $to_remove
104test_expect_success \
105 'change in branch B (removal)' \
5be60078 106 "git update-index --remove $to_remove"
63713028
JH
107
108for p in ?M Z/?M
109do
110 echo This is modified $p in the branch B. >$p
111 test_expect_success \
112 'change in branch B (modification)' \
5be60078 113 "git update-index $p"
63713028
JH
114done
115
116for p in NA AA Z/NA Z/AA
117do
118 echo This is added $p in the branch B. >$p
119 test_expect_success \
120 'change in branch B (addition)' \
5be60078 121 "git update-index --add $p"
63713028
JH
122done
123echo This is SS from the modified tree. >SS
124echo This is LL from the modified tree. >LL
125test_expect_success \
126 'change in branch B (addition and modification)' \
5be60078
JH
127 'git update-index --add LL &&
128 git update-index SS'
63713028
JH
129mv TT TT-
130sed -e '/Branch B/s/word/WORD/g' <TT- >TT
131rm -f TT-
132test_expect_success \
133 'change in branch B (modification)' \
5be60078 134 'git update-index TT'
63713028
JH
135
136echo Branch B makes a file at DF. >DF
137test_expect_success \
138 'change in branch B (addition of a file to conflict with directory)' \
5be60078 139 'git update-index --add DF'
63713028
JH
140
141test_expect_success \
142 'recording branch B tree' \
5be60078 143 'tree_B=$(git write-tree)'
63713028 144
f225b218
JH
145test_expect_success \
146 'keep contents of 3 trees for easy access' \
147 'rm -f .git/index &&
5be60078 148 git read-tree $tree_O &&
f225b218 149 mkdir .orig-O &&
5be60078 150 git checkout-index --prefix=.orig-O/ -f -q -a &&
f225b218 151 rm -f .git/index &&
5be60078 152 git read-tree $tree_A &&
f225b218 153 mkdir .orig-A &&
5be60078 154 git checkout-index --prefix=.orig-A/ -f -q -a &&
f225b218 155 rm -f .git/index &&
5be60078 156 git read-tree $tree_B &&
f225b218 157 mkdir .orig-B &&
5be60078 158 git checkout-index --prefix=.orig-B/ -f -q -a'