git-push: avoid falling back on pushing "matching" refs.
[tgit.git] / t / t6022-merge-rename.sh
blob1292cafd7f1f7fc30b462d4e07be34383e9d6be9
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 &&
46 git branch white &&
47 git branch red &&
48 git branch blue &&
50 sed -e "/^g /s/.*/g : master changes a line/" <A >A+ &&
51 mv A+ A &&
52 git commit -a -m "master updates A" &&
54 git checkout white &&
55 sed -e "/^g /s/.*/g : white changes a line/" <A >B &&
56 sed -e "/^G /s/.*/G : colored branch changes a line/" <M >N &&
57 rm -f A M &&
58 git update-index --add --remove A B M N &&
59 git commit -m "white renames A->B, M->N" &&
61 git checkout red &&
62 sed -e "/^g /s/.*/g : red 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 "red renames A->B, M->N" &&
68 git checkout blue &&
69 sed -e "/^g /s/.*/g : blue changes a line/" <A >C &&
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 C M N &&
73 git commit -m "blue renames A->C, M->N" &&
75 git checkout master'
77 test_expect_success 'pull renaming branch into unrenaming one' \
79 git show-branch
80 git pull . white && {
81 echo "BAD: should have conflicted"
82 exit 1
84 git ls-files -s
85 test "$(git ls-files -u B | wc -l)" -eq 3 || {
86 echo "BAD: should have left stages for B"
87 exit 1
89 test "$(git ls-files -s N | wc -l)" -eq 1 || {
90 echo "BAD: should have merged N"
91 exit 1
93 sed -ne "/^g/{
96 }" B | grep master || {
97 echo "BAD: should have listed our change first"
98 exit 1
100 test "$(git diff white N | wc -l)" -eq 0 || {
101 echo "BAD: should have taken colored branch"
102 exit 1
106 test_expect_success 'pull renaming branch into another renaming one' \
108 git reset --hard
109 git checkout red
110 git pull . white && {
111 echo "BAD: should have conflicted"
112 exit 1
114 test "$(git ls-files -u B | wc -l)" -eq 3 || {
115 echo "BAD: should have left stages"
116 exit 1
118 test "$(git ls-files -s N | wc -l)" -eq 1 || {
119 echo "BAD: should have merged N"
120 exit 1
122 sed -ne "/^g/{
125 }" B | grep red || {
126 echo "BAD: should have listed our change first"
127 exit 1
129 test "$(git diff white N | wc -l)" -eq 0 || {
130 echo "BAD: should have taken colored branch"
131 exit 1
135 test_expect_success 'pull unrenaming branch into renaming one' \
137 git reset --hard
138 git show-branch
139 git pull . master && {
140 echo "BAD: should have conflicted"
141 exit 1
143 test "$(git ls-files -u B | wc -l)" -eq 3 || {
144 echo "BAD: should have left stages"
145 exit 1
147 test "$(git ls-files -s N | wc -l)" -eq 1 || {
148 echo "BAD: should have merged N"
149 exit 1
151 sed -ne "/^g/{
154 }" B | grep red || {
155 echo "BAD: should have listed our change first"
156 exit 1
158 test "$(git diff white N | wc -l)" -eq 0 || {
159 echo "BAD: should have taken colored branch"
160 exit 1
164 test_expect_success 'pull conflicting renames' \
166 git reset --hard
167 git show-branch
168 git pull . blue && {
169 echo "BAD: should have conflicted"
170 exit 1
172 test "$(git ls-files -u A | wc -l)" -eq 1 || {
173 echo "BAD: should have left a stage"
174 exit 1
176 test "$(git ls-files -u B | wc -l)" -eq 1 || {
177 echo "BAD: should have left a stage"
178 exit 1
180 test "$(git ls-files -u C | wc -l)" -eq 1 || {
181 echo "BAD: should have left a stage"
182 exit 1
184 test "$(git ls-files -s N | wc -l)" -eq 1 || {
185 echo "BAD: should have merged N"
186 exit 1
188 sed -ne "/^g/{
191 }" B | grep red || {
192 echo "BAD: should have listed our change first"
193 exit 1
195 test "$(git diff white N | wc -l)" -eq 0 || {
196 echo "BAD: should have taken colored branch"
197 exit 1
201 test_done