]> git.ipfire.org Git - thirdparty/git.git/blame - t/lib-read-tree-m-3way.sh
The fifteenth batch
[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
cd26cd6c
SY
6 for b in N D M
7 do
8 p=$a$b
63713028
JH
9 echo This is $p from the original tree. >$p
10 echo This is Z/$p from the original tree. >Z/$p
ddea5719
SY
11 test_expect_success "adding test file $p and Z/$p" '
12 git update-index --add $p &&
13 git update-index --add Z/$p
14 '
63713028
JH
15 done
16done
17echo This is SS from the original tree. >SS
ddea5719 18test_expect_success 'adding test file SS' '
cd26cd6c 19 git update-index --add SS
ddea5719 20'
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
ddea5719 33test_expect_success 'adding test file TT' '
cd26cd6c 34 git update-index --add TT
ddea5719
SY
35'
36test_expect_success 'prepare initial tree' '
cd26cd6c 37 tree_O=$(git write-tree)
ddea5719 38'
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
ddea5719 48test_expect_success 'change in branch A (removal)' '
cd26cd6c 49 git update-index --remove $to_remove
ddea5719 50'
63713028
JH
51
52for p in M? Z/M?
53do
cd26cd6c
SY
54 echo This is modified $p in the branch A. >$p
55 test_expect_success 'change in branch A (modification)' '
56 git update-index $p
57 '
63713028
JH
58done
59
60for p in AN AA Z/AN Z/AA
61do
cd26cd6c
SY
62 echo This is added $p in the branch A. >$p
63 test_expect_success 'change in branch A (addition)' '
64 git update-index --add $p
65 '
63713028
JH
66done
67
68echo This is SS from the modified tree. >SS
69echo This is LL from the modified tree. >LL
ddea5719 70test_expect_success 'change in branch A (addition)' '
cd26cd6c
SY
71 git update-index --add LL &&
72 git update-index SS
ddea5719 73'
63713028
JH
74mv TT TT-
75sed -e '/Branch A/s/word/WORD/g' <TT- >TT
76rm -f TT-
ddea5719 77test_expect_success 'change in branch A (edit)' '
cd26cd6c 78 git update-index TT
ddea5719 79'
63713028
JH
80
81mkdir DF
82echo Branch A makes a file at DF/DF, creating a directory DF. >DF/DF
ddea5719 83test_expect_success 'change in branch A (change file to directory)' '
cd26cd6c 84 git update-index --add DF/DF
ddea5719 85'
63713028 86
ddea5719 87test_expect_success 'recording branch A tree' '
cd26cd6c 88 tree_A=$(git write-tree)
ddea5719 89'
a6080a0a 90
63713028
JH
91################################################################
92# Branch B
93# Start from O
94
95rm -rf [NDMASLT][NDMASLT] Z DF
96mkdir Z
ddea5719 97test_expect_success 'reading original tree and checking out' '
cd26cd6c
SY
98 git read-tree $tree_O &&
99 git checkout-index -a
ddea5719 100'
63713028
JH
101
102to_remove=$(echo ?D Z/?D)
103rm -f $to_remove
ddea5719 104test_expect_success 'change in branch B (removal)' '
cd26cd6c 105 git update-index --remove $to_remove
ddea5719 106'
63713028
JH
107
108for p in ?M Z/?M
109do
cd26cd6c
SY
110 echo This is modified $p in the branch B. >$p
111 test_expect_success 'change in branch B (modification)' '
112 git update-index $p
113 '
63713028
JH
114done
115
116for p in NA AA Z/NA Z/AA
117do
cd26cd6c
SY
118 echo This is added $p in the branch B. >$p
119 test_expect_success 'change in branch B (addition)' '
120 git update-index --add $p
121 '
63713028
JH
122done
123echo This is SS from the modified tree. >SS
124echo This is LL from the modified tree. >LL
ddea5719 125test_expect_success 'change in branch B (addition and modification)' '
cd26cd6c
SY
126 git update-index --add LL &&
127 git update-index SS
ddea5719 128'
63713028
JH
129mv TT TT-
130sed -e '/Branch B/s/word/WORD/g' <TT- >TT
131rm -f TT-
ddea5719 132test_expect_success 'change in branch B (modification)' '
cd26cd6c 133 git update-index TT
ddea5719 134'
63713028
JH
135
136echo Branch B makes a file at DF. >DF
ddea5719 137test_expect_success 'change in branch B (addition of a file to conflict with directory)' '
cd26cd6c 138 git update-index --add DF
ddea5719
SY
139'
140
141test_expect_success 'recording branch B tree' '
cd26cd6c 142 tree_B=$(git write-tree)
ddea5719
SY
143'
144
145test_expect_success 'keep contents of 3 trees for easy access' '
cd26cd6c
SY
146 rm -f .git/index &&
147 git read-tree $tree_O &&
148 mkdir .orig-O &&
149 git checkout-index --prefix=.orig-O/ -f -q -a &&
150 rm -f .git/index &&
151 git read-tree $tree_A &&
152 mkdir .orig-A &&
153 git checkout-index --prefix=.orig-A/ -f -q -a &&
154 rm -f .git/index &&
155 git read-tree $tree_B &&
156 mkdir .orig-B &&
157 git checkout-index --prefix=.orig-B/ -f -q -a
ddea5719 158'