t/README: --valgrind already implies -v
[git/gitweb.git] / t / t7512-status-help.sh
blob9d4610629d725c22b9de5187abf71b2b8544292d
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 git config --global advice.statusuoption false &&
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
26 test_expect_success 'status when conflicts unresolved' '
27 test_must_fail git merge master &&
28 cat >expected <<-\EOF &&
29 # On branch conflicts
30 # You have unmerged paths.
31 # (fix conflicts and run "git commit")
33 # Unmerged paths:
34 # (use "git add <file>..." to mark resolution)
36 # both modified: main.txt
38 no changes added to commit (use "git add" and/or "git commit -a")
39 EOF
40 git status --untracked-files=no >actual &&
41 test_i18ncmp expected actual
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 &&
50 cat >expected <<-\EOF &&
51 # On branch conflicts
52 # All conflicts fixed but you are still merging.
53 # (use "git commit" to conclude merge)
55 # Changes to be committed:
57 # modified: main.txt
59 # Untracked files not listed (use -u option to show untracked files)
60 EOF
61 git status --untracked-files=no >actual &&
62 test_i18ncmp expected actual
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
75 test_expect_success 'status when rebase in progress before resolving conflicts' '
76 test_when_finished "git rebase --abort" &&
77 ONTO=$(git rev-parse --short HEAD^^) &&
78 test_must_fail git rebase HEAD^ --onto HEAD^^ &&
79 cat >expected <<-EOF &&
80 # Not currently on any branch.
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)
86 # Unmerged paths:
87 # (use "git reset HEAD <file>..." to unstage)
88 # (use "git add <file>..." to mark resolution)
90 # both modified: main.txt
92 no changes added to commit (use "git add" and/or "git commit -a")
93 EOF
94 git status --untracked-files=no >actual &&
95 test_i18ncmp expected actual
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" &&
102 ONTO=$(git rev-parse --short HEAD^^) &&
103 test_must_fail git rebase HEAD^ --onto HEAD^^ &&
104 echo three >main.txt &&
105 git add main.txt &&
106 cat >expected <<-EOF &&
107 # Not currently on any branch.
108 # You are currently rebasing branch '\''rebase_conflicts'\'' on '\''$ONTO'\''.
109 # (all conflicts fixed: run "git rebase --continue")
111 # Changes to be committed:
112 # (use "git reset HEAD <file>..." to unstage)
114 # modified: main.txt
116 # Untracked files not listed (use -u option to show untracked files)
118 git status --untracked-files=no >actual &&
119 test_i18ncmp expected actual
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
134 test_expect_success 'status during rebase -i when conflicts unresolved' '
135 test_when_finished "git rebase --abort" &&
136 ONTO=$(git rev-parse --short rebase_i_conflicts) &&
137 test_must_fail git rebase -i rebase_i_conflicts &&
138 cat >expected <<-EOF &&
139 # Not currently on any branch.
140 # You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''$ONTO'\''.
141 # (fix conflicts and then run "git rebase --continue")
142 # (use "git rebase --skip" to skip this patch)
143 # (use "git rebase --abort" to check out the original branch)
145 # Unmerged paths:
146 # (use "git reset HEAD <file>..." to unstage)
147 # (use "git add <file>..." to mark resolution)
149 # both modified: main.txt
151 no changes added to commit (use "git add" and/or "git commit -a")
153 git status --untracked-files=no >actual &&
154 test_i18ncmp expected actual
158 test_expect_success 'status during rebase -i after resolving conflicts' '
159 git reset --hard rebase_i_conflicts_second &&
160 test_when_finished "git rebase --abort" &&
161 ONTO=$(git rev-parse --short rebase_i_conflicts) &&
162 test_must_fail git rebase -i rebase_i_conflicts &&
163 git add main.txt &&
164 cat >expected <<-EOF &&
165 # Not currently on any branch.
166 # You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''$ONTO'\''.
167 # (all conflicts fixed: run "git rebase --continue")
169 # Changes to be committed:
170 # (use "git reset HEAD <file>..." to unstage)
172 # modified: main.txt
174 # Untracked files not listed (use -u option to show untracked files)
176 git status --untracked-files=no >actual &&
177 test_i18ncmp expected actual
181 test_expect_success 'status when rebasing -i in edit mode' '
182 git reset --hard master &&
183 git checkout -b rebase_i_edit &&
184 test_commit one_rebase_i main.txt one &&
185 test_commit two_rebase_i main.txt two &&
186 test_commit three_rebase_i main.txt three &&
187 FAKE_LINES="1 edit 2" &&
188 export FAKE_LINES &&
189 test_when_finished "git rebase --abort" &&
190 ONTO=$(git rev-parse --short HEAD~2) &&
191 git rebase -i HEAD~2 &&
192 cat >expected <<-EOF &&
193 # Not currently on any branch.
194 # You are currently editing a commit while rebasing branch '\''rebase_i_edit'\'' on '\''$ONTO'\''.
195 # (use "git commit --amend" to amend the current commit)
196 # (use "git rebase --continue" once you are satisfied with your changes)
198 nothing to commit (use -u to show untracked files)
200 git status --untracked-files=no >actual &&
201 test_i18ncmp expected actual
205 test_expect_success 'status when splitting a commit' '
206 git reset --hard master &&
207 git checkout -b split_commit &&
208 test_commit one_split main.txt one &&
209 test_commit two_split main.txt two &&
210 test_commit three_split main.txt three &&
211 test_commit four_split main.txt four &&
212 FAKE_LINES="1 edit 2 3" &&
213 export FAKE_LINES &&
214 test_when_finished "git rebase --abort" &&
215 ONTO=$(git rev-parse --short HEAD~3) &&
216 git rebase -i HEAD~3 &&
217 git reset HEAD^ &&
218 cat >expected <<-EOF &&
219 # Not currently on any branch.
220 # You are currently splitting a commit while rebasing branch '\''split_commit'\'' on '\''$ONTO'\''.
221 # (Once your working directory is clean, run "git rebase --continue")
223 # Changes not staged for commit:
224 # (use "git add <file>..." to update what will be committed)
225 # (use "git checkout -- <file>..." to discard changes in working directory)
227 # modified: main.txt
229 no changes added to commit (use "git add" and/or "git commit -a")
231 git status --untracked-files=no >actual &&
232 test_i18ncmp expected actual
236 test_expect_success 'status after editing the last commit with --amend during a rebase -i' '
237 git reset --hard master &&
238 git checkout -b amend_last &&
239 test_commit one_amend main.txt one &&
240 test_commit two_amend main.txt two &&
241 test_commit three_amend main.txt three &&
242 test_commit four_amend main.txt four &&
243 FAKE_LINES="1 2 edit 3" &&
244 export FAKE_LINES &&
245 test_when_finished "git rebase --abort" &&
246 ONTO=$(git rev-parse --short HEAD~3) &&
247 git rebase -i HEAD~3 &&
248 git commit --amend -m "foo" &&
249 cat >expected <<-EOF &&
250 # Not currently on any branch.
251 # You are currently editing a commit while rebasing branch '\''amend_last'\'' on '\''$ONTO'\''.
252 # (use "git commit --amend" to amend the current commit)
253 # (use "git rebase --continue" once you are satisfied with your changes)
255 nothing to commit (use -u to show untracked files)
257 git status --untracked-files=no >actual &&
258 test_i18ncmp expected actual
262 test_expect_success 'prepare for several edits' '
263 git reset --hard master &&
264 git checkout -b several_edits &&
265 test_commit one_edits main.txt one &&
266 test_commit two_edits main.txt two &&
267 test_commit three_edits main.txt three &&
268 test_commit four_edits main.txt four
272 test_expect_success 'status: (continue first edit) second edit' '
273 FAKE_LINES="edit 1 edit 2 3" &&
274 export FAKE_LINES &&
275 test_when_finished "git rebase --abort" &&
276 ONTO=$(git rev-parse --short HEAD~3) &&
277 git rebase -i HEAD~3 &&
278 git rebase --continue &&
279 cat >expected <<-EOF &&
280 # Not currently on any branch.
281 # You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
282 # (use "git commit --amend" to amend the current commit)
283 # (use "git rebase --continue" once you are satisfied with your changes)
285 nothing to commit (use -u to show untracked files)
287 git status --untracked-files=no >actual &&
288 test_i18ncmp expected actual
292 test_expect_success 'status: (continue first edit) second edit and split' '
293 git reset --hard several_edits &&
294 FAKE_LINES="edit 1 edit 2 3" &&
295 export FAKE_LINES &&
296 test_when_finished "git rebase --abort" &&
297 ONTO=$(git rev-parse --short HEAD~3) &&
298 git rebase -i HEAD~3 &&
299 git rebase --continue &&
300 git reset HEAD^ &&
301 cat >expected <<-EOF &&
302 # Not currently on any branch.
303 # You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
304 # (Once your working directory is clean, run "git rebase --continue")
306 # Changes not staged for commit:
307 # (use "git add <file>..." to update what will be committed)
308 # (use "git checkout -- <file>..." to discard changes in working directory)
310 # modified: main.txt
312 no changes added to commit (use "git add" and/or "git commit -a")
314 git status --untracked-files=no >actual &&
315 test_i18ncmp expected actual
319 test_expect_success 'status: (continue first edit) second edit and amend' '
320 git reset --hard several_edits &&
321 FAKE_LINES="edit 1 edit 2 3" &&
322 export FAKE_LINES &&
323 test_when_finished "git rebase --abort" &&
324 ONTO=$(git rev-parse --short HEAD~3) &&
325 git rebase -i HEAD~3 &&
326 git rebase --continue &&
327 git commit --amend -m "foo" &&
328 cat >expected <<-EOF &&
329 # Not currently on any branch.
330 # You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
331 # (use "git commit --amend" to amend the current commit)
332 # (use "git rebase --continue" once you are satisfied with your changes)
334 nothing to commit (use -u to show untracked files)
336 git status --untracked-files=no >actual &&
337 test_i18ncmp expected actual
341 test_expect_success 'status: (amend first edit) second edit' '
342 git reset --hard several_edits &&
343 FAKE_LINES="edit 1 edit 2 3" &&
344 export FAKE_LINES &&
345 test_when_finished "git rebase --abort" &&
346 ONTO=$(git rev-parse --short HEAD~3) &&
347 git rebase -i HEAD~3 &&
348 git commit --amend -m "a" &&
349 git rebase --continue &&
350 cat >expected <<-EOF &&
351 # Not currently on any branch.
352 # You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
353 # (use "git commit --amend" to amend the current commit)
354 # (use "git rebase --continue" once you are satisfied with your changes)
356 nothing to commit (use -u to show untracked files)
358 git status --untracked-files=no >actual &&
359 test_i18ncmp expected actual
363 test_expect_success 'status: (amend first edit) second edit and split' '
364 git reset --hard several_edits &&
365 FAKE_LINES="edit 1 edit 2 3" &&
366 export FAKE_LINES &&
367 test_when_finished "git rebase --abort" &&
368 ONTO=$(git rev-parse --short HEAD~3) &&
369 git rebase -i HEAD~3 &&
370 git commit --amend -m "b" &&
371 git rebase --continue &&
372 git reset HEAD^ &&
373 cat >expected <<-EOF &&
374 # Not currently on any branch.
375 # You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
376 # (Once your working directory is clean, run "git rebase --continue")
378 # Changes not staged for commit:
379 # (use "git add <file>..." to update what will be committed)
380 # (use "git checkout -- <file>..." to discard changes in working directory)
382 # modified: main.txt
384 no changes added to commit (use "git add" and/or "git commit -a")
386 git status --untracked-files=no >actual &&
387 test_i18ncmp expected actual
391 test_expect_success 'status: (amend first edit) second edit and amend' '
392 git reset --hard several_edits &&
393 FAKE_LINES="edit 1 edit 2 3" &&
394 export FAKE_LINES &&
395 test_when_finished "git rebase --abort" &&
396 ONTO=$(git rev-parse --short HEAD~3) &&
397 git rebase -i HEAD~3 &&
398 git commit --amend -m "c" &&
399 git rebase --continue &&
400 git commit --amend -m "d" &&
401 cat >expected <<-EOF &&
402 # Not currently on any branch.
403 # You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
404 # (use "git commit --amend" to amend the current commit)
405 # (use "git rebase --continue" once you are satisfied with your changes)
407 nothing to commit (use -u to show untracked files)
409 git status --untracked-files=no >actual &&
410 test_i18ncmp expected actual
414 test_expect_success 'status: (split first edit) second edit' '
415 git reset --hard several_edits &&
416 FAKE_LINES="edit 1 edit 2 3" &&
417 export FAKE_LINES &&
418 test_when_finished "git rebase --abort" &&
419 ONTO=$(git rev-parse --short HEAD~3) &&
420 git rebase -i HEAD~3 &&
421 git reset HEAD^ &&
422 git add main.txt &&
423 git commit -m "e" &&
424 git rebase --continue &&
425 cat >expected <<-EOF &&
426 # Not currently on any branch.
427 # You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
428 # (use "git commit --amend" to amend the current commit)
429 # (use "git rebase --continue" once you are satisfied with your changes)
431 nothing to commit (use -u to show untracked files)
433 git status --untracked-files=no >actual &&
434 test_i18ncmp expected actual
438 test_expect_success 'status: (split first edit) second edit and split' '
439 git reset --hard several_edits &&
440 FAKE_LINES="edit 1 edit 2 3" &&
441 export FAKE_LINES &&
442 test_when_finished "git rebase --abort" &&
443 ONTO=$(git rev-parse --short HEAD~3) &&
444 git rebase -i HEAD~3 &&
445 git reset HEAD^ &&
446 git add main.txt &&
447 git commit --amend -m "f" &&
448 git rebase --continue &&
449 git reset HEAD^ &&
450 cat >expected <<-EOF &&
451 # Not currently on any branch.
452 # You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
453 # (Once your working directory is clean, run "git rebase --continue")
455 # Changes not staged for commit:
456 # (use "git add <file>..." to update what will be committed)
457 # (use "git checkout -- <file>..." to discard changes in working directory)
459 # modified: main.txt
461 no changes added to commit (use "git add" and/or "git commit -a")
463 git status --untracked-files=no >actual &&
464 test_i18ncmp expected actual
468 test_expect_success 'status: (split first edit) second edit and amend' '
469 git reset --hard several_edits &&
470 FAKE_LINES="edit 1 edit 2 3" &&
471 export FAKE_LINES &&
472 test_when_finished "git rebase --abort" &&
473 ONTO=$(git rev-parse --short HEAD~3) &&
474 git rebase -i HEAD~3 &&
475 git reset HEAD^ &&
476 git add main.txt &&
477 git commit --amend -m "g" &&
478 git rebase --continue &&
479 git commit --amend -m "h" &&
480 cat >expected <<-EOF &&
481 # Not currently on any branch.
482 # You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
483 # (use "git commit --amend" to amend the current commit)
484 # (use "git rebase --continue" once you are satisfied with your changes)
486 nothing to commit (use -u to show untracked files)
488 git status --untracked-files=no >actual &&
489 test_i18ncmp expected actual
493 test_expect_success 'prepare am_session' '
494 git reset --hard master &&
495 git checkout -b am_session &&
496 test_commit one_am one.txt "one" &&
497 test_commit two_am two.txt "two" &&
498 test_commit three_am three.txt "three"
502 test_expect_success 'status in an am session: file already exists' '
503 git checkout -b am_already_exists &&
504 test_when_finished "rm Maildir/* && git am --abort" &&
505 git format-patch -1 -oMaildir &&
506 test_must_fail git am Maildir/*.patch &&
507 cat >expected <<-\EOF &&
508 # On branch am_already_exists
509 # You are in the middle of an am session.
510 # (fix conflicts and then run "git am --resolved")
511 # (use "git am --skip" to skip this patch)
512 # (use "git am --abort" to restore the original branch)
514 nothing to commit (use -u to show untracked files)
516 git status --untracked-files=no >actual &&
517 test_i18ncmp expected actual
521 test_expect_success 'status in an am session: file does not exist' '
522 git reset --hard am_session &&
523 git checkout -b am_not_exists &&
524 git rm three.txt &&
525 git commit -m "delete three.txt" &&
526 test_when_finished "rm Maildir/* && git am --abort" &&
527 git format-patch -1 -oMaildir &&
528 test_must_fail git am Maildir/*.patch &&
529 cat >expected <<-\EOF &&
530 # On branch am_not_exists
531 # You are in the middle of an am session.
532 # (fix conflicts and then run "git am --resolved")
533 # (use "git am --skip" to skip this patch)
534 # (use "git am --abort" to restore the original branch)
536 nothing to commit (use -u to show untracked files)
538 git status --untracked-files=no >actual &&
539 test_i18ncmp expected actual
543 test_expect_success 'status in an am session: empty patch' '
544 git reset --hard am_session &&
545 git checkout -b am_empty &&
546 test_when_finished "rm Maildir/* && git am --abort" &&
547 git format-patch -3 -oMaildir &&
548 git rm one.txt two.txt three.txt &&
549 git commit -m "delete all am_empty" &&
550 echo error >Maildir/0002-two_am.patch &&
551 test_must_fail git am Maildir/*.patch &&
552 cat >expected <<-\EOF &&
553 # On branch am_empty
554 # You are in the middle of an am session.
555 # The current patch is empty.
556 # (use "git am --skip" to skip this patch)
557 # (use "git am --abort" to restore the original branch)
559 nothing to commit (use -u to show untracked files)
561 git status --untracked-files=no >actual &&
562 test_i18ncmp expected actual
566 test_expect_success 'status when bisecting' '
567 git reset --hard master &&
568 git checkout -b bisect &&
569 test_commit one_bisect main.txt one &&
570 test_commit two_bisect main.txt two &&
571 test_commit three_bisect main.txt three &&
572 test_when_finished "git bisect reset" &&
573 git bisect start &&
574 git bisect bad &&
575 git bisect good one_bisect &&
576 cat >expected <<-\EOF &&
577 # Not currently on any branch.
578 # You are currently bisecting branch '\''bisect'\''.
579 # (use "git bisect reset" to get back to the original branch)
581 nothing to commit (use -u to show untracked files)
583 git status --untracked-files=no >actual &&
584 test_i18ncmp expected actual
588 test_expect_success 'status when rebase conflicts with statushints disabled' '
589 git reset --hard master &&
590 git checkout -b statushints_disabled &&
591 test_when_finished "git config --local advice.statushints true" &&
592 git config --local advice.statushints false &&
593 test_commit one_statushints main.txt one &&
594 test_commit two_statushints main.txt two &&
595 test_commit three_statushints main.txt three &&
596 test_when_finished "git rebase --abort" &&
597 ONTO=$(git rev-parse --short HEAD^^) &&
598 test_must_fail git rebase HEAD^ --onto HEAD^^ &&
599 cat >expected <<-EOF &&
600 # Not currently on any branch.
601 # You are currently rebasing branch '\''statushints_disabled'\'' on '\''$ONTO'\''.
603 # Unmerged paths:
604 # both modified: main.txt
606 no changes added to commit
608 git status --untracked-files=no >actual &&
609 test_i18ncmp expected actual
613 test_expect_success 'prepare for cherry-pick conflicts' '
614 git reset --hard master &&
615 git checkout -b cherry_branch &&
616 test_commit one_cherry main.txt one &&
617 test_commit two_cherries main.txt two &&
618 git checkout -b cherry_branch_second &&
619 test_commit second_cherry main.txt second &&
620 git checkout cherry_branch &&
621 test_commit three_cherries main.txt three
625 test_expect_success 'status when cherry-picking before resolving conflicts' '
626 test_when_finished "git cherry-pick --abort" &&
627 test_must_fail git cherry-pick cherry_branch_second &&
628 cat >expected <<-\EOF &&
629 # On branch cherry_branch
630 # You are currently cherry-picking.
631 # (fix conflicts and run "git commit")
633 # Unmerged paths:
634 # (use "git add <file>..." to mark resolution)
636 # both modified: main.txt
638 no changes added to commit (use "git add" and/or "git commit -a")
640 git status --untracked-files=no >actual &&
641 test_i18ncmp expected actual
645 test_expect_success 'status when cherry-picking after resolving conflicts' '
646 git reset --hard cherry_branch &&
647 test_when_finished "git cherry-pick --abort" &&
648 test_must_fail git cherry-pick cherry_branch_second &&
649 echo end >main.txt &&
650 git add main.txt &&
651 cat >expected <<-\EOF &&
652 # On branch cherry_branch
653 # You are currently cherry-picking.
654 # (all conflicts fixed: run "git commit")
656 # Changes to be committed:
658 # modified: main.txt
660 # Untracked files not listed (use -u option to show untracked files)
662 git status --untracked-files=no >actual &&
663 test_i18ncmp expected actual
667 test_done