3 # Copyright (c) 2012 Valentin Duperray, Lucien Kong, Franck Jonas,
4 # Thomas Nguy, Khoi Nguyen
8 test_description
='git status advices'
12 .
"$TEST_DIRECTORY"/lib-rebase.sh
16 test_expect_success
'prepare for conflicts' '
17 test_commit init main.txt init &&
18 git branch conflicts &&
19 test_commit on_master main.txt on_master &&
20 git checkout conflicts &&
21 test_commit on_conflicts main.txt on_conflicts
25 test_expect_success
'status when conflicts unresolved' '
26 test_must_fail git merge master &&
27 cat >expected <<-\EOF &&
29 # You have unmerged paths.
30 # (fix conflicts and run "git commit")
33 # (use "git add <file>..." to mark resolution)
35 # both modified: main.txt
37 no changes added to commit (use "git add" and/or "git commit -a")
39 git status --untracked-files=no >actual &&
40 test_i18ncmp expected actual
44 test_expect_success
'status when conflicts resolved before commit' '
45 git reset --hard conflicts &&
46 test_must_fail git merge master &&
49 cat >expected <<-\EOF &&
51 # All conflicts fixed but you are still merging.
52 # (use "git commit" to conclude merge)
54 # Changes to be committed:
58 # Untracked files not listed (use -u option to show untracked files)
60 git status --untracked-files=no >actual &&
61 test_i18ncmp expected actual
65 test_expect_success
'prepare for rebase conflicts' '
66 git reset --hard master &&
67 git checkout -b rebase_conflicts &&
68 test_commit one_rebase main.txt one &&
69 test_commit two_rebase main.txt two &&
70 test_commit three_rebase main.txt three
74 test_expect_success
'status when rebase in progress before resolving conflicts' '
75 test_when_finished "git rebase --abort" &&
76 test_must_fail git rebase HEAD^ --onto HEAD^^ &&
77 cat >expected <<-\EOF &&
78 # Not currently on any branch.
79 # You are currently rebasing.
80 # (fix conflicts and then run "git rebase --continue")
81 # (use "git rebase --skip" to skip this patch)
82 # (use "git rebase --abort" to check out the original branch)
85 # (use "git reset HEAD <file>..." to unstage)
86 # (use "git add <file>..." to mark resolution)
88 # both modified: main.txt
90 no changes added to commit (use "git add" and/or "git commit -a")
92 git status --untracked-files=no >actual &&
93 test_i18ncmp expected actual
97 test_expect_success
'status when rebase in progress before rebase --continue' '
98 git reset --hard rebase_conflicts &&
99 test_when_finished "git rebase --abort" &&
100 test_must_fail git rebase HEAD^ --onto HEAD^^ &&
101 echo three >main.txt &&
103 cat >expected <<-\EOF &&
104 # Not currently on any branch.
105 # You are currently rebasing.
106 # (all conflicts fixed: run "git rebase --continue")
108 # Changes to be committed:
109 # (use "git reset HEAD <file>..." to unstage)
113 # Untracked files not listed (use -u option to show untracked files)
115 git status --untracked-files=no >actual &&
116 test_i18ncmp expected actual
120 test_expect_success
'prepare for rebase_i_conflicts' '
121 git reset --hard master &&
122 git checkout -b rebase_i_conflicts &&
123 test_commit one_unmerge main.txt one_unmerge &&
124 git branch rebase_i_conflicts_second &&
125 test_commit one_master main.txt one_master &&
126 git checkout rebase_i_conflicts_second &&
127 test_commit one_second main.txt one_second
131 test_expect_success
'status during rebase -i when conflicts unresolved' '
132 test_when_finished "git rebase --abort" &&
133 test_must_fail git rebase -i rebase_i_conflicts &&
134 cat >expected <<-\EOF &&
135 # Not currently on any branch.
136 # You are currently rebasing.
137 # (fix conflicts and then run "git rebase --continue")
138 # (use "git rebase --skip" to skip this patch)
139 # (use "git rebase --abort" to check out the original branch)
142 # (use "git reset HEAD <file>..." to unstage)
143 # (use "git add <file>..." to mark resolution)
145 # both modified: main.txt
147 no changes added to commit (use "git add" and/or "git commit -a")
149 git status --untracked-files=no >actual &&
150 test_i18ncmp expected actual
154 test_expect_success
'status during rebase -i after resolving conflicts' '
155 git reset --hard rebase_i_conflicts_second &&
156 test_when_finished "git rebase --abort" &&
157 test_must_fail git rebase -i rebase_i_conflicts &&
159 cat >expected <<-\EOF &&
160 # Not currently on any branch.
161 # You are currently rebasing.
162 # (all conflicts fixed: run "git rebase --continue")
164 # Changes to be committed:
165 # (use "git reset HEAD <file>..." to unstage)
169 # Untracked files not listed (use -u option to show untracked files)
171 git status --untracked-files=no >actual &&
172 test_i18ncmp expected actual
176 test_expect_success
'status when rebasing -i in edit mode' '
177 git reset --hard master &&
178 git checkout -b rebase_i_edit &&
179 test_commit one_rebase_i main.txt one &&
180 test_commit two_rebase_i main.txt two &&
181 test_commit three_rebase_i main.txt three &&
182 FAKE_LINES="1 edit 2" &&
184 test_when_finished "git rebase --abort" &&
185 git rebase -i HEAD~2 &&
186 cat >expected <<-\EOF &&
187 # Not currently on any branch.
188 # You are currently editing a commit during a rebase.
189 # (use "git commit --amend" to amend the current commit)
190 # (use "git rebase --continue" once you are satisfied with your changes)
192 nothing to commit (use -u to show untracked files)
194 git status --untracked-files=no >actual &&
195 test_i18ncmp expected actual
199 test_expect_success
'status when splitting a commit' '
200 git reset --hard master &&
201 git checkout -b split_commit &&
202 test_commit one_split main.txt one &&
203 test_commit two_split main.txt two &&
204 test_commit three_split main.txt three &&
205 test_commit four_split main.txt four &&
206 FAKE_LINES="1 edit 2 3" &&
208 test_when_finished "git rebase --abort" &&
209 git rebase -i HEAD~3 &&
211 cat >expected <<-\EOF &&
212 # Not currently on any branch.
213 # You are currently splitting a commit during a rebase.
214 # (Once your working directory is clean, run "git rebase --continue")
216 # Changes not staged for commit:
217 # (use "git add <file>..." to update what will be committed)
218 # (use "git checkout -- <file>..." to discard changes in working directory)
222 no changes added to commit (use "git add" and/or "git commit -a")
224 git status --untracked-files=no >actual &&
225 test_i18ncmp expected actual
229 test_expect_success
'status after editing the last commit with --amend during a rebase -i' '
230 git reset --hard master &&
231 git checkout -b amend_last &&
232 test_commit one_amend main.txt one &&
233 test_commit two_amend main.txt two &&
234 test_commit three_amend main.txt three &&
235 test_commit four_amend main.txt four &&
236 FAKE_LINES="1 2 edit 3" &&
238 test_when_finished "git rebase --abort" &&
239 git rebase -i HEAD~3 &&
240 git commit --amend -m "foo" &&
241 cat >expected <<-\EOF &&
242 # Not currently on any branch.
243 # You are currently editing a commit during a rebase.
244 # (use "git commit --amend" to amend the current commit)
245 # (use "git rebase --continue" once you are satisfied with your changes)
247 nothing to commit (use -u to show untracked files)
249 git status --untracked-files=no >actual &&
250 test_i18ncmp expected actual
254 test_expect_success
'prepare for several edits' '
255 git reset --hard master &&
256 git checkout -b several_edits &&
257 test_commit one_edits main.txt one &&
258 test_commit two_edits main.txt two &&
259 test_commit three_edits main.txt three &&
260 test_commit four_edits main.txt four
264 test_expect_success
'status: (continue first edit) second edit' '
265 FAKE_LINES="edit 1 edit 2 3" &&
267 test_when_finished "git rebase --abort" &&
268 git rebase -i HEAD~3 &&
269 git rebase --continue &&
270 cat >expected <<-\EOF &&
271 # Not currently on any branch.
272 # You are currently editing a commit during a rebase.
273 # (use "git commit --amend" to amend the current commit)
274 # (use "git rebase --continue" once you are satisfied with your changes)
276 nothing to commit (use -u to show untracked files)
278 git status --untracked-files=no >actual &&
279 test_i18ncmp expected actual
283 test_expect_success
'status: (continue first edit) second edit and split' '
284 git reset --hard several_edits &&
285 FAKE_LINES="edit 1 edit 2 3" &&
287 test_when_finished "git rebase --abort" &&
288 git rebase -i HEAD~3 &&
289 git rebase --continue &&
291 cat >expected <<-\EOF &&
292 # Not currently on any branch.
293 # You are currently splitting a commit during a rebase.
294 # (Once your working directory is clean, run "git rebase --continue")
296 # Changes not staged for commit:
297 # (use "git add <file>..." to update what will be committed)
298 # (use "git checkout -- <file>..." to discard changes in working directory)
302 no changes added to commit (use "git add" and/or "git commit -a")
304 git status --untracked-files=no >actual &&
305 test_i18ncmp expected actual
309 test_expect_success
'status: (continue first edit) second edit and amend' '
310 git reset --hard several_edits &&
311 FAKE_LINES="edit 1 edit 2 3" &&
313 test_when_finished "git rebase --abort" &&
314 git rebase -i HEAD~3 &&
315 git rebase --continue &&
316 git commit --amend -m "foo" &&
317 cat >expected <<-\EOF &&
318 # Not currently on any branch.
319 # You are currently editing a commit during a rebase.
320 # (use "git commit --amend" to amend the current commit)
321 # (use "git rebase --continue" once you are satisfied with your changes)
323 nothing to commit (use -u to show untracked files)
325 git status --untracked-files=no >actual &&
326 test_i18ncmp expected actual
330 test_expect_success
'status: (amend first edit) second edit' '
331 git reset --hard several_edits &&
332 FAKE_LINES="edit 1 edit 2 3" &&
334 test_when_finished "git rebase --abort" &&
335 git rebase -i HEAD~3 &&
336 git commit --amend -m "a" &&
337 git rebase --continue &&
338 cat >expected <<-\EOF &&
339 # Not currently on any branch.
340 # You are currently editing a commit during a rebase.
341 # (use "git commit --amend" to amend the current commit)
342 # (use "git rebase --continue" once you are satisfied with your changes)
344 nothing to commit (use -u to show untracked files)
346 git status --untracked-files=no >actual &&
347 test_i18ncmp expected actual
351 test_expect_success
'status: (amend first edit) second edit and split' '
352 git reset --hard several_edits &&
353 FAKE_LINES="edit 1 edit 2 3" &&
355 test_when_finished "git rebase --abort" &&
356 git rebase -i HEAD~3 &&
357 git commit --amend -m "b" &&
358 git rebase --continue &&
360 cat >expected <<-\EOF &&
361 # Not currently on any branch.
362 # You are currently splitting a commit during a rebase.
363 # (Once your working directory is clean, run "git rebase --continue")
365 # Changes not staged for commit:
366 # (use "git add <file>..." to update what will be committed)
367 # (use "git checkout -- <file>..." to discard changes in working directory)
371 no changes added to commit (use "git add" and/or "git commit -a")
373 git status --untracked-files=no >actual &&
374 test_i18ncmp expected actual
378 test_expect_success
'status: (amend first edit) second edit and amend' '
379 git reset --hard several_edits &&
380 FAKE_LINES="edit 1 edit 2 3" &&
382 test_when_finished "git rebase --abort" &&
383 git rebase -i HEAD~3 &&
384 git commit --amend -m "c" &&
385 git rebase --continue &&
386 git commit --amend -m "d" &&
387 cat >expected <<-\EOF &&
388 # Not currently on any branch.
389 # You are currently editing a commit during a rebase.
390 # (use "git commit --amend" to amend the current commit)
391 # (use "git rebase --continue" once you are satisfied with your changes)
393 nothing to commit (use -u to show untracked files)
395 git status --untracked-files=no >actual &&
396 test_i18ncmp expected actual
400 test_expect_success
'status: (split first edit) second edit' '
401 git reset --hard several_edits &&
402 FAKE_LINES="edit 1 edit 2 3" &&
404 test_when_finished "git rebase --abort" &&
405 git rebase -i HEAD~3 &&
409 git rebase --continue &&
410 cat >expected <<-\EOF &&
411 # Not currently on any branch.
412 # You are currently editing a commit during a rebase.
413 # (use "git commit --amend" to amend the current commit)
414 # (use "git rebase --continue" once you are satisfied with your changes)
416 nothing to commit (use -u to show untracked files)
418 git status --untracked-files=no >actual &&
419 test_i18ncmp expected actual
423 test_expect_success
'status: (split first edit) second edit and split' '
424 git reset --hard several_edits &&
425 FAKE_LINES="edit 1 edit 2 3" &&
427 test_when_finished "git rebase --abort" &&
428 git rebase -i HEAD~3 &&
431 git commit --amend -m "f" &&
432 git rebase --continue &&
434 cat >expected <<-\EOF &&
435 # Not currently on any branch.
436 # You are currently splitting a commit during a rebase.
437 # (Once your working directory is clean, run "git rebase --continue")
439 # Changes not staged for commit:
440 # (use "git add <file>..." to update what will be committed)
441 # (use "git checkout -- <file>..." to discard changes in working directory)
445 no changes added to commit (use "git add" and/or "git commit -a")
447 git status --untracked-files=no >actual &&
448 test_i18ncmp expected actual
452 test_expect_success
'status: (split first edit) second edit and amend' '
453 git reset --hard several_edits &&
454 FAKE_LINES="edit 1 edit 2 3" &&
456 test_when_finished "git rebase --abort" &&
457 git rebase -i HEAD~3 &&
460 git commit --amend -m "g" &&
461 git rebase --continue &&
462 git commit --amend -m "h" &&
463 cat >expected <<-\EOF &&
464 # Not currently on any branch.
465 # You are currently editing a commit during a rebase.
466 # (use "git commit --amend" to amend the current commit)
467 # (use "git rebase --continue" once you are satisfied with your changes)
469 nothing to commit (use -u to show untracked files)
471 git status --untracked-files=no >actual &&
472 test_i18ncmp expected actual
476 test_expect_success
'prepare am_session' '
477 git reset --hard master &&
478 git checkout -b am_session &&
479 test_commit one_am one.txt "one" &&
480 test_commit two_am two.txt "two" &&
481 test_commit three_am three.txt "three"
485 test_expect_success
'status in an am session: file already exists' '
486 git checkout -b am_already_exists &&
487 test_when_finished "rm Maildir/* && git am --abort" &&
488 git format-patch -1 -oMaildir &&
489 test_must_fail git am Maildir/*.patch &&
490 cat >expected <<-\EOF &&
491 # On branch am_already_exists
492 # You are in the middle of an am session.
493 # (fix conflicts and then run "git am --resolved")
494 # (use "git am --skip" to skip this patch)
495 # (use "git am --abort" to restore the original branch)
497 nothing to commit (use -u to show untracked files)
499 git status --untracked-files=no >actual &&
500 test_i18ncmp expected actual
504 test_expect_success
'status in an am session: file does not exist' '
505 git reset --hard am_session &&
506 git checkout -b am_not_exists &&
508 git commit -m "delete three.txt" &&
509 test_when_finished "rm Maildir/* && git am --abort" &&
510 git format-patch -1 -oMaildir &&
511 test_must_fail git am Maildir/*.patch &&
512 cat >expected <<-\EOF &&
513 # On branch am_not_exists
514 # You are in the middle of an am session.
515 # (fix conflicts and then run "git am --resolved")
516 # (use "git am --skip" to skip this patch)
517 # (use "git am --abort" to restore the original branch)
519 nothing to commit (use -u to show untracked files)
521 git status --untracked-files=no >actual &&
522 test_i18ncmp expected actual
526 test_expect_success
'status in an am session: empty patch' '
527 git reset --hard am_session &&
528 git checkout -b am_empty &&
529 test_when_finished "rm Maildir/* && git am --abort" &&
530 git format-patch -3 -oMaildir &&
531 git rm one.txt two.txt three.txt &&
532 git commit -m "delete all am_empty" &&
533 echo error >Maildir/0002-two_am.patch &&
534 test_must_fail git am Maildir/*.patch &&
535 cat >expected <<-\EOF &&
537 # You are in the middle of an am session.
538 # The current patch is empty.
539 # (use "git am --skip" to skip this patch)
540 # (use "git am --abort" to restore the original branch)
542 nothing to commit (use -u to show untracked files)
544 git status --untracked-files=no >actual &&
545 test_i18ncmp expected actual
549 test_expect_success
'status when bisecting' '
550 git reset --hard master &&
551 git checkout -b bisect &&
552 test_commit one_bisect main.txt one &&
553 test_commit two_bisect main.txt two &&
554 test_commit three_bisect main.txt three &&
555 test_when_finished "git bisect reset" &&
558 git bisect good one_bisect &&
559 cat >expected <<-\EOF &&
560 # Not currently on any branch.
561 # You are currently bisecting.
562 # (use "git bisect reset" to get back to the original branch)
564 nothing to commit (use -u to show untracked files)
566 git status --untracked-files=no >actual &&
567 test_i18ncmp expected actual
571 test_expect_success
'status when rebase conflicts with statushints disabled' '
572 git reset --hard master &&
573 git checkout -b statushints_disabled &&
574 test_when_finished "git config --local advice.statushints true" &&
575 git config --local advice.statushints false &&
576 test_commit one_statushints main.txt one &&
577 test_commit two_statushints main.txt two &&
578 test_commit three_statushints main.txt three &&
579 test_when_finished "git rebase --abort" &&
580 test_must_fail git rebase HEAD^ --onto HEAD^^ &&
581 cat >expected <<-\EOF &&
582 # Not currently on any branch.
583 # You are currently rebasing.
586 # both modified: main.txt
588 no changes added to commit
590 git status --untracked-files=no >actual &&
591 test_i18ncmp expected actual
595 test_expect_success
'prepare for cherry-pick conflicts' '
596 git reset --hard master &&
597 git checkout -b cherry_branch &&
598 test_commit one_cherry main.txt one &&
599 test_commit two_cherries main.txt two &&
600 git checkout -b cherry_branch_second &&
601 test_commit second_cherry main.txt second &&
602 git checkout cherry_branch &&
603 test_commit three_cherries main.txt three
607 test_expect_success
'status when cherry-picking before resolving conflicts' '
608 test_when_finished "git cherry-pick --abort" &&
609 test_must_fail git cherry-pick cherry_branch_second &&
610 cat >expected <<-\EOF &&
611 # On branch cherry_branch
612 # You are currently cherry-picking.
613 # (fix conflicts and run "git commit")
616 # (use "git add <file>..." to mark resolution)
618 # both modified: main.txt
620 no changes added to commit (use "git add" and/or "git commit -a")
622 git status --untracked-files=no >actual &&
623 test_i18ncmp expected actual
627 test_expect_success
'status when cherry-picking after resolving conflicts' '
628 git reset --hard cherry_branch &&
629 test_when_finished "git cherry-pick --abort" &&
630 test_must_fail git cherry-pick cherry_branch_second &&
631 echo end >main.txt &&
633 cat >expected <<-\EOF &&
634 # On branch cherry_branch
635 # You are currently cherry-picking.
636 # (all conflicts fixed: run "git commit")
638 # Changes to be committed:
642 # Untracked files not listed (use -u option to show untracked files)
644 git status --untracked-files=no >actual &&
645 test_i18ncmp expected actual