test-suite: Log everything to a file in non-verbose mode
[git/dscho.git] / t / t6022-merge-rename.sh
blobd69a364caecd0b7311a4d4a27c15e7760c929c92
1 #!/bin/sh
3 test_description='Merge-recursive merging renames'
4 . ./test-lib.sh
6 test_expect_success setup \
8 cat >A <<\EOF &&
9 a aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
10 b bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
11 c cccccccccccccccccccccccccccccccccccccccccccccccc
12 d dddddddddddddddddddddddddddddddddddddddddddddddd
13 e eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
14 f ffffffffffffffffffffffffffffffffffffffffffffffff
15 g gggggggggggggggggggggggggggggggggggggggggggggggg
16 h hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
17 i iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
18 j jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
19 k kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
20 l llllllllllllllllllllllllllllllllllllllllllllllll
21 m mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
22 n nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
23 o oooooooooooooooooooooooooooooooooooooooooooooooo
24 EOF
26 cat >M <<\EOF &&
27 A AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
28 B BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
29 C CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
30 D DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
31 E EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
32 F FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
33 G GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG
34 H HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
35 I IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
36 J JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ
37 K KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK
38 L LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL
39 M MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
40 N NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
41 O OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
42 EOF
44 git add A M &&
45 git commit -m "initial has A and M" &&
46 git branch white &&
47 git branch red &&
48 git branch blue &&
49 git branch yellow &&
50 git branch change &&
51 git branch change+rename &&
53 sed -e "/^g /s/.*/g : master changes a line/" <A >A+ &&
54 mv A+ A &&
55 git commit -a -m "master updates A" &&
57 git checkout yellow &&
58 rm -f M &&
59 git commit -a -m "yellow removes M" &&
61 git checkout white &&
62 sed -e "/^g /s/.*/g : white changes a line/" <A >B &&
63 sed -e "/^G /s/.*/G : colored branch changes a line/" <M >N &&
64 rm -f A M &&
65 git update-index --add --remove A B M N &&
66 git commit -m "white renames A->B, M->N" &&
68 git checkout red &&
69 sed -e "/^g /s/.*/g : red changes a line/" <A >B &&
70 sed -e "/^G /s/.*/G : colored branch changes a line/" <M >N &&
71 rm -f A M &&
72 git update-index --add --remove A B M N &&
73 git commit -m "red renames A->B, M->N" &&
75 git checkout blue &&
76 sed -e "/^g /s/.*/g : blue changes a line/" <A >C &&
77 sed -e "/^G /s/.*/G : colored branch changes a line/" <M >N &&
78 rm -f A M &&
79 git update-index --add --remove A C M N &&
80 git commit -m "blue renames A->C, M->N" &&
82 git checkout change &&
83 sed -e "/^g /s/.*/g : changed line/" <A >A+ &&
84 mv A+ A &&
85 git commit -q -a -m "changed" &&
87 git checkout change+rename &&
88 sed -e "/^g /s/.*/g : changed line/" <A >B &&
89 rm A &&
90 git update-index --add B &&
91 git commit -q -a -m "changed and renamed" &&
93 git checkout master'
95 test_expect_success 'pull renaming branch into unrenaming one' \
97 git show-branch
98 test_must_fail git pull . white &&
99 git ls-files -s &&
100 test "$(git ls-files -u B | wc -l)" -eq 3 &&
101 test "$(git ls-files -s N | wc -l)" -eq 1 &&
102 sed -ne "/^g/{
105 }" B | grep master &&
106 test "$(git diff white N | wc -l)" -eq 0
109 test_expect_success 'pull renaming branch into another renaming one' \
111 rm -f B
112 git reset --hard
113 git checkout red
114 test_must_fail git pull . white &&
115 test "$(git ls-files -u B | wc -l)" -eq 3 &&
116 test "$(git ls-files -s N | wc -l)" -eq 1 &&
117 sed -ne "/^g/{
120 }" B | grep red &&
121 test "$(git diff white N | wc -l)" -eq 0
124 test_expect_success 'pull unrenaming branch into renaming one' \
126 git reset --hard
127 git show-branch
128 test_must_fail git pull . master &&
129 test "$(git ls-files -u B | wc -l)" -eq 3 &&
130 test "$(git ls-files -s N | wc -l)" -eq 1 &&
131 sed -ne "/^g/{
134 }" B | grep red &&
135 test "$(git diff white N | wc -l)" -eq 0
138 test_expect_success 'pull conflicting renames' \
140 git reset --hard
141 git show-branch
142 test_must_fail git pull . blue &&
143 test "$(git ls-files -u A | wc -l)" -eq 1 &&
144 test "$(git ls-files -u B | wc -l)" -eq 1 &&
145 test "$(git ls-files -u C | wc -l)" -eq 1 &&
146 test "$(git ls-files -s N | wc -l)" -eq 1 &&
147 sed -ne "/^g/{
150 }" B | grep red &&
151 test "$(git diff white N | wc -l)" -eq 0
154 test_expect_success 'interference with untracked working tree file' '
156 git reset --hard
157 git show-branch
158 echo >A this file should not matter
159 test_must_fail git pull . white &&
160 test -f A
163 test_expect_success 'interference with untracked working tree file' '
165 git reset --hard
166 git checkout white
167 git show-branch
168 rm -f A
169 echo >A this file should not matter
170 test_must_fail git pull . red &&
171 test -f A
174 test_expect_success 'interference with untracked working tree file' '
176 git reset --hard
177 rm -f A M
178 git checkout -f master
179 git tag -f anchor
180 git show-branch
181 git pull . yellow
182 test ! -f M &&
183 git reset --hard anchor
186 test_expect_success 'updated working tree file should prevent the merge' '
188 git reset --hard
189 rm -f A M
190 git checkout -f master
191 git tag -f anchor
192 git show-branch
193 echo >>M one line addition
194 cat M >M.saved
195 test_must_fail git pull . yellow &&
196 diff M M.saved &&
197 rm -f M.saved
200 test_expect_success 'updated working tree file should prevent the merge' '
202 git reset --hard
203 rm -f A M
204 git checkout -f master
205 git tag -f anchor
206 git show-branch
207 echo >>M one line addition
208 cat M >M.saved
209 git update-index M
210 test_must_fail git pull . yellow &&
211 diff M M.saved &&
212 rm -f M.saved
215 test_expect_success 'interference with untracked working tree file' '
217 git reset --hard
218 rm -f A M
219 git checkout -f yellow
220 git tag -f anchor
221 git show-branch
222 echo >M this file should not matter
223 git pull . master &&
224 test -f M &&
225 ! (git ls-files -s | grep M) &&
226 git reset --hard anchor
229 test_expect_success 'merge of identical changes in a renamed file' '
230 rm -f A M N
231 git reset --hard &&
232 git checkout change+rename &&
233 GIT_MERGE_VERBOSITY=3 git merge change | grep "^Skipped B" &&
234 git reset --hard HEAD^ &&
235 git checkout change &&
236 GIT_MERGE_VERBOSITY=3 git merge change+rename | grep "^Skipped B"
239 test_done