git-prompt: use here-doc instead of here-string
[git/gitster.git] / t / t3401-rebase-and-am-rename.sh
blob328c1d3a3f45bcf2a2c153c94556d0b56fb5bbce
1 #!/bin/sh
3 test_description='git rebase + directory rename tests'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
7 . "$TEST_DIRECTORY"/lib-rebase.sh
9 test_expect_success 'setup testcase where directory rename should be detected' '
10 test_create_repo dir-rename &&
12 cd dir-rename &&
14 mkdir x &&
15 test_seq 1 10 >x/a &&
16 test_seq 11 20 >x/b &&
17 test_seq 21 30 >x/c &&
18 test_write_lines a b c d e f g h i >l &&
19 git add x l &&
20 git commit -m "Initial" &&
22 git branch O &&
23 git branch A &&
24 git branch B &&
26 git checkout A &&
27 git mv x y &&
28 git mv l letters &&
29 git commit -m "Rename x to y, l to letters" &&
31 git checkout B &&
32 echo j >>l &&
33 test_seq 31 40 >x/d &&
34 git add l x/d &&
35 git commit -m "Modify l, add x/d"
39 test_expect_success 'rebase --interactive: directory rename detected' '
41 cd dir-rename &&
43 git checkout B^0 &&
45 set_fake_editor &&
46 FAKE_LINES="1" git -c merge.directoryRenames=true rebase --interactive A &&
48 git ls-files -s >out &&
49 test_line_count = 5 out &&
51 test_path_is_file y/d &&
52 test_path_is_missing x/d
56 test_expect_failure 'rebase --apply: directory rename detected' '
58 cd dir-rename &&
60 git checkout B^0 &&
62 git -c merge.directoryRenames=true rebase --apply A &&
64 git ls-files -s >out &&
65 test_line_count = 5 out &&
67 test_path_is_file y/d &&
68 test_path_is_missing x/d
72 test_expect_success 'rebase --merge: directory rename detected' '
74 cd dir-rename &&
76 git checkout B^0 &&
78 git -c merge.directoryRenames=true rebase --merge A &&
80 git ls-files -s >out &&
81 test_line_count = 5 out &&
83 test_path_is_file y/d &&
84 test_path_is_missing x/d
88 test_expect_failure 'am: directory rename detected' '
90 cd dir-rename &&
92 git checkout A^0 &&
94 git format-patch -1 B &&
96 git -c merge.directoryRenames=true am --3way 0001*.patch &&
98 git ls-files -s >out &&
99 test_line_count = 5 out &&
101 test_path_is_file y/d &&
102 test_path_is_missing x/d
106 test_expect_success 'setup testcase where directory rename should NOT be detected' '
107 test_create_repo no-dir-rename &&
109 cd no-dir-rename &&
111 mkdir x &&
112 test_seq 1 10 >x/a &&
113 test_seq 11 20 >x/b &&
114 test_seq 21 30 >x/c &&
115 echo original >project_info &&
116 git add x project_info &&
117 git commit -m "Initial" &&
119 git branch O &&
120 git branch A &&
121 git branch B &&
123 git checkout A &&
124 echo v2 >project_info &&
125 git add project_info &&
126 git commit -m "Modify project_info" &&
128 git checkout B &&
129 mkdir y &&
130 git mv x/c y/c &&
131 echo v1 >project_info &&
132 git add project_info &&
133 git commit -m "Rename x/c to y/c, modify project_info"
137 test_expect_success 'rebase --interactive: NO directory rename' '
138 test_when_finished "git -C no-dir-rename rebase --abort" &&
140 cd no-dir-rename &&
142 git checkout B^0 &&
144 set_fake_editor &&
145 test_must_fail env FAKE_LINES="1" git rebase --interactive A &&
147 git ls-files -s >out &&
148 test_line_count = 6 out &&
150 test_path_is_file x/a &&
151 test_path_is_file x/b &&
152 test_path_is_missing x/c
156 test_expect_success 'rebase (am): NO directory rename' '
157 test_when_finished "git -C no-dir-rename rebase --abort" &&
159 cd no-dir-rename &&
161 git checkout B^0 &&
163 set_fake_editor &&
164 test_must_fail git rebase A &&
166 git ls-files -s >out &&
167 test_line_count = 6 out &&
169 test_path_is_file x/a &&
170 test_path_is_file x/b &&
171 test_path_is_missing x/c
175 test_expect_success 'rebase --merge: NO directory rename' '
176 test_when_finished "git -C no-dir-rename rebase --abort" &&
178 cd no-dir-rename &&
180 git checkout B^0 &&
182 set_fake_editor &&
183 test_must_fail git rebase --merge A &&
185 git ls-files -s >out &&
186 test_line_count = 6 out &&
188 test_path_is_file x/a &&
189 test_path_is_file x/b &&
190 test_path_is_missing x/c
194 test_expect_success 'am: NO directory rename' '
195 test_when_finished "git -C no-dir-rename am --abort" &&
197 cd no-dir-rename &&
199 git checkout A^0 &&
201 git format-patch -1 B &&
203 test_must_fail git am --3way 0001*.patch &&
205 git ls-files -s >out &&
206 test_line_count = 6 out &&
208 test_path_is_file x/a &&
209 test_path_is_file x/b &&
210 test_path_is_missing x/c
214 test_done