Merge branch 'jc/fsck'
[git/gitweb-caching.git] / t / t6022-merge-rename.sh
bloba2d24b5ca95d971eccbb913c2a0eb84b7e87cd10
1 #!/bin/sh
3 test_description='Merge-recursive merging renames'
4 . ./test-lib.sh
6 if test "$no_python"; then
7 echo "Skipping: no python => no recursive merge"
8 test_done
9 exit 0
12 test_expect_success setup \
14 cat >A <<\EOF &&
15 a aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
16 b bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
17 c cccccccccccccccccccccccccccccccccccccccccccccccc
18 d dddddddddddddddddddddddddddddddddddddddddddddddd
19 e eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
20 f ffffffffffffffffffffffffffffffffffffffffffffffff
21 g gggggggggggggggggggggggggggggggggggggggggggggggg
22 h hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
23 i iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
24 j jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
25 k kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
26 l llllllllllllllllllllllllllllllllllllllllllllllll
27 m mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
28 n nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
29 o oooooooooooooooooooooooooooooooooooooooooooooooo
30 EOF
32 cat >M <<\EOF &&
33 A AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
34 B BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
35 C CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
36 D DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
37 E EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
38 F FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
39 G GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG
40 H HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
41 I IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
42 J JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ
43 K KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK
44 L LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL
45 M MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
46 N NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
47 O OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
48 EOF
50 git add A M &&
51 git commit -m initial &&
52 git branch white &&
53 git branch red &&
54 git branch blue &&
56 sed -e "/^g /s/.*/g : master changes a line/" <A >A+ &&
57 mv A+ A &&
58 git commit -a -m "master updates A" &&
60 git checkout white &&
61 sed -e "/^g /s/.*/g : white changes a line/" <A >B &&
62 sed -e "/^G /s/.*/G : colored branch changes a line/" <M >N &&
63 rm -f A M &&
64 git update-index --add --remove A B M N &&
65 git commit -m "white renames A->B, M->N" &&
67 git checkout red &&
68 sed -e "/^g /s/.*/g : red changes a line/" <A >B &&
69 sed -e "/^G /s/.*/G : colored branch changes a line/" <M >N &&
70 rm -f A M &&
71 git update-index --add --remove A B M N &&
72 git commit -m "red renames A->B, M->N" &&
74 git checkout blue &&
75 sed -e "/^g /s/.*/g : blue changes a line/" <A >C &&
76 sed -e "/^G /s/.*/G : colored branch changes a line/" <M >N &&
77 rm -f A M &&
78 git update-index --add --remove A C M N &&
79 git commit -m "blue renames A->C, M->N" &&
81 git checkout master'
83 test_expect_success 'pull renaming branch into unrenaming one' \
85 git show-branch
86 git pull . white && {
87 echo "BAD: should have conflicted"
88 exit 1
90 git ls-files -s
91 test "$(git ls-files -u B | wc -l)" -eq 3 || {
92 echo "BAD: should have left stages for B"
93 exit 1
95 test "$(git ls-files -s N | wc -l)" -eq 1 || {
96 echo "BAD: should have merged N"
97 exit 1
99 sed -ne "/^g/{
102 }" B | grep master || {
103 echo "BAD: should have listed our change first"
104 exit 1
106 test "$(git diff white N | wc -l)" -eq 0 || {
107 echo "BAD: should have taken colored branch"
108 exit 1
112 test_expect_success 'pull renaming branch into another renaming one' \
114 git reset --hard
115 git checkout red
116 git pull . white && {
117 echo "BAD: should have conflicted"
118 exit 1
120 test "$(git ls-files -u B | wc -l)" -eq 3 || {
121 echo "BAD: should have left stages"
122 exit 1
124 test "$(git ls-files -s N | wc -l)" -eq 1 || {
125 echo "BAD: should have merged N"
126 exit 1
128 sed -ne "/^g/{
131 }" B | grep red || {
132 echo "BAD: should have listed our change first"
133 exit 1
135 test "$(git diff white N | wc -l)" -eq 0 || {
136 echo "BAD: should have taken colored branch"
137 exit 1
141 test_expect_success 'pull unrenaming branch into renaming one' \
143 git reset --hard
144 git show-branch
145 git pull . master && {
146 echo "BAD: should have conflicted"
147 exit 1
149 test "$(git ls-files -u B | wc -l)" -eq 3 || {
150 echo "BAD: should have left stages"
151 exit 1
153 test "$(git ls-files -s N | wc -l)" -eq 1 || {
154 echo "BAD: should have merged N"
155 exit 1
157 sed -ne "/^g/{
160 }" B | grep red || {
161 echo "BAD: should have listed our change first"
162 exit 1
164 test "$(git diff white N | wc -l)" -eq 0 || {
165 echo "BAD: should have taken colored branch"
166 exit 1
170 test_expect_success 'pull conflicting renames' \
172 git reset --hard
173 git show-branch
174 git pull . blue && {
175 echo "BAD: should have conflicted"
176 exit 1
178 test "$(git ls-files -u A | wc -l)" -eq 1 || {
179 echo "BAD: should have left a stage"
180 exit 1
182 test "$(git ls-files -u B | wc -l)" -eq 1 || {
183 echo "BAD: should have left a stage"
184 exit 1
186 test "$(git ls-files -u C | wc -l)" -eq 1 || {
187 echo "BAD: should have left a stage"
188 exit 1
190 test "$(git ls-files -s N | wc -l)" -eq 1 || {
191 echo "BAD: should have merged N"
192 exit 1
194 sed -ne "/^g/{
197 }" B | grep red || {
198 echo "BAD: should have listed our change first"
199 exit 1
201 test "$(git diff white N | wc -l)" -eq 0 || {
202 echo "BAD: should have taken colored branch"
203 exit 1
207 test_done