fast-import: use mem_pool_calloc()
[git.git] / t / t3401-rebase-and-am-rename.sh
blobf18bae94507587a4dc9118cc3d508902e02c6bc1
1 #!/bin/sh
3 test_description='git rebase + directory rename tests'
5 . ./test-lib.sh
6 . "$TEST_DIRECTORY"/lib-rebase.sh
8 test_expect_success 'setup testcase where directory rename should be detected' '
9 test_create_repo dir-rename &&
11 cd dir-rename &&
13 mkdir x &&
14 test_seq 1 10 >x/a &&
15 test_seq 11 20 >x/b &&
16 test_seq 21 30 >x/c &&
17 test_write_lines a b c d e f g h i >l &&
18 git add x l &&
19 git commit -m "Initial" &&
21 git branch O &&
22 git branch A &&
23 git branch B &&
25 git checkout A &&
26 git mv x y &&
27 git mv l letters &&
28 git commit -m "Rename x to y, l to letters" &&
30 git checkout B &&
31 echo j >>l &&
32 test_seq 31 40 >x/d &&
33 git add l x/d &&
34 git commit -m "Modify l, add x/d"
38 test_expect_success 'rebase --interactive: directory rename detected' '
40 cd dir-rename &&
42 git checkout B^0 &&
44 set_fake_editor &&
45 FAKE_LINES="1" git -c merge.directoryRenames=true rebase --interactive A &&
47 git ls-files -s >out &&
48 test_line_count = 5 out &&
50 test_path_is_file y/d &&
51 test_path_is_missing x/d
55 test_expect_failure 'rebase --apply: directory rename detected' '
57 cd dir-rename &&
59 git checkout B^0 &&
61 git -c merge.directoryRenames=true rebase --apply A &&
63 git ls-files -s >out &&
64 test_line_count = 5 out &&
66 test_path_is_file y/d &&
67 test_path_is_missing x/d
71 test_expect_success 'rebase --merge: directory rename detected' '
73 cd dir-rename &&
75 git checkout B^0 &&
77 git -c merge.directoryRenames=true rebase --merge A &&
79 git ls-files -s >out &&
80 test_line_count = 5 out &&
82 test_path_is_file y/d &&
83 test_path_is_missing x/d
87 test_expect_failure 'am: directory rename detected' '
89 cd dir-rename &&
91 git checkout A^0 &&
93 git format-patch -1 B &&
95 git -c merge.directoryRenames=true am --3way 0001*.patch &&
97 git ls-files -s >out &&
98 test_line_count = 5 out &&
100 test_path_is_file y/d &&
101 test_path_is_missing x/d
105 test_expect_success 'setup testcase where directory rename should NOT be detected' '
106 test_create_repo no-dir-rename &&
108 cd no-dir-rename &&
110 mkdir x &&
111 test_seq 1 10 >x/a &&
112 test_seq 11 20 >x/b &&
113 test_seq 21 30 >x/c &&
114 echo original >project_info &&
115 git add x project_info &&
116 git commit -m "Initial" &&
118 git branch O &&
119 git branch A &&
120 git branch B &&
122 git checkout A &&
123 echo v2 >project_info &&
124 git add project_info &&
125 git commit -m "Modify project_info" &&
127 git checkout B &&
128 mkdir y &&
129 git mv x/c y/c &&
130 echo v1 >project_info &&
131 git add project_info &&
132 git commit -m "Rename x/c to y/c, modify project_info"
136 test_expect_success 'rebase --interactive: NO directory rename' '
137 test_when_finished "git -C no-dir-rename rebase --abort" &&
139 cd no-dir-rename &&
141 git checkout B^0 &&
143 set_fake_editor &&
144 test_must_fail env FAKE_LINES="1" git rebase --interactive A &&
146 git ls-files -s >out &&
147 test_line_count = 6 out &&
149 test_path_is_file x/a &&
150 test_path_is_file x/b &&
151 test_path_is_missing x/c
155 test_expect_success 'rebase (am): NO directory rename' '
156 test_when_finished "git -C no-dir-rename rebase --abort" &&
158 cd no-dir-rename &&
160 git checkout B^0 &&
162 set_fake_editor &&
163 test_must_fail git rebase A &&
165 git ls-files -s >out &&
166 test_line_count = 6 out &&
168 test_path_is_file x/a &&
169 test_path_is_file x/b &&
170 test_path_is_missing x/c
174 test_expect_success 'rebase --merge: NO directory rename' '
175 test_when_finished "git -C no-dir-rename rebase --abort" &&
177 cd no-dir-rename &&
179 git checkout B^0 &&
181 set_fake_editor &&
182 test_must_fail git rebase --merge A &&
184 git ls-files -s >out &&
185 test_line_count = 6 out &&
187 test_path_is_file x/a &&
188 test_path_is_file x/b &&
189 test_path_is_missing x/c
193 test_expect_success 'am: NO directory rename' '
194 test_when_finished "git -C no-dir-rename am --abort" &&
196 cd no-dir-rename &&
198 git checkout A^0 &&
200 git format-patch -1 B &&
202 test_must_fail git am --3way 0001*.patch &&
204 git ls-files -s >out &&
205 test_line_count = 6 out &&
207 test_path_is_file x/a &&
208 test_path_is_file x/b &&
209 test_path_is_missing x/c
213 test_done