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