fmt-merge-msg: respect core.commentchar in people credits
[git/raj.git] / t / t7512-status-help.sh
blobd2da89a5f572134c55c690b1439ffde66ecdd6cb
1 #!/bin/sh
3 # Copyright (c) 2012 Valentin Duperray, Lucien Kong, Franck Jonas,
4 # Thomas Nguy, Khoi Nguyen
5 # Grenoble INP Ensimag
8 test_description='git status advice'
10 . ./test-lib.sh
12 . "$TEST_DIRECTORY"/lib-rebase.sh
14 set_fake_editor
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 &&
28 # On branch conflicts
29 # You have unmerged paths.
30 # (fix conflicts and run "git commit")
32 # Unmerged paths:
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")
38 EOF
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 &&
47 echo one >main.txt &&
48 git add main.txt &&
49 cat >expected <<-\EOF &&
50 # On branch conflicts
51 # All conflicts fixed but you are still merging.
52 # (use "git commit" to conclude merge)
54 # Changes to be committed:
56 # modified: main.txt
58 # Untracked files not listed (use -u option to show untracked files)
59 EOF
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 ONTO=$(git rev-parse --short HEAD^^) &&
77 test_must_fail git rebase HEAD^ --onto HEAD^^ &&
78 cat >expected <<-EOF &&
79 # Not currently on any branch.
80 # You are currently rebasing branch '\''rebase_conflicts'\'' on '\''$ONTO'\''.
81 # (fix conflicts and then run "git rebase --continue")
82 # (use "git rebase --skip" to skip this patch)
83 # (use "git rebase --abort" to check out the original branch)
85 # Unmerged paths:
86 # (use "git reset HEAD <file>..." to unstage)
87 # (use "git add <file>..." to mark resolution)
89 # both modified: main.txt
91 no changes added to commit (use "git add" and/or "git commit -a")
92 EOF
93 git status --untracked-files=no >actual &&
94 test_i18ncmp expected actual
98 test_expect_success 'status when rebase in progress before rebase --continue' '
99 git reset --hard rebase_conflicts &&
100 test_when_finished "git rebase --abort" &&
101 ONTO=$(git rev-parse --short HEAD^^) &&
102 test_must_fail git rebase HEAD^ --onto HEAD^^ &&
103 echo three >main.txt &&
104 git add main.txt &&
105 cat >expected <<-EOF &&
106 # Not currently on any branch.
107 # You are currently rebasing branch '\''rebase_conflicts'\'' on '\''$ONTO'\''.
108 # (all conflicts fixed: run "git rebase --continue")
110 # Changes to be committed:
111 # (use "git reset HEAD <file>..." to unstage)
113 # modified: main.txt
115 # Untracked files not listed (use -u option to show untracked files)
117 git status --untracked-files=no >actual &&
118 test_i18ncmp expected actual
122 test_expect_success 'prepare for rebase_i_conflicts' '
123 git reset --hard master &&
124 git checkout -b rebase_i_conflicts &&
125 test_commit one_unmerge main.txt one_unmerge &&
126 git branch rebase_i_conflicts_second &&
127 test_commit one_master main.txt one_master &&
128 git checkout rebase_i_conflicts_second &&
129 test_commit one_second main.txt one_second
133 test_expect_success 'status during rebase -i when conflicts unresolved' '
134 test_when_finished "git rebase --abort" &&
135 ONTO=$(git rev-parse --short rebase_i_conflicts) &&
136 test_must_fail git rebase -i rebase_i_conflicts &&
137 cat >expected <<-EOF &&
138 # Not currently on any branch.
139 # You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''$ONTO'\''.
140 # (fix conflicts and then run "git rebase --continue")
141 # (use "git rebase --skip" to skip this patch)
142 # (use "git rebase --abort" to check out the original branch)
144 # Unmerged paths:
145 # (use "git reset HEAD <file>..." to unstage)
146 # (use "git add <file>..." to mark resolution)
148 # both modified: main.txt
150 no changes added to commit (use "git add" and/or "git commit -a")
152 git status --untracked-files=no >actual &&
153 test_i18ncmp expected actual
157 test_expect_success 'status during rebase -i after resolving conflicts' '
158 git reset --hard rebase_i_conflicts_second &&
159 test_when_finished "git rebase --abort" &&
160 ONTO=$(git rev-parse --short rebase_i_conflicts) &&
161 test_must_fail git rebase -i rebase_i_conflicts &&
162 git add main.txt &&
163 cat >expected <<-EOF &&
164 # Not currently on any branch.
165 # You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''$ONTO'\''.
166 # (all conflicts fixed: run "git rebase --continue")
168 # Changes to be committed:
169 # (use "git reset HEAD <file>..." to unstage)
171 # modified: main.txt
173 # Untracked files not listed (use -u option to show untracked files)
175 git status --untracked-files=no >actual &&
176 test_i18ncmp expected actual
180 test_expect_success 'status when rebasing -i in edit mode' '
181 git reset --hard master &&
182 git checkout -b rebase_i_edit &&
183 test_commit one_rebase_i main.txt one &&
184 test_commit two_rebase_i main.txt two &&
185 test_commit three_rebase_i main.txt three &&
186 FAKE_LINES="1 edit 2" &&
187 export FAKE_LINES &&
188 test_when_finished "git rebase --abort" &&
189 ONTO=$(git rev-parse --short HEAD~2) &&
190 git rebase -i HEAD~2 &&
191 cat >expected <<-EOF &&
192 # Not currently on any branch.
193 # You are currently editing a commit while rebasing branch '\''rebase_i_edit'\'' on '\''$ONTO'\''.
194 # (use "git commit --amend" to amend the current commit)
195 # (use "git rebase --continue" once you are satisfied with your changes)
197 nothing to commit (use -u to show untracked files)
199 git status --untracked-files=no >actual &&
200 test_i18ncmp expected actual
204 test_expect_success 'status when splitting a commit' '
205 git reset --hard master &&
206 git checkout -b split_commit &&
207 test_commit one_split main.txt one &&
208 test_commit two_split main.txt two &&
209 test_commit three_split main.txt three &&
210 test_commit four_split main.txt four &&
211 FAKE_LINES="1 edit 2 3" &&
212 export FAKE_LINES &&
213 test_when_finished "git rebase --abort" &&
214 ONTO=$(git rev-parse --short HEAD~3) &&
215 git rebase -i HEAD~3 &&
216 git reset HEAD^ &&
217 cat >expected <<-EOF &&
218 # Not currently on any branch.
219 # You are currently splitting a commit while rebasing branch '\''split_commit'\'' on '\''$ONTO'\''.
220 # (Once your working directory is clean, run "git rebase --continue")
222 # Changes not staged for commit:
223 # (use "git add <file>..." to update what will be committed)
224 # (use "git checkout -- <file>..." to discard changes in working directory)
226 # modified: main.txt
228 no changes added to commit (use "git add" and/or "git commit -a")
230 git status --untracked-files=no >actual &&
231 test_i18ncmp expected actual
235 test_expect_success 'status after editing the last commit with --amend during a rebase -i' '
236 git reset --hard master &&
237 git checkout -b amend_last &&
238 test_commit one_amend main.txt one &&
239 test_commit two_amend main.txt two &&
240 test_commit three_amend main.txt three &&
241 test_commit four_amend main.txt four &&
242 FAKE_LINES="1 2 edit 3" &&
243 export FAKE_LINES &&
244 test_when_finished "git rebase --abort" &&
245 ONTO=$(git rev-parse --short HEAD~3) &&
246 git rebase -i HEAD~3 &&
247 git commit --amend -m "foo" &&
248 cat >expected <<-EOF &&
249 # Not currently on any branch.
250 # You are currently editing a commit while rebasing branch '\''amend_last'\'' on '\''$ONTO'\''.
251 # (use "git commit --amend" to amend the current commit)
252 # (use "git rebase --continue" once you are satisfied with your changes)
254 nothing to commit (use -u to show untracked files)
256 git status --untracked-files=no >actual &&
257 test_i18ncmp expected actual
261 test_expect_success 'prepare for several edits' '
262 git reset --hard master &&
263 git checkout -b several_edits &&
264 test_commit one_edits main.txt one &&
265 test_commit two_edits main.txt two &&
266 test_commit three_edits main.txt three &&
267 test_commit four_edits main.txt four
271 test_expect_success 'status: (continue first edit) second edit' '
272 FAKE_LINES="edit 1 edit 2 3" &&
273 export FAKE_LINES &&
274 test_when_finished "git rebase --abort" &&
275 ONTO=$(git rev-parse --short HEAD~3) &&
276 git rebase -i HEAD~3 &&
277 git rebase --continue &&
278 cat >expected <<-EOF &&
279 # Not currently on any branch.
280 # You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
281 # (use "git commit --amend" to amend the current commit)
282 # (use "git rebase --continue" once you are satisfied with your changes)
284 nothing to commit (use -u to show untracked files)
286 git status --untracked-files=no >actual &&
287 test_i18ncmp expected actual
291 test_expect_success 'status: (continue first edit) second edit and split' '
292 git reset --hard several_edits &&
293 FAKE_LINES="edit 1 edit 2 3" &&
294 export FAKE_LINES &&
295 test_when_finished "git rebase --abort" &&
296 ONTO=$(git rev-parse --short HEAD~3) &&
297 git rebase -i HEAD~3 &&
298 git rebase --continue &&
299 git reset HEAD^ &&
300 cat >expected <<-EOF &&
301 # Not currently on any branch.
302 # You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
303 # (Once your working directory is clean, run "git rebase --continue")
305 # Changes not staged for commit:
306 # (use "git add <file>..." to update what will be committed)
307 # (use "git checkout -- <file>..." to discard changes in working directory)
309 # modified: main.txt
311 no changes added to commit (use "git add" and/or "git commit -a")
313 git status --untracked-files=no >actual &&
314 test_i18ncmp expected actual
318 test_expect_success 'status: (continue first edit) second edit and amend' '
319 git reset --hard several_edits &&
320 FAKE_LINES="edit 1 edit 2 3" &&
321 export FAKE_LINES &&
322 test_when_finished "git rebase --abort" &&
323 ONTO=$(git rev-parse --short HEAD~3) &&
324 git rebase -i HEAD~3 &&
325 git rebase --continue &&
326 git commit --amend -m "foo" &&
327 cat >expected <<-EOF &&
328 # Not currently on any branch.
329 # You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
330 # (use "git commit --amend" to amend the current commit)
331 # (use "git rebase --continue" once you are satisfied with your changes)
333 nothing to commit (use -u to show untracked files)
335 git status --untracked-files=no >actual &&
336 test_i18ncmp expected actual
340 test_expect_success 'status: (amend first edit) second edit' '
341 git reset --hard several_edits &&
342 FAKE_LINES="edit 1 edit 2 3" &&
343 export FAKE_LINES &&
344 test_when_finished "git rebase --abort" &&
345 ONTO=$(git rev-parse --short HEAD~3) &&
346 git rebase -i HEAD~3 &&
347 git commit --amend -m "a" &&
348 git rebase --continue &&
349 cat >expected <<-EOF &&
350 # Not currently on any branch.
351 # You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
352 # (use "git commit --amend" to amend the current commit)
353 # (use "git rebase --continue" once you are satisfied with your changes)
355 nothing to commit (use -u to show untracked files)
357 git status --untracked-files=no >actual &&
358 test_i18ncmp expected actual
362 test_expect_success 'status: (amend first edit) second edit and split' '
363 git reset --hard several_edits &&
364 FAKE_LINES="edit 1 edit 2 3" &&
365 export FAKE_LINES &&
366 test_when_finished "git rebase --abort" &&
367 ONTO=$(git rev-parse --short HEAD~3) &&
368 git rebase -i HEAD~3 &&
369 git commit --amend -m "b" &&
370 git rebase --continue &&
371 git reset HEAD^ &&
372 cat >expected <<-EOF &&
373 # Not currently on any branch.
374 # You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
375 # (Once your working directory is clean, run "git rebase --continue")
377 # Changes not staged for commit:
378 # (use "git add <file>..." to update what will be committed)
379 # (use "git checkout -- <file>..." to discard changes in working directory)
381 # modified: main.txt
383 no changes added to commit (use "git add" and/or "git commit -a")
385 git status --untracked-files=no >actual &&
386 test_i18ncmp expected actual
390 test_expect_success 'status: (amend first edit) second edit and amend' '
391 git reset --hard several_edits &&
392 FAKE_LINES="edit 1 edit 2 3" &&
393 export FAKE_LINES &&
394 test_when_finished "git rebase --abort" &&
395 ONTO=$(git rev-parse --short HEAD~3) &&
396 git rebase -i HEAD~3 &&
397 git commit --amend -m "c" &&
398 git rebase --continue &&
399 git commit --amend -m "d" &&
400 cat >expected <<-EOF &&
401 # Not currently on any branch.
402 # You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
403 # (use "git commit --amend" to amend the current commit)
404 # (use "git rebase --continue" once you are satisfied with your changes)
406 nothing to commit (use -u to show untracked files)
408 git status --untracked-files=no >actual &&
409 test_i18ncmp expected actual
413 test_expect_success 'status: (split first edit) second edit' '
414 git reset --hard several_edits &&
415 FAKE_LINES="edit 1 edit 2 3" &&
416 export FAKE_LINES &&
417 test_when_finished "git rebase --abort" &&
418 ONTO=$(git rev-parse --short HEAD~3) &&
419 git rebase -i HEAD~3 &&
420 git reset HEAD^ &&
421 git add main.txt &&
422 git commit -m "e" &&
423 git rebase --continue &&
424 cat >expected <<-EOF &&
425 # Not currently on any branch.
426 # You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
427 # (use "git commit --amend" to amend the current commit)
428 # (use "git rebase --continue" once you are satisfied with your changes)
430 nothing to commit (use -u to show untracked files)
432 git status --untracked-files=no >actual &&
433 test_i18ncmp expected actual
437 test_expect_success 'status: (split first edit) second edit and split' '
438 git reset --hard several_edits &&
439 FAKE_LINES="edit 1 edit 2 3" &&
440 export FAKE_LINES &&
441 test_when_finished "git rebase --abort" &&
442 ONTO=$(git rev-parse --short HEAD~3) &&
443 git rebase -i HEAD~3 &&
444 git reset HEAD^ &&
445 git add main.txt &&
446 git commit --amend -m "f" &&
447 git rebase --continue &&
448 git reset HEAD^ &&
449 cat >expected <<-EOF &&
450 # Not currently on any branch.
451 # You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
452 # (Once your working directory is clean, run "git rebase --continue")
454 # Changes not staged for commit:
455 # (use "git add <file>..." to update what will be committed)
456 # (use "git checkout -- <file>..." to discard changes in working directory)
458 # modified: main.txt
460 no changes added to commit (use "git add" and/or "git commit -a")
462 git status --untracked-files=no >actual &&
463 test_i18ncmp expected actual
467 test_expect_success 'status: (split first edit) second edit and amend' '
468 git reset --hard several_edits &&
469 FAKE_LINES="edit 1 edit 2 3" &&
470 export FAKE_LINES &&
471 test_when_finished "git rebase --abort" &&
472 ONTO=$(git rev-parse --short HEAD~3) &&
473 git rebase -i HEAD~3 &&
474 git reset HEAD^ &&
475 git add main.txt &&
476 git commit --amend -m "g" &&
477 git rebase --continue &&
478 git commit --amend -m "h" &&
479 cat >expected <<-EOF &&
480 # Not currently on any branch.
481 # You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
482 # (use "git commit --amend" to amend the current commit)
483 # (use "git rebase --continue" once you are satisfied with your changes)
485 nothing to commit (use -u to show untracked files)
487 git status --untracked-files=no >actual &&
488 test_i18ncmp expected actual
492 test_expect_success 'prepare am_session' '
493 git reset --hard master &&
494 git checkout -b am_session &&
495 test_commit one_am one.txt "one" &&
496 test_commit two_am two.txt "two" &&
497 test_commit three_am three.txt "three"
501 test_expect_success 'status in an am session: file already exists' '
502 git checkout -b am_already_exists &&
503 test_when_finished "rm Maildir/* && git am --abort" &&
504 git format-patch -1 -oMaildir &&
505 test_must_fail git am Maildir/*.patch &&
506 cat >expected <<-\EOF &&
507 # On branch am_already_exists
508 # You are in the middle of an am session.
509 # (fix conflicts and then run "git am --resolved")
510 # (use "git am --skip" to skip this patch)
511 # (use "git am --abort" to restore the original branch)
513 nothing to commit (use -u to show untracked files)
515 git status --untracked-files=no >actual &&
516 test_i18ncmp expected actual
520 test_expect_success 'status in an am session: file does not exist' '
521 git reset --hard am_session &&
522 git checkout -b am_not_exists &&
523 git rm three.txt &&
524 git commit -m "delete three.txt" &&
525 test_when_finished "rm Maildir/* && git am --abort" &&
526 git format-patch -1 -oMaildir &&
527 test_must_fail git am Maildir/*.patch &&
528 cat >expected <<-\EOF &&
529 # On branch am_not_exists
530 # You are in the middle of an am session.
531 # (fix conflicts and then run "git am --resolved")
532 # (use "git am --skip" to skip this patch)
533 # (use "git am --abort" to restore the original branch)
535 nothing to commit (use -u to show untracked files)
537 git status --untracked-files=no >actual &&
538 test_i18ncmp expected actual
542 test_expect_success 'status in an am session: empty patch' '
543 git reset --hard am_session &&
544 git checkout -b am_empty &&
545 test_when_finished "rm Maildir/* && git am --abort" &&
546 git format-patch -3 -oMaildir &&
547 git rm one.txt two.txt three.txt &&
548 git commit -m "delete all am_empty" &&
549 echo error >Maildir/0002-two_am.patch &&
550 test_must_fail git am Maildir/*.patch &&
551 cat >expected <<-\EOF &&
552 # On branch am_empty
553 # You are in the middle of an am session.
554 # The current patch is empty.
555 # (use "git am --skip" to skip this patch)
556 # (use "git am --abort" to restore the original branch)
558 nothing to commit (use -u to show untracked files)
560 git status --untracked-files=no >actual &&
561 test_i18ncmp expected actual
565 test_expect_success 'status when bisecting' '
566 git reset --hard master &&
567 git checkout -b bisect &&
568 test_commit one_bisect main.txt one &&
569 test_commit two_bisect main.txt two &&
570 test_commit three_bisect main.txt three &&
571 test_when_finished "git bisect reset" &&
572 git bisect start &&
573 git bisect bad &&
574 git bisect good one_bisect &&
575 cat >expected <<-\EOF &&
576 # Not currently on any branch.
577 # You are currently bisecting branch '\''bisect'\''.
578 # (use "git bisect reset" to get back to the original branch)
580 nothing to commit (use -u to show untracked files)
582 git status --untracked-files=no >actual &&
583 test_i18ncmp expected actual
587 test_expect_success 'status when rebase conflicts with statushints disabled' '
588 git reset --hard master &&
589 git checkout -b statushints_disabled &&
590 test_when_finished "git config --local advice.statushints true" &&
591 git config --local advice.statushints false &&
592 test_commit one_statushints main.txt one &&
593 test_commit two_statushints main.txt two &&
594 test_commit three_statushints main.txt three &&
595 test_when_finished "git rebase --abort" &&
596 ONTO=$(git rev-parse --short HEAD^^) &&
597 test_must_fail git rebase HEAD^ --onto HEAD^^ &&
598 cat >expected <<-EOF &&
599 # Not currently on any branch.
600 # You are currently rebasing branch '\''statushints_disabled'\'' on '\''$ONTO'\''.
602 # Unmerged paths:
603 # both modified: main.txt
605 no changes added to commit
607 git status --untracked-files=no >actual &&
608 test_i18ncmp expected actual
612 test_expect_success 'prepare for cherry-pick conflicts' '
613 git reset --hard master &&
614 git checkout -b cherry_branch &&
615 test_commit one_cherry main.txt one &&
616 test_commit two_cherries main.txt two &&
617 git checkout -b cherry_branch_second &&
618 test_commit second_cherry main.txt second &&
619 git checkout cherry_branch &&
620 test_commit three_cherries main.txt three
624 test_expect_success 'status when cherry-picking before resolving conflicts' '
625 test_when_finished "git cherry-pick --abort" &&
626 test_must_fail git cherry-pick cherry_branch_second &&
627 cat >expected <<-\EOF &&
628 # On branch cherry_branch
629 # You are currently cherry-picking.
630 # (fix conflicts and run "git commit")
632 # Unmerged paths:
633 # (use "git add <file>..." to mark resolution)
635 # both modified: main.txt
637 no changes added to commit (use "git add" and/or "git commit -a")
639 git status --untracked-files=no >actual &&
640 test_i18ncmp expected actual
644 test_expect_success 'status when cherry-picking after resolving conflicts' '
645 git reset --hard cherry_branch &&
646 test_when_finished "git cherry-pick --abort" &&
647 test_must_fail git cherry-pick cherry_branch_second &&
648 echo end >main.txt &&
649 git add main.txt &&
650 cat >expected <<-\EOF &&
651 # On branch cherry_branch
652 # You are currently cherry-picking.
653 # (all conflicts fixed: run "git commit")
655 # Changes to be committed:
657 # modified: main.txt
659 # Untracked files not listed (use -u option to show untracked files)
661 git status --untracked-files=no >actual &&
662 test_i18ncmp expected actual
666 test_done