]>
Commit | Line | Data |
---|---|---|
70819263 LK |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2012 Valentin Duperray, Lucien Kong, Franck Jonas, | |
4 | # Thomas Nguy, Khoi Nguyen | |
5 | # Grenoble INP Ensimag | |
6 | # | |
7 | ||
4f021b34 | 8 | test_description='git status advice' |
70819263 LK |
9 | |
10 | . ./test-lib.sh | |
11 | ||
12 | . "$TEST_DIRECTORY"/lib-rebase.sh | |
13 | ||
14 | set_fake_editor | |
15 | ||
16 | test_expect_success 'prepare for conflicts' ' | |
6a38ef2c | 17 | git config --global advice.statusuoption false && |
70819263 LK |
18 | test_commit init main.txt init && |
19 | git branch conflicts && | |
20 | test_commit on_master main.txt on_master && | |
21 | git checkout conflicts && | |
22 | test_commit on_conflicts main.txt on_conflicts | |
23 | ' | |
24 | ||
25 | ||
26 | test_expect_success 'status when conflicts unresolved' ' | |
27 | test_must_fail git merge master && | |
1c7969c9 MM |
28 | cat >expected <<\EOF && |
29 | On branch conflicts | |
30 | You have unmerged paths. | |
31 | (fix conflicts and run "git commit") | |
32 | ||
33 | Unmerged paths: | |
34 | (use "git add <file>..." to mark resolution) | |
35 | ||
c7cb333f | 36 | both modified: main.txt |
1c7969c9 MM |
37 | |
38 | no changes added to commit (use "git add" and/or "git commit -a") | |
39 | EOF | |
70819263 LK |
40 | git status --untracked-files=no >actual && |
41 | test_i18ncmp expected actual | |
42 | ' | |
43 | ||
44 | ||
45 | test_expect_success 'status when conflicts resolved before commit' ' | |
46 | git reset --hard conflicts && | |
47 | test_must_fail git merge master && | |
48 | echo one >main.txt && | |
49 | git add main.txt && | |
1c7969c9 MM |
50 | cat >expected <<\EOF && |
51 | On branch conflicts | |
52 | All conflicts fixed but you are still merging. | |
53 | (use "git commit" to conclude merge) | |
54 | ||
55 | Changes to be committed: | |
56 | ||
57 | modified: main.txt | |
58 | ||
59 | Untracked files not listed (use -u option to show untracked files) | |
60 | EOF | |
70819263 LK |
61 | git status --untracked-files=no >actual && |
62 | test_i18ncmp expected actual | |
63 | ' | |
64 | ||
65 | ||
66 | test_expect_success 'prepare for rebase conflicts' ' | |
67 | git reset --hard master && | |
68 | git checkout -b rebase_conflicts && | |
69 | test_commit one_rebase main.txt one && | |
70 | test_commit two_rebase main.txt two && | |
71 | test_commit three_rebase main.txt three | |
72 | ' | |
73 | ||
74 | ||
75 | test_expect_success 'status when rebase in progress before resolving conflicts' ' | |
76 | test_when_finished "git rebase --abort" && | |
0722c805 | 77 | ONTO=$(git rev-parse --short HEAD^^) && |
70819263 | 78 | test_must_fail git rebase HEAD^ --onto HEAD^^ && |
1c7969c9 MM |
79 | cat >expected <<EOF && |
80 | rebase in progress; onto $ONTO | |
81 | You are currently rebasing branch '\''rebase_conflicts'\'' on '\''$ONTO'\''. | |
82 | (fix conflicts and then run "git rebase --continue") | |
83 | (use "git rebase --skip" to skip this patch) | |
84 | (use "git rebase --abort" to check out the original branch) | |
85 | ||
86 | Unmerged paths: | |
87 | (use "git reset HEAD <file>..." to unstage) | |
88 | (use "git add <file>..." to mark resolution) | |
89 | ||
c7cb333f | 90 | both modified: main.txt |
1c7969c9 MM |
91 | |
92 | no changes added to commit (use "git add" and/or "git commit -a") | |
93 | EOF | |
70819263 LK |
94 | git status --untracked-files=no >actual && |
95 | test_i18ncmp expected actual | |
96 | ' | |
97 | ||
98 | ||
99 | test_expect_success 'status when rebase in progress before rebase --continue' ' | |
100 | git reset --hard rebase_conflicts && | |
101 | test_when_finished "git rebase --abort" && | |
0722c805 | 102 | ONTO=$(git rev-parse --short HEAD^^) && |
70819263 LK |
103 | test_must_fail git rebase HEAD^ --onto HEAD^^ && |
104 | echo three >main.txt && | |
105 | git add main.txt && | |
1c7969c9 MM |
106 | cat >expected <<EOF && |
107 | rebase in progress; onto $ONTO | |
108 | You are currently rebasing branch '\''rebase_conflicts'\'' on '\''$ONTO'\''. | |
109 | (all conflicts fixed: run "git rebase --continue") | |
110 | ||
111 | Changes to be committed: | |
112 | (use "git reset HEAD <file>..." to unstage) | |
113 | ||
114 | modified: main.txt | |
115 | ||
116 | Untracked files not listed (use -u option to show untracked files) | |
117 | EOF | |
70819263 LK |
118 | git status --untracked-files=no >actual && |
119 | test_i18ncmp expected actual | |
120 | ' | |
121 | ||
122 | ||
123 | test_expect_success 'prepare for rebase_i_conflicts' ' | |
124 | git reset --hard master && | |
125 | git checkout -b rebase_i_conflicts && | |
126 | test_commit one_unmerge main.txt one_unmerge && | |
127 | git branch rebase_i_conflicts_second && | |
128 | test_commit one_master main.txt one_master && | |
129 | git checkout rebase_i_conflicts_second && | |
130 | test_commit one_second main.txt one_second | |
131 | ' | |
132 | ||
133 | ||
134 | test_expect_success 'status during rebase -i when conflicts unresolved' ' | |
135 | test_when_finished "git rebase --abort" && | |
0722c805 | 136 | ONTO=$(git rev-parse --short rebase_i_conflicts) && |
84e6fb9d | 137 | LAST_COMMIT=$(git rev-parse --short rebase_i_conflicts_second) && |
70819263 | 138 | test_must_fail git rebase -i rebase_i_conflicts && |
1c7969c9 | 139 | cat >expected <<EOF && |
df25e947 | 140 | interactive rebase in progress; onto $ONTO |
84e6fb9d GP |
141 | Last command done (1 command done): |
142 | pick $LAST_COMMIT one_second | |
143 | No commands remaining. | |
1c7969c9 MM |
144 | You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''$ONTO'\''. |
145 | (fix conflicts and then run "git rebase --continue") | |
146 | (use "git rebase --skip" to skip this patch) | |
147 | (use "git rebase --abort" to check out the original branch) | |
148 | ||
149 | Unmerged paths: | |
150 | (use "git reset HEAD <file>..." to unstage) | |
151 | (use "git add <file>..." to mark resolution) | |
152 | ||
c7cb333f | 153 | both modified: main.txt |
1c7969c9 MM |
154 | |
155 | no changes added to commit (use "git add" and/or "git commit -a") | |
156 | EOF | |
70819263 LK |
157 | git status --untracked-files=no >actual && |
158 | test_i18ncmp expected actual | |
159 | ' | |
160 | ||
161 | ||
162 | test_expect_success 'status during rebase -i after resolving conflicts' ' | |
163 | git reset --hard rebase_i_conflicts_second && | |
164 | test_when_finished "git rebase --abort" && | |
0722c805 | 165 | ONTO=$(git rev-parse --short rebase_i_conflicts) && |
84e6fb9d | 166 | LAST_COMMIT=$(git rev-parse --short rebase_i_conflicts_second) && |
70819263 LK |
167 | test_must_fail git rebase -i rebase_i_conflicts && |
168 | git add main.txt && | |
1c7969c9 | 169 | cat >expected <<EOF && |
df25e947 | 170 | interactive rebase in progress; onto $ONTO |
84e6fb9d GP |
171 | Last command done (1 command done): |
172 | pick $LAST_COMMIT one_second | |
173 | No commands remaining. | |
1c7969c9 MM |
174 | You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''$ONTO'\''. |
175 | (all conflicts fixed: run "git rebase --continue") | |
176 | ||
177 | Changes to be committed: | |
178 | (use "git reset HEAD <file>..." to unstage) | |
179 | ||
180 | modified: main.txt | |
181 | ||
182 | Untracked files not listed (use -u option to show untracked files) | |
183 | EOF | |
70819263 LK |
184 | git status --untracked-files=no >actual && |
185 | test_i18ncmp expected actual | |
186 | ' | |
187 | ||
188 | ||
189 | test_expect_success 'status when rebasing -i in edit mode' ' | |
190 | git reset --hard master && | |
191 | git checkout -b rebase_i_edit && | |
192 | test_commit one_rebase_i main.txt one && | |
193 | test_commit two_rebase_i main.txt two && | |
84e6fb9d | 194 | COMMIT2=$(git rev-parse --short rebase_i_edit) && |
70819263 | 195 | test_commit three_rebase_i main.txt three && |
84e6fb9d | 196 | COMMIT3=$(git rev-parse --short rebase_i_edit) && |
70819263 LK |
197 | FAKE_LINES="1 edit 2" && |
198 | export FAKE_LINES && | |
199 | test_when_finished "git rebase --abort" && | |
0722c805 | 200 | ONTO=$(git rev-parse --short HEAD~2) && |
70819263 | 201 | git rebase -i HEAD~2 && |
1c7969c9 | 202 | cat >expected <<EOF && |
df25e947 | 203 | interactive rebase in progress; onto $ONTO |
84e6fb9d GP |
204 | Last commands done (2 commands done): |
205 | pick $COMMIT2 two_rebase_i | |
206 | edit $COMMIT3 three_rebase_i | |
207 | No commands remaining. | |
1c7969c9 MM |
208 | You are currently editing a commit while rebasing branch '\''rebase_i_edit'\'' on '\''$ONTO'\''. |
209 | (use "git commit --amend" to amend the current commit) | |
210 | (use "git rebase --continue" once you are satisfied with your changes) | |
211 | ||
212 | nothing to commit (use -u to show untracked files) | |
213 | EOF | |
70819263 LK |
214 | git status --untracked-files=no >actual && |
215 | test_i18ncmp expected actual | |
216 | ' | |
217 | ||
218 | ||
2d1cceba LK |
219 | test_expect_success 'status when splitting a commit' ' |
220 | git reset --hard master && | |
221 | git checkout -b split_commit && | |
222 | test_commit one_split main.txt one && | |
223 | test_commit two_split main.txt two && | |
84e6fb9d | 224 | COMMIT2=$(git rev-parse --short split_commit) && |
2d1cceba | 225 | test_commit three_split main.txt three && |
84e6fb9d | 226 | COMMIT3=$(git rev-parse --short split_commit) && |
2d1cceba | 227 | test_commit four_split main.txt four && |
84e6fb9d | 228 | COMMIT4=$(git rev-parse --short split_commit) && |
2d1cceba LK |
229 | FAKE_LINES="1 edit 2 3" && |
230 | export FAKE_LINES && | |
231 | test_when_finished "git rebase --abort" && | |
0722c805 | 232 | ONTO=$(git rev-parse --short HEAD~3) && |
2d1cceba LK |
233 | git rebase -i HEAD~3 && |
234 | git reset HEAD^ && | |
1c7969c9 | 235 | cat >expected <<EOF && |
df25e947 | 236 | interactive rebase in progress; onto $ONTO |
84e6fb9d GP |
237 | Last commands done (2 commands done): |
238 | pick $COMMIT2 two_split | |
239 | edit $COMMIT3 three_split | |
240 | Next command to do (1 remaining command): | |
241 | pick $COMMIT4 four_split | |
242 | (use "git rebase --edit-todo" to view and edit) | |
1c7969c9 MM |
243 | You are currently splitting a commit while rebasing branch '\''split_commit'\'' on '\''$ONTO'\''. |
244 | (Once your working directory is clean, run "git rebase --continue") | |
245 | ||
246 | Changes not staged for commit: | |
247 | (use "git add <file>..." to update what will be committed) | |
248 | (use "git checkout -- <file>..." to discard changes in working directory) | |
249 | ||
250 | modified: main.txt | |
251 | ||
252 | no changes added to commit (use "git add" and/or "git commit -a") | |
253 | EOF | |
2d1cceba LK |
254 | git status --untracked-files=no >actual && |
255 | test_i18ncmp expected actual | |
256 | ' | |
257 | ||
258 | ||
259 | test_expect_success 'status after editing the last commit with --amend during a rebase -i' ' | |
260 | git reset --hard master && | |
261 | git checkout -b amend_last && | |
262 | test_commit one_amend main.txt one && | |
263 | test_commit two_amend main.txt two && | |
264 | test_commit three_amend main.txt three && | |
84e6fb9d | 265 | COMMIT3=$(git rev-parse --short amend_last) && |
2d1cceba | 266 | test_commit four_amend main.txt four && |
84e6fb9d | 267 | COMMIT4=$(git rev-parse --short amend_last) && |
2d1cceba LK |
268 | FAKE_LINES="1 2 edit 3" && |
269 | export FAKE_LINES && | |
270 | test_when_finished "git rebase --abort" && | |
0722c805 | 271 | ONTO=$(git rev-parse --short HEAD~3) && |
2d1cceba LK |
272 | git rebase -i HEAD~3 && |
273 | git commit --amend -m "foo" && | |
1c7969c9 | 274 | cat >expected <<EOF && |
df25e947 | 275 | interactive rebase in progress; onto $ONTO |
84e6fb9d GP |
276 | Last commands done (3 commands done): |
277 | pick $COMMIT3 three_amend | |
278 | edit $COMMIT4 four_amend | |
279 | (see more in file .git/rebase-merge/done) | |
280 | No commands remaining. | |
1c7969c9 MM |
281 | You are currently editing a commit while rebasing branch '\''amend_last'\'' on '\''$ONTO'\''. |
282 | (use "git commit --amend" to amend the current commit) | |
283 | (use "git rebase --continue" once you are satisfied with your changes) | |
284 | ||
285 | nothing to commit (use -u to show untracked files) | |
286 | EOF | |
2d1cceba LK |
287 | git status --untracked-files=no >actual && |
288 | test_i18ncmp expected actual | |
289 | ' | |
290 | ||
291 | ||
292 | test_expect_success 'prepare for several edits' ' | |
293 | git reset --hard master && | |
294 | git checkout -b several_edits && | |
295 | test_commit one_edits main.txt one && | |
296 | test_commit two_edits main.txt two && | |
297 | test_commit three_edits main.txt three && | |
298 | test_commit four_edits main.txt four | |
299 | ' | |
300 | ||
301 | ||
302 | test_expect_success 'status: (continue first edit) second edit' ' | |
303 | FAKE_LINES="edit 1 edit 2 3" && | |
304 | export FAKE_LINES && | |
305 | test_when_finished "git rebase --abort" && | |
84e6fb9d GP |
306 | COMMIT2=$(git rev-parse --short several_edits^^) && |
307 | COMMIT3=$(git rev-parse --short several_edits^) && | |
308 | COMMIT4=$(git rev-parse --short several_edits) && | |
0722c805 | 309 | ONTO=$(git rev-parse --short HEAD~3) && |
2d1cceba LK |
310 | git rebase -i HEAD~3 && |
311 | git rebase --continue && | |
1c7969c9 | 312 | cat >expected <<EOF && |
df25e947 | 313 | interactive rebase in progress; onto $ONTO |
84e6fb9d GP |
314 | Last commands done (2 commands done): |
315 | edit $COMMIT2 two_edits | |
316 | edit $COMMIT3 three_edits | |
317 | Next command to do (1 remaining command): | |
318 | pick $COMMIT4 four_edits | |
319 | (use "git rebase --edit-todo" to view and edit) | |
1c7969c9 MM |
320 | You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''. |
321 | (use "git commit --amend" to amend the current commit) | |
322 | (use "git rebase --continue" once you are satisfied with your changes) | |
323 | ||
324 | nothing to commit (use -u to show untracked files) | |
325 | EOF | |
2d1cceba LK |
326 | git status --untracked-files=no >actual && |
327 | test_i18ncmp expected actual | |
328 | ' | |
329 | ||
330 | ||
331 | test_expect_success 'status: (continue first edit) second edit and split' ' | |
332 | git reset --hard several_edits && | |
333 | FAKE_LINES="edit 1 edit 2 3" && | |
334 | export FAKE_LINES && | |
335 | test_when_finished "git rebase --abort" && | |
84e6fb9d GP |
336 | COMMIT2=$(git rev-parse --short several_edits^^) && |
337 | COMMIT3=$(git rev-parse --short several_edits^) && | |
338 | COMMIT4=$(git rev-parse --short several_edits) && | |
0722c805 | 339 | ONTO=$(git rev-parse --short HEAD~3) && |
2d1cceba LK |
340 | git rebase -i HEAD~3 && |
341 | git rebase --continue && | |
342 | git reset HEAD^ && | |
1c7969c9 | 343 | cat >expected <<EOF && |
df25e947 | 344 | interactive rebase in progress; onto $ONTO |
84e6fb9d GP |
345 | Last commands done (2 commands done): |
346 | edit $COMMIT2 two_edits | |
347 | edit $COMMIT3 three_edits | |
348 | Next command to do (1 remaining command): | |
349 | pick $COMMIT4 four_edits | |
350 | (use "git rebase --edit-todo" to view and edit) | |
1c7969c9 MM |
351 | You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''. |
352 | (Once your working directory is clean, run "git rebase --continue") | |
353 | ||
354 | Changes not staged for commit: | |
355 | (use "git add <file>..." to update what will be committed) | |
356 | (use "git checkout -- <file>..." to discard changes in working directory) | |
357 | ||
358 | modified: main.txt | |
359 | ||
360 | no changes added to commit (use "git add" and/or "git commit -a") | |
361 | EOF | |
2d1cceba LK |
362 | git status --untracked-files=no >actual && |
363 | test_i18ncmp expected actual | |
364 | ' | |
365 | ||
366 | ||
367 | test_expect_success 'status: (continue first edit) second edit and amend' ' | |
368 | git reset --hard several_edits && | |
369 | FAKE_LINES="edit 1 edit 2 3" && | |
370 | export FAKE_LINES && | |
371 | test_when_finished "git rebase --abort" && | |
84e6fb9d GP |
372 | COMMIT2=$(git rev-parse --short several_edits^^) && |
373 | COMMIT3=$(git rev-parse --short several_edits^) && | |
374 | COMMIT4=$(git rev-parse --short several_edits) && | |
0722c805 | 375 | ONTO=$(git rev-parse --short HEAD~3) && |
2d1cceba LK |
376 | git rebase -i HEAD~3 && |
377 | git rebase --continue && | |
378 | git commit --amend -m "foo" && | |
1c7969c9 | 379 | cat >expected <<EOF && |
df25e947 | 380 | interactive rebase in progress; onto $ONTO |
84e6fb9d GP |
381 | Last commands done (2 commands done): |
382 | edit $COMMIT2 two_edits | |
383 | edit $COMMIT3 three_edits | |
384 | Next command to do (1 remaining command): | |
385 | pick $COMMIT4 four_edits | |
386 | (use "git rebase --edit-todo" to view and edit) | |
1c7969c9 MM |
387 | You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''. |
388 | (use "git commit --amend" to amend the current commit) | |
389 | (use "git rebase --continue" once you are satisfied with your changes) | |
390 | ||
391 | nothing to commit (use -u to show untracked files) | |
392 | EOF | |
2d1cceba LK |
393 | git status --untracked-files=no >actual && |
394 | test_i18ncmp expected actual | |
395 | ' | |
396 | ||
397 | ||
398 | test_expect_success 'status: (amend first edit) second edit' ' | |
399 | git reset --hard several_edits && | |
400 | FAKE_LINES="edit 1 edit 2 3" && | |
401 | export FAKE_LINES && | |
402 | test_when_finished "git rebase --abort" && | |
84e6fb9d GP |
403 | COMMIT2=$(git rev-parse --short several_edits^^) && |
404 | COMMIT3=$(git rev-parse --short several_edits^) && | |
405 | COMMIT4=$(git rev-parse --short several_edits) && | |
0722c805 | 406 | ONTO=$(git rev-parse --short HEAD~3) && |
2d1cceba LK |
407 | git rebase -i HEAD~3 && |
408 | git commit --amend -m "a" && | |
409 | git rebase --continue && | |
1c7969c9 | 410 | cat >expected <<EOF && |
df25e947 | 411 | interactive rebase in progress; onto $ONTO |
84e6fb9d GP |
412 | Last commands done (2 commands done): |
413 | edit $COMMIT2 two_edits | |
414 | edit $COMMIT3 three_edits | |
415 | Next command to do (1 remaining command): | |
416 | pick $COMMIT4 four_edits | |
417 | (use "git rebase --edit-todo" to view and edit) | |
1c7969c9 MM |
418 | You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''. |
419 | (use "git commit --amend" to amend the current commit) | |
420 | (use "git rebase --continue" once you are satisfied with your changes) | |
421 | ||
422 | nothing to commit (use -u to show untracked files) | |
423 | EOF | |
2d1cceba LK |
424 | git status --untracked-files=no >actual && |
425 | test_i18ncmp expected actual | |
426 | ' | |
427 | ||
428 | ||
429 | test_expect_success 'status: (amend first edit) second edit and split' ' | |
430 | git reset --hard several_edits && | |
431 | FAKE_LINES="edit 1 edit 2 3" && | |
432 | export FAKE_LINES && | |
433 | test_when_finished "git rebase --abort" && | |
0722c805 | 434 | ONTO=$(git rev-parse --short HEAD~3) && |
84e6fb9d GP |
435 | COMMIT2=$(git rev-parse --short several_edits^^) && |
436 | COMMIT3=$(git rev-parse --short several_edits^) && | |
437 | COMMIT4=$(git rev-parse --short several_edits) && | |
2d1cceba LK |
438 | git rebase -i HEAD~3 && |
439 | git commit --amend -m "b" && | |
440 | git rebase --continue && | |
441 | git reset HEAD^ && | |
1c7969c9 | 442 | cat >expected <<EOF && |
df25e947 | 443 | interactive rebase in progress; onto $ONTO |
84e6fb9d GP |
444 | Last commands done (2 commands done): |
445 | edit $COMMIT2 two_edits | |
446 | edit $COMMIT3 three_edits | |
447 | Next command to do (1 remaining command): | |
448 | pick $COMMIT4 four_edits | |
449 | (use "git rebase --edit-todo" to view and edit) | |
1c7969c9 MM |
450 | You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''. |
451 | (Once your working directory is clean, run "git rebase --continue") | |
452 | ||
453 | Changes not staged for commit: | |
454 | (use "git add <file>..." to update what will be committed) | |
455 | (use "git checkout -- <file>..." to discard changes in working directory) | |
456 | ||
457 | modified: main.txt | |
458 | ||
459 | no changes added to commit (use "git add" and/or "git commit -a") | |
460 | EOF | |
2d1cceba LK |
461 | git status --untracked-files=no >actual && |
462 | test_i18ncmp expected actual | |
463 | ' | |
464 | ||
465 | ||
466 | test_expect_success 'status: (amend first edit) second edit and amend' ' | |
467 | git reset --hard several_edits && | |
468 | FAKE_LINES="edit 1 edit 2 3" && | |
469 | export FAKE_LINES && | |
470 | test_when_finished "git rebase --abort" && | |
84e6fb9d GP |
471 | COMMIT2=$(git rev-parse --short several_edits^^) && |
472 | COMMIT3=$(git rev-parse --short several_edits^) && | |
473 | COMMIT4=$(git rev-parse --short several_edits) && | |
0722c805 | 474 | ONTO=$(git rev-parse --short HEAD~3) && |
2d1cceba LK |
475 | git rebase -i HEAD~3 && |
476 | git commit --amend -m "c" && | |
477 | git rebase --continue && | |
478 | git commit --amend -m "d" && | |
1c7969c9 | 479 | cat >expected <<EOF && |
df25e947 | 480 | interactive rebase in progress; onto $ONTO |
84e6fb9d GP |
481 | Last commands done (2 commands done): |
482 | edit $COMMIT2 two_edits | |
483 | edit $COMMIT3 three_edits | |
484 | Next command to do (1 remaining command): | |
485 | pick $COMMIT4 four_edits | |
486 | (use "git rebase --edit-todo" to view and edit) | |
1c7969c9 MM |
487 | You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''. |
488 | (use "git commit --amend" to amend the current commit) | |
489 | (use "git rebase --continue" once you are satisfied with your changes) | |
490 | ||
491 | nothing to commit (use -u to show untracked files) | |
492 | EOF | |
2d1cceba LK |
493 | git status --untracked-files=no >actual && |
494 | test_i18ncmp expected actual | |
495 | ' | |
496 | ||
497 | ||
498 | test_expect_success 'status: (split first edit) second edit' ' | |
499 | git reset --hard several_edits && | |
500 | FAKE_LINES="edit 1 edit 2 3" && | |
501 | export FAKE_LINES && | |
502 | test_when_finished "git rebase --abort" && | |
84e6fb9d GP |
503 | COMMIT2=$(git rev-parse --short several_edits^^) && |
504 | COMMIT3=$(git rev-parse --short several_edits^) && | |
505 | COMMIT4=$(git rev-parse --short several_edits) && | |
0722c805 | 506 | ONTO=$(git rev-parse --short HEAD~3) && |
2d1cceba LK |
507 | git rebase -i HEAD~3 && |
508 | git reset HEAD^ && | |
509 | git add main.txt && | |
510 | git commit -m "e" && | |
511 | git rebase --continue && | |
1c7969c9 | 512 | cat >expected <<EOF && |
df25e947 | 513 | interactive rebase in progress; onto $ONTO |
84e6fb9d GP |
514 | Last commands done (2 commands done): |
515 | edit $COMMIT2 two_edits | |
516 | edit $COMMIT3 three_edits | |
517 | Next command to do (1 remaining command): | |
518 | pick $COMMIT4 four_edits | |
519 | (use "git rebase --edit-todo" to view and edit) | |
1c7969c9 MM |
520 | You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''. |
521 | (use "git commit --amend" to amend the current commit) | |
522 | (use "git rebase --continue" once you are satisfied with your changes) | |
523 | ||
524 | nothing to commit (use -u to show untracked files) | |
525 | EOF | |
2d1cceba LK |
526 | git status --untracked-files=no >actual && |
527 | test_i18ncmp expected actual | |
528 | ' | |
529 | ||
530 | ||
531 | test_expect_success 'status: (split first edit) second edit and split' ' | |
532 | git reset --hard several_edits && | |
533 | FAKE_LINES="edit 1 edit 2 3" && | |
534 | export FAKE_LINES && | |
535 | test_when_finished "git rebase --abort" && | |
84e6fb9d GP |
536 | COMMIT2=$(git rev-parse --short several_edits^^) && |
537 | COMMIT3=$(git rev-parse --short several_edits^) && | |
538 | COMMIT4=$(git rev-parse --short several_edits) && | |
0722c805 | 539 | ONTO=$(git rev-parse --short HEAD~3) && |
2d1cceba LK |
540 | git rebase -i HEAD~3 && |
541 | git reset HEAD^ && | |
542 | git add main.txt && | |
543 | git commit --amend -m "f" && | |
544 | git rebase --continue && | |
545 | git reset HEAD^ && | |
1c7969c9 | 546 | cat >expected <<EOF && |
df25e947 | 547 | interactive rebase in progress; onto $ONTO |
84e6fb9d GP |
548 | Last commands done (2 commands done): |
549 | edit $COMMIT2 two_edits | |
550 | edit $COMMIT3 three_edits | |
551 | Next command to do (1 remaining command): | |
552 | pick $COMMIT4 four_edits | |
553 | (use "git rebase --edit-todo" to view and edit) | |
1c7969c9 MM |
554 | You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''. |
555 | (Once your working directory is clean, run "git rebase --continue") | |
556 | ||
557 | Changes not staged for commit: | |
558 | (use "git add <file>..." to update what will be committed) | |
559 | (use "git checkout -- <file>..." to discard changes in working directory) | |
560 | ||
561 | modified: main.txt | |
562 | ||
563 | no changes added to commit (use "git add" and/or "git commit -a") | |
564 | EOF | |
2d1cceba LK |
565 | git status --untracked-files=no >actual && |
566 | test_i18ncmp expected actual | |
567 | ' | |
568 | ||
569 | ||
570 | test_expect_success 'status: (split first edit) second edit and amend' ' | |
571 | git reset --hard several_edits && | |
572 | FAKE_LINES="edit 1 edit 2 3" && | |
573 | export FAKE_LINES && | |
574 | test_when_finished "git rebase --abort" && | |
84e6fb9d GP |
575 | COMMIT2=$(git rev-parse --short several_edits^^) && |
576 | COMMIT3=$(git rev-parse --short several_edits^) && | |
577 | COMMIT4=$(git rev-parse --short several_edits) && | |
0722c805 | 578 | ONTO=$(git rev-parse --short HEAD~3) && |
2d1cceba LK |
579 | git rebase -i HEAD~3 && |
580 | git reset HEAD^ && | |
581 | git add main.txt && | |
582 | git commit --amend -m "g" && | |
583 | git rebase --continue && | |
584 | git commit --amend -m "h" && | |
1c7969c9 | 585 | cat >expected <<EOF && |
df25e947 | 586 | interactive rebase in progress; onto $ONTO |
84e6fb9d GP |
587 | Last commands done (2 commands done): |
588 | edit $COMMIT2 two_edits | |
589 | edit $COMMIT3 three_edits | |
590 | Next command to do (1 remaining command): | |
591 | pick $COMMIT4 four_edits | |
592 | (use "git rebase --edit-todo" to view and edit) | |
1c7969c9 MM |
593 | You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''. |
594 | (use "git commit --amend" to amend the current commit) | |
595 | (use "git rebase --continue" once you are satisfied with your changes) | |
596 | ||
597 | nothing to commit (use -u to show untracked files) | |
598 | EOF | |
2d1cceba LK |
599 | git status --untracked-files=no >actual && |
600 | test_i18ncmp expected actual | |
601 | ' | |
602 | ||
603 | ||
70819263 LK |
604 | test_expect_success 'prepare am_session' ' |
605 | git reset --hard master && | |
606 | git checkout -b am_session && | |
607 | test_commit one_am one.txt "one" && | |
608 | test_commit two_am two.txt "two" && | |
609 | test_commit three_am three.txt "three" | |
610 | ' | |
611 | ||
612 | ||
613 | test_expect_success 'status in an am session: file already exists' ' | |
614 | git checkout -b am_already_exists && | |
615 | test_when_finished "rm Maildir/* && git am --abort" && | |
616 | git format-patch -1 -oMaildir && | |
617 | test_must_fail git am Maildir/*.patch && | |
1c7969c9 MM |
618 | cat >expected <<\EOF && |
619 | On branch am_already_exists | |
620 | You are in the middle of an am session. | |
621 | (fix conflicts and then run "git am --continue") | |
622 | (use "git am --skip" to skip this patch) | |
623 | (use "git am --abort" to restore the original branch) | |
624 | ||
625 | nothing to commit (use -u to show untracked files) | |
626 | EOF | |
70819263 LK |
627 | git status --untracked-files=no >actual && |
628 | test_i18ncmp expected actual | |
629 | ' | |
630 | ||
631 | ||
632 | test_expect_success 'status in an am session: file does not exist' ' | |
633 | git reset --hard am_session && | |
634 | git checkout -b am_not_exists && | |
635 | git rm three.txt && | |
636 | git commit -m "delete three.txt" && | |
637 | test_when_finished "rm Maildir/* && git am --abort" && | |
638 | git format-patch -1 -oMaildir && | |
639 | test_must_fail git am Maildir/*.patch && | |
1c7969c9 MM |
640 | cat >expected <<\EOF && |
641 | On branch am_not_exists | |
642 | You are in the middle of an am session. | |
643 | (fix conflicts and then run "git am --continue") | |
644 | (use "git am --skip" to skip this patch) | |
645 | (use "git am --abort" to restore the original branch) | |
646 | ||
647 | nothing to commit (use -u to show untracked files) | |
648 | EOF | |
70819263 LK |
649 | git status --untracked-files=no >actual && |
650 | test_i18ncmp expected actual | |
651 | ' | |
652 | ||
653 | ||
654 | test_expect_success 'status in an am session: empty patch' ' | |
655 | git reset --hard am_session && | |
656 | git checkout -b am_empty && | |
657 | test_when_finished "rm Maildir/* && git am --abort" && | |
658 | git format-patch -3 -oMaildir && | |
659 | git rm one.txt two.txt three.txt && | |
660 | git commit -m "delete all am_empty" && | |
661 | echo error >Maildir/0002-two_am.patch && | |
662 | test_must_fail git am Maildir/*.patch && | |
1c7969c9 MM |
663 | cat >expected <<\EOF && |
664 | On branch am_empty | |
665 | You are in the middle of an am session. | |
666 | The current patch is empty. | |
667 | (use "git am --skip" to skip this patch) | |
668 | (use "git am --abort" to restore the original branch) | |
669 | ||
670 | nothing to commit (use -u to show untracked files) | |
671 | EOF | |
70819263 LK |
672 | git status --untracked-files=no >actual && |
673 | test_i18ncmp expected actual | |
674 | ' | |
675 | ||
676 | ||
677 | test_expect_success 'status when bisecting' ' | |
678 | git reset --hard master && | |
679 | git checkout -b bisect && | |
680 | test_commit one_bisect main.txt one && | |
681 | test_commit two_bisect main.txt two && | |
682 | test_commit three_bisect main.txt three && | |
683 | test_when_finished "git bisect reset" && | |
684 | git bisect start && | |
685 | git bisect bad && | |
686 | git bisect good one_bisect && | |
b397ea48 | 687 | TGT=$(git rev-parse --short two_bisect) && |
1c7969c9 MM |
688 | cat >expected <<EOF && |
689 | HEAD detached at $TGT | |
690 | You are currently bisecting, started from branch '\''bisect'\''. | |
691 | (use "git bisect reset" to get back to the original branch) | |
692 | ||
693 | nothing to commit (use -u to show untracked files) | |
694 | EOF | |
70819263 LK |
695 | git status --untracked-files=no >actual && |
696 | test_i18ncmp expected actual | |
697 | ' | |
698 | ||
699 | ||
700 | test_expect_success 'status when rebase conflicts with statushints disabled' ' | |
701 | git reset --hard master && | |
702 | git checkout -b statushints_disabled && | |
703 | test_when_finished "git config --local advice.statushints true" && | |
704 | git config --local advice.statushints false && | |
705 | test_commit one_statushints main.txt one && | |
706 | test_commit two_statushints main.txt two && | |
707 | test_commit three_statushints main.txt three && | |
708 | test_when_finished "git rebase --abort" && | |
0722c805 | 709 | ONTO=$(git rev-parse --short HEAD^^) && |
70819263 | 710 | test_must_fail git rebase HEAD^ --onto HEAD^^ && |
1c7969c9 MM |
711 | cat >expected <<EOF && |
712 | rebase in progress; onto $ONTO | |
713 | You are currently rebasing branch '\''statushints_disabled'\'' on '\''$ONTO'\''. | |
714 | ||
715 | Unmerged paths: | |
c7cb333f | 716 | both modified: main.txt |
1c7969c9 MM |
717 | |
718 | no changes added to commit | |
719 | EOF | |
70819263 LK |
720 | git status --untracked-files=no >actual && |
721 | test_i18ncmp expected actual | |
722 | ' | |
723 | ||
724 | ||
725 | test_expect_success 'prepare for cherry-pick conflicts' ' | |
726 | git reset --hard master && | |
727 | git checkout -b cherry_branch && | |
728 | test_commit one_cherry main.txt one && | |
729 | test_commit two_cherries main.txt two && | |
730 | git checkout -b cherry_branch_second && | |
731 | test_commit second_cherry main.txt second && | |
732 | git checkout cherry_branch && | |
733 | test_commit three_cherries main.txt three | |
734 | ' | |
735 | ||
736 | ||
737 | test_expect_success 'status when cherry-picking before resolving conflicts' ' | |
738 | test_when_finished "git cherry-pick --abort" && | |
739 | test_must_fail git cherry-pick cherry_branch_second && | |
bffd8098 RT |
740 | TO_CHERRY_PICK=$(git rev-parse --short CHERRY_PICK_HEAD) && |
741 | cat >expected <<EOF && | |
1c7969c9 | 742 | On branch cherry_branch |
bffd8098 | 743 | You are currently cherry-picking commit $TO_CHERRY_PICK. |
1c7969c9 MM |
744 | (fix conflicts and run "git cherry-pick --continue") |
745 | (use "git cherry-pick --abort" to cancel the cherry-pick operation) | |
746 | ||
747 | Unmerged paths: | |
748 | (use "git add <file>..." to mark resolution) | |
749 | ||
c7cb333f | 750 | both modified: main.txt |
1c7969c9 MM |
751 | |
752 | no changes added to commit (use "git add" and/or "git commit -a") | |
753 | EOF | |
70819263 LK |
754 | git status --untracked-files=no >actual && |
755 | test_i18ncmp expected actual | |
756 | ' | |
757 | ||
758 | ||
759 | test_expect_success 'status when cherry-picking after resolving conflicts' ' | |
760 | git reset --hard cherry_branch && | |
761 | test_when_finished "git cherry-pick --abort" && | |
762 | test_must_fail git cherry-pick cherry_branch_second && | |
bffd8098 | 763 | TO_CHERRY_PICK=$(git rev-parse --short CHERRY_PICK_HEAD) && |
70819263 LK |
764 | echo end >main.txt && |
765 | git add main.txt && | |
bffd8098 | 766 | cat >expected <<EOF && |
1c7969c9 | 767 | On branch cherry_branch |
bffd8098 | 768 | You are currently cherry-picking commit $TO_CHERRY_PICK. |
1c7969c9 MM |
769 | (all conflicts fixed: run "git cherry-pick --continue") |
770 | (use "git cherry-pick --abort" to cancel the cherry-pick operation) | |
771 | ||
772 | Changes to be committed: | |
773 | ||
774 | modified: main.txt | |
775 | ||
776 | Untracked files not listed (use -u option to show untracked files) | |
777 | EOF | |
70819263 LK |
778 | git status --untracked-files=no >actual && |
779 | test_i18ncmp expected actual | |
780 | ' | |
781 | ||
46ab7d46 | 782 | test_expect_success 'status showing detached at and from a tag' ' |
b397ea48 NTND |
783 | test_commit atag tagging && |
784 | git checkout atag && | |
59c22205 | 785 | cat >expected <<\EOF && |
1c7969c9 MM |
786 | HEAD detached at atag |
787 | nothing to commit (use -u to show untracked files) | |
788 | EOF | |
b397ea48 | 789 | git status --untracked-files=no >actual && |
46ab7d46 JH |
790 | test_i18ncmp expected actual && |
791 | ||
792 | git reset --hard HEAD^ && | |
59c22205 | 793 | cat >expected <<\EOF && |
1c7969c9 MM |
794 | HEAD detached from atag |
795 | nothing to commit (use -u to show untracked files) | |
796 | EOF | |
46ab7d46 | 797 | git status --untracked-files=no >actual && |
b397ea48 NTND |
798 | test_i18ncmp expected actual |
799 | ' | |
70819263 | 800 | |
db4ef449 MM |
801 | test_expect_success 'status while reverting commit (conflicts)' ' |
802 | git checkout master && | |
803 | echo before >to-revert.txt && | |
804 | test_commit before to-revert.txt && | |
805 | echo old >to-revert.txt && | |
806 | test_commit old to-revert.txt && | |
807 | echo new >to-revert.txt && | |
808 | test_commit new to-revert.txt && | |
87e139c0 MM |
809 | TO_REVERT=$(git rev-parse --short HEAD^) && |
810 | test_must_fail git revert $TO_REVERT && | |
59c22205 | 811 | cat >expected <<EOF && |
1c7969c9 MM |
812 | On branch master |
813 | You are currently reverting commit $TO_REVERT. | |
814 | (fix conflicts and run "git revert --continue") | |
815 | (use "git revert --abort" to cancel the revert operation) | |
816 | ||
817 | Unmerged paths: | |
818 | (use "git reset HEAD <file>..." to unstage) | |
819 | (use "git add <file>..." to mark resolution) | |
820 | ||
c7cb333f | 821 | both modified: to-revert.txt |
1c7969c9 MM |
822 | |
823 | no changes added to commit (use "git add" and/or "git commit -a") | |
824 | EOF | |
db4ef449 MM |
825 | git status --untracked-files=no >actual && |
826 | test_i18ncmp expected actual | |
827 | ' | |
828 | ||
829 | test_expect_success 'status while reverting commit (conflicts resolved)' ' | |
830 | echo reverted >to-revert.txt && | |
831 | git add to-revert.txt && | |
59c22205 | 832 | cat >expected <<EOF && |
1c7969c9 MM |
833 | On branch master |
834 | You are currently reverting commit $TO_REVERT. | |
835 | (all conflicts fixed: run "git revert --continue") | |
836 | (use "git revert --abort" to cancel the revert operation) | |
837 | ||
838 | Changes to be committed: | |
839 | (use "git reset HEAD <file>..." to unstage) | |
840 | ||
841 | modified: to-revert.txt | |
842 | ||
843 | Untracked files not listed (use -u option to show untracked files) | |
844 | EOF | |
db4ef449 MM |
845 | git status --untracked-files=no >actual && |
846 | test_i18ncmp expected actual | |
847 | ' | |
848 | ||
849 | test_expect_success 'status after reverting commit' ' | |
850 | git revert --continue && | |
59c22205 | 851 | cat >expected <<\EOF && |
1c7969c9 MM |
852 | On branch master |
853 | nothing to commit (use -u to show untracked files) | |
854 | EOF | |
db4ef449 MM |
855 | git status --untracked-files=no >actual && |
856 | test_i18ncmp expected actual | |
857 | ' | |
858 | ||
70819263 | 859 | test_done |