3 test_description
='git rebase + directory rename tests'
5 TEST_PASSES_SANITIZE_LEAK
=true
7 .
"$TEST_DIRECTORY"/lib-rebase.sh
9 test_expect_success
'setup testcase where directory rename should be detected' '
10 test_create_repo dir-rename &&
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 &&
20 git commit -m "Initial" &&
29 git commit -m "Rename x to y, l to letters" &&
33 test_seq 31 40 >x/d &&
35 git commit -m "Modify l, add x/d"
39 test_expect_success
'rebase --interactive: directory rename detected' '
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' '
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' '
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' '
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 &&
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" &&
124 echo v2 >project_info &&
125 git add project_info &&
126 git commit -m "Modify project_info" &&
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" &&
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" &&
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" &&
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" &&
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