]> git.ipfire.org Git - thirdparty/git.git/blob - t/t3701-add-interactive.sh
CodingGuidelines: do not ==/!= compare with 0 or '\0' or NULL
[thirdparty/git.git] / t / t3701-add-interactive.sh
1 #!/bin/sh
2
3 test_description='add -i basic tests'
4 . ./test-lib.sh
5 . "$TEST_DIRECTORY"/lib-terminal.sh
6
7 if ! test_have_prereq PERL
8 then
9 skip_all='skipping add -i tests, perl not available'
10 test_done
11 fi
12
13 diff_cmp () {
14 for x
15 do
16 sed -e '/^index/s/[0-9a-f]*[1-9a-f][0-9a-f]*\.\./1234567../' \
17 -e '/^index/s/\.\.[0-9a-f]*[1-9a-f][0-9a-f]*/..9abcdef/' \
18 -e '/^index/s/ 00*\.\./ 0000000../' \
19 -e '/^index/s/\.\.00*$/..0000000/' \
20 -e '/^index/s/\.\.00* /..0000000 /' \
21 "$x" >"$x.filtered"
22 done
23 test_cmp "$1.filtered" "$2.filtered"
24 }
25
26 # This function uses a trick to manipulate the interactive add to use color:
27 # the `want_color()` function special-cases the situation where a pager was
28 # spawned and Git now wants to output colored text: to detect that situation,
29 # the environment variable `GIT_PAGER_IN_USE` is set. However, color is
30 # suppressed despite that environment variable if the `TERM` variable
31 # indicates a dumb terminal, so we set that variable, too.
32
33 force_color () {
34 env GIT_PAGER_IN_USE=true TERM=vt100 "$@"
35 }
36
37 test_expect_success 'setup (initial)' '
38 echo content >file &&
39 git add file &&
40 echo more >>file &&
41 echo lines >>file
42 '
43 test_expect_success 'status works (initial)' '
44 git add -i </dev/null >output &&
45 grep "+1/-0 *+2/-0 file" output
46 '
47
48 test_expect_success 'setup expected' '
49 cat >expected <<-\EOF
50 new file mode 100644
51 index 0000000..d95f3ad
52 --- /dev/null
53 +++ b/file
54 @@ -0,0 +1 @@
55 +content
56 EOF
57 '
58
59 test_expect_success 'diff works (initial)' '
60 test_write_lines d 1 | git add -i >output &&
61 sed -ne "/new file/,/content/p" <output >diff &&
62 diff_cmp expected diff
63 '
64 test_expect_success 'revert works (initial)' '
65 git add file &&
66 test_write_lines r 1 | git add -i &&
67 git ls-files >output &&
68 ! grep . output
69 '
70
71 test_expect_success 'add untracked (multiple)' '
72 test_when_finished "git reset && rm [1-9]" &&
73 touch $(test_seq 9) &&
74 test_write_lines a "2-5 8-" | git add -i -- [1-9] &&
75 test_write_lines 2 3 4 5 8 9 >expected &&
76 git ls-files [1-9] >output &&
77 test_cmp expected output
78 '
79
80 test_expect_success 'setup (commit)' '
81 echo baseline >file &&
82 git add file &&
83 git commit -m commit &&
84 echo content >>file &&
85 git add file &&
86 echo more >>file &&
87 echo lines >>file
88 '
89 test_expect_success 'status works (commit)' '
90 git add -i </dev/null >output &&
91 grep "+1/-0 *+2/-0 file" output
92 '
93
94 test_expect_success 'setup expected' '
95 cat >expected <<-\EOF
96 index 180b47c..b6f2c08 100644
97 --- a/file
98 +++ b/file
99 @@ -1 +1,2 @@
100 baseline
101 +content
102 EOF
103 '
104
105 test_expect_success 'diff works (commit)' '
106 test_write_lines d 1 | git add -i >output &&
107 sed -ne "/^index/,/content/p" <output >diff &&
108 diff_cmp expected diff
109 '
110 test_expect_success 'revert works (commit)' '
111 git add file &&
112 test_write_lines r 1 | git add -i &&
113 git add -i </dev/null >output &&
114 grep "unchanged *+3/-0 file" output
115 '
116
117 test_expect_success 'setup expected' '
118 cat >expected <<-\EOF
119 EOF
120 '
121
122 test_expect_success 'dummy edit works' '
123 test_set_editor : &&
124 test_write_lines e a | git add -p &&
125 git diff > diff &&
126 diff_cmp expected diff
127 '
128
129 test_expect_success 'setup patch' '
130 cat >patch <<-\EOF
131 @@ -1,1 +1,4 @@
132 this
133 +patch
134 -does not
135 apply
136 EOF
137 '
138
139 test_expect_success 'setup fake editor' '
140 write_script "fake_editor.sh" <<-\EOF &&
141 mv -f "$1" oldpatch &&
142 mv -f patch "$1"
143 EOF
144 test_set_editor "$(pwd)/fake_editor.sh"
145 '
146
147 test_expect_success 'bad edit rejected' '
148 git reset &&
149 test_write_lines e n d | git add -p >output &&
150 grep "hunk does not apply" output
151 '
152
153 test_expect_success 'setup patch' '
154 cat >patch <<-\EOF
155 this patch
156 is garbage
157 EOF
158 '
159
160 test_expect_success 'garbage edit rejected' '
161 git reset &&
162 test_write_lines e n d | git add -p >output &&
163 grep "hunk does not apply" output
164 '
165
166 test_expect_success 'setup patch' '
167 cat >patch <<-\EOF
168 @@ -1,0 +1,0 @@
169 baseline
170 +content
171 +newcontent
172 +lines
173 EOF
174 '
175
176 test_expect_success 'setup expected' '
177 cat >expected <<-\EOF
178 diff --git a/file b/file
179 index b5dd6c9..f910ae9 100644
180 --- a/file
181 +++ b/file
182 @@ -1,4 +1,4 @@
183 baseline
184 content
185 -newcontent
186 +more
187 lines
188 EOF
189 '
190
191 test_expect_success 'real edit works' '
192 test_write_lines e n d | git add -p &&
193 git diff >output &&
194 diff_cmp expected output
195 '
196
197 test_expect_success 'setup file' '
198 test_write_lines a "" b "" c >file &&
199 git add file &&
200 test_write_lines a "" d "" c >file
201 '
202
203 test_expect_success 'setup patch' '
204 SP=" " &&
205 NULL="" &&
206 cat >patch <<-EOF
207 @@ -1,4 +1,4 @@
208 a
209 $NULL
210 -b
211 +f
212 $SP
213 c
214 EOF
215 '
216
217 test_expect_success 'setup expected' '
218 cat >expected <<-EOF
219 diff --git a/file b/file
220 index b5dd6c9..f910ae9 100644
221 --- a/file
222 +++ b/file
223 @@ -1,5 +1,5 @@
224 a
225 $SP
226 -f
227 +d
228 $SP
229 c
230 EOF
231 '
232
233 test_expect_success 'edit can strip spaces from empty context lines' '
234 test_write_lines e n q | git add -p 2>error &&
235 test_must_be_empty error &&
236 git diff >output &&
237 diff_cmp expected output
238 '
239
240 test_expect_success 'skip files similarly as commit -a' '
241 git reset &&
242 echo file >.gitignore &&
243 echo changed >file &&
244 echo y | git add -p file &&
245 git diff >output &&
246 git reset &&
247 git commit -am commit &&
248 git diff >expected &&
249 diff_cmp expected output &&
250 git reset --hard HEAD^
251 '
252 rm -f .gitignore
253
254 test_expect_success FILEMODE 'patch does not affect mode' '
255 git reset --hard &&
256 echo content >>file &&
257 chmod +x file &&
258 printf "n\\ny\\n" | git add -p &&
259 git show :file | grep content &&
260 git diff file | grep "new mode"
261 '
262
263 test_expect_success FILEMODE 'stage mode but not hunk' '
264 git reset --hard &&
265 echo content >>file &&
266 chmod +x file &&
267 printf "y\\nn\\n" | git add -p &&
268 git diff --cached file | grep "new mode" &&
269 git diff file | grep "+content"
270 '
271
272
273 test_expect_success FILEMODE 'stage mode and hunk' '
274 git reset --hard &&
275 echo content >>file &&
276 chmod +x file &&
277 printf "y\\ny\\n" | git add -p &&
278 git diff --cached file | grep "new mode" &&
279 git diff --cached file | grep "+content" &&
280 test -z "$(git diff file)"
281 '
282
283 # end of tests disabled when filemode is not usable
284
285 test_expect_success 'different prompts for mode change/deleted' '
286 git reset --hard &&
287 >file &&
288 >deleted &&
289 git add --chmod=+x file deleted &&
290 echo changed >file &&
291 rm deleted &&
292 test_write_lines n n n |
293 git -c core.filemode=true add -p >actual &&
294 sed -n "s/^\(([0-9/]*) Stage .*?\).*/\1/p" actual >actual.filtered &&
295 cat >expect <<-\EOF &&
296 (1/1) Stage deletion [y,n,q,a,d,?]?
297 (1/2) Stage mode change [y,n,q,a,d,j,J,g,/,?]?
298 (2/2) Stage this hunk [y,n,q,a,d,K,g,/,e,?]?
299 EOF
300 test_cmp expect actual.filtered
301 '
302
303 test_expect_success 'correct message when there is nothing to do' '
304 git reset --hard &&
305 git add -p 2>err &&
306 test_i18ngrep "No changes" err &&
307 printf "\\0123" >binary &&
308 git add binary &&
309 printf "\\0abc" >binary &&
310 git add -p 2>err &&
311 test_i18ngrep "Only binary files changed" err
312 '
313
314 test_expect_success 'setup again' '
315 git reset --hard &&
316 test_chmod +x file &&
317 echo content >>file
318 '
319
320 # Write the patch file with a new line at the top and bottom
321 test_expect_success 'setup patch' '
322 cat >patch <<-\EOF
323 index 180b47c..b6f2c08 100644
324 --- a/file
325 +++ b/file
326 @@ -1,2 +1,4 @@
327 +firstline
328 baseline
329 content
330 +lastline
331 \ No newline at end of file
332 EOF
333 '
334
335 # Expected output, diff is similar to the patch but w/ diff at the top
336 test_expect_success 'setup expected' '
337 echo diff --git a/file b/file >expected &&
338 cat patch |sed "/^index/s/ 100644/ 100755/" >>expected &&
339 cat >expected-output <<-\EOF
340 --- a/file
341 +++ b/file
342 @@ -1,2 +1,4 @@
343 +firstline
344 baseline
345 content
346 +lastline
347 \ No newline at end of file
348 @@ -1,2 +1,3 @@
349 +firstline
350 baseline
351 content
352 @@ -1,2 +2,3 @@
353 baseline
354 content
355 +lastline
356 \ No newline at end of file
357 EOF
358 '
359
360 # Test splitting the first patch, then adding both
361 test_expect_success C_LOCALE_OUTPUT 'add first line works' '
362 git commit -am "clear local changes" &&
363 git apply patch &&
364 printf "%s\n" s y y | git add -p file 2>error |
365 sed -n -e "s/^([1-2]\/[1-2]) Stage this hunk[^@]*\(@@ .*\)/\1/" \
366 -e "/^[-+@ \\\\]"/p >output &&
367 test_must_be_empty error &&
368 git diff --cached >diff &&
369 diff_cmp expected diff &&
370 test_cmp expected-output output
371 '
372
373 test_expect_success 'setup expected' '
374 cat >expected <<-\EOF
375 diff --git a/non-empty b/non-empty
376 deleted file mode 100644
377 index d95f3ad..0000000
378 --- a/non-empty
379 +++ /dev/null
380 @@ -1 +0,0 @@
381 -content
382 EOF
383 '
384
385 test_expect_success 'deleting a non-empty file' '
386 git reset --hard &&
387 echo content >non-empty &&
388 git add non-empty &&
389 git commit -m non-empty &&
390 rm non-empty &&
391 echo y | git add -p non-empty &&
392 git diff --cached >diff &&
393 diff_cmp expected diff
394 '
395
396 test_expect_success 'setup expected' '
397 cat >expected <<-\EOF
398 diff --git a/empty b/empty
399 deleted file mode 100644
400 index e69de29..0000000
401 EOF
402 '
403
404 test_expect_success 'deleting an empty file' '
405 git reset --hard &&
406 > empty &&
407 git add empty &&
408 git commit -m empty &&
409 rm empty &&
410 echo y | git add -p empty &&
411 git diff --cached >diff &&
412 diff_cmp expected diff
413 '
414
415 test_expect_success 'split hunk setup' '
416 git reset --hard &&
417 test_write_lines 10 20 30 40 50 60 >test &&
418 git add test &&
419 test_tick &&
420 git commit -m test &&
421
422 test_write_lines 10 15 20 21 22 23 24 30 40 50 60 >test
423 '
424
425 test_expect_success 'goto hunk' '
426 test_when_finished "git reset" &&
427 tr _ " " >expect <<-EOF &&
428 (2/2) Stage this hunk [y,n,q,a,d,K,g,/,e,?]? + 1: -1,2 +1,3 +15
429 _ 2: -2,4 +3,8 +21
430 go to which hunk? @@ -1,2 +1,3 @@
431 _10
432 +15
433 _20
434 (1/2) Stage this hunk [y,n,q,a,d,j,J,g,/,e,?]?_
435 EOF
436 test_write_lines s y g 1 | git add -p >actual &&
437 tail -n 7 <actual >actual.trimmed &&
438 test_cmp expect actual.trimmed
439 '
440
441 test_expect_success 'navigate to hunk via regex' '
442 test_when_finished "git reset" &&
443 tr _ " " >expect <<-EOF &&
444 (2/2) Stage this hunk [y,n,q,a,d,K,g,/,e,?]? @@ -1,2 +1,3 @@
445 _10
446 +15
447 _20
448 (1/2) Stage this hunk [y,n,q,a,d,j,J,g,/,e,?]?_
449 EOF
450 test_write_lines s y /1,2 | git add -p >actual &&
451 tail -n 5 <actual >actual.trimmed &&
452 test_cmp expect actual.trimmed
453 '
454
455 test_expect_success 'split hunk "add -p (edit)"' '
456 # Split, say Edit and do nothing. Then:
457 #
458 # 1. Broken version results in a patch that does not apply and
459 # only takes [y/n] (edit again) so the first q is discarded
460 # and then n attempts to discard the edit. Repeat q enough
461 # times to get out.
462 #
463 # 2. Correct version applies the (not)edited version, and asks
464 # about the next hunk, against which we say q and program
465 # exits.
466 printf "%s\n" s e q n q q |
467 EDITOR=: git add -p &&
468 git diff >actual &&
469 ! grep "^+15" actual
470 '
471
472 test_expect_failure 'split hunk "add -p (no, yes, edit)"' '
473 test_write_lines 5 10 20 21 30 31 40 50 60 >test &&
474 git reset &&
475 # test sequence is s(plit), n(o), y(es), e(dit)
476 # q n q q is there to make sure we exit at the end.
477 printf "%s\n" s n y e q n q q |
478 EDITOR=: git add -p 2>error &&
479 test_must_be_empty error &&
480 git diff >actual &&
481 ! grep "^+31" actual
482 '
483
484 test_expect_success 'split hunk with incomplete line at end' '
485 git reset --hard &&
486 printf "missing LF" >>test &&
487 git add test &&
488 test_write_lines before 10 20 30 40 50 60 70 >test &&
489 git grep --cached missing &&
490 test_write_lines s n y q | git add -p &&
491 test_must_fail git grep --cached missing &&
492 git grep before &&
493 test_must_fail git grep --cached before
494 '
495
496 test_expect_failure 'edit, adding lines to the first hunk' '
497 test_write_lines 10 11 20 30 40 50 51 60 >test &&
498 git reset &&
499 tr _ " " >patch <<-EOF &&
500 @@ -1,5 +1,6 @@
501 _10
502 +11
503 +12
504 _20
505 +21
506 +22
507 _30
508 EOF
509 # test sequence is s(plit), e(dit), n(o)
510 # q n q q is there to make sure we exit at the end.
511 printf "%s\n" s e n q n q q |
512 EDITOR=./fake_editor.sh git add -p 2>error &&
513 test_must_be_empty error &&
514 git diff --cached >actual &&
515 grep "^+22" actual
516 '
517
518 test_expect_success 'patch mode ignores unmerged entries' '
519 git reset --hard &&
520 test_commit conflict &&
521 test_commit non-conflict &&
522 git checkout -b side &&
523 test_commit side conflict.t &&
524 git checkout master &&
525 test_commit master conflict.t &&
526 test_must_fail git merge side &&
527 echo changed >non-conflict.t &&
528 echo y | git add -p >output &&
529 ! grep a/conflict.t output &&
530 cat >expected <<-\EOF &&
531 * Unmerged path conflict.t
532 diff --git a/non-conflict.t b/non-conflict.t
533 index f766221..5ea2ed4 100644
534 --- a/non-conflict.t
535 +++ b/non-conflict.t
536 @@ -1 +1 @@
537 -non-conflict
538 +changed
539 EOF
540 git diff --cached >diff &&
541 diff_cmp expected diff
542 '
543
544 test_expect_success 'diffs can be colorized' '
545 git reset --hard &&
546
547 echo content >test &&
548 printf y >y &&
549 force_color git add -p >output 2>&1 <y &&
550
551 # We do not want to depend on the exact coloring scheme
552 # git uses for diffs, so just check that we saw some kind of color.
553 grep "$(printf "\\033")" output
554 '
555
556 test_expect_success 'colorized diffs respect diff.wsErrorHighlight' '
557 git reset --hard &&
558
559 echo "old " >test &&
560 git add test &&
561 echo "new " >test &&
562
563 printf y >y &&
564 force_color git -c diff.wsErrorHighlight=all add -p >output.raw 2>&1 <y &&
565 test_decode_color <output.raw >output &&
566 grep "old<" output
567 '
568
569 test_expect_success 'diffFilter filters diff' '
570 git reset --hard &&
571
572 echo content >test &&
573 test_config interactive.diffFilter "sed s/^/foo:/" &&
574 printf y >y &&
575 force_color git add -p >output 2>&1 <y &&
576
577 # avoid depending on the exact coloring or content of the prompts,
578 # and just make sure we saw our diff prefixed
579 grep foo:.*content output
580 '
581
582 test_expect_success 'detect bogus diffFilter output' '
583 git reset --hard &&
584
585 echo content >test &&
586 test_config interactive.diffFilter "sed 1d" &&
587 printf y >y &&
588 test_must_fail force_color git add -p <y
589 '
590
591 test_expect_success 'diff.algorithm is passed to `git diff-files`' '
592 git reset --hard &&
593
594 >file &&
595 git add file &&
596 echo changed >file &&
597 test_must_fail git -c diff.algorithm=bogus add -p 2>err &&
598 test_i18ngrep "error: option diff-algorithm accepts " err
599 '
600
601 test_expect_success 'patch-mode via -i prompts for files' '
602 git reset --hard &&
603
604 echo one >file &&
605 echo two >test &&
606 git add -i <<-\EOF &&
607 patch
608 test
609
610 y
611 quit
612 EOF
613
614 echo test >expect &&
615 git diff --cached --name-only >actual &&
616 diff_cmp expect actual
617 '
618
619 test_expect_success 'add -p handles globs' '
620 git reset --hard &&
621
622 mkdir -p subdir &&
623 echo base >one.c &&
624 echo base >subdir/two.c &&
625 git add "*.c" &&
626 git commit -m base &&
627
628 echo change >one.c &&
629 echo change >subdir/two.c &&
630 git add -p "*.c" <<-\EOF &&
631 y
632 y
633 EOF
634
635 cat >expect <<-\EOF &&
636 one.c
637 subdir/two.c
638 EOF
639 git diff --cached --name-only >actual &&
640 test_cmp expect actual
641 '
642
643 test_expect_success 'add -p handles relative paths' '
644 git reset --hard &&
645
646 echo base >relpath.c &&
647 git add "*.c" &&
648 git commit -m relpath &&
649
650 echo change >relpath.c &&
651 mkdir -p subdir &&
652 git -C subdir add -p .. 2>error <<-\EOF &&
653 y
654 EOF
655
656 test_must_be_empty error &&
657
658 cat >expect <<-\EOF &&
659 relpath.c
660 EOF
661 git diff --cached --name-only >actual &&
662 test_cmp expect actual
663 '
664
665 test_expect_success 'add -p does not expand argument lists' '
666 git reset --hard &&
667
668 echo content >not-changed &&
669 git add not-changed &&
670 git commit -m "add not-changed file" &&
671
672 echo change >file &&
673 GIT_TRACE=$(pwd)/trace.out git add -p . <<-\EOF &&
674 y
675 EOF
676
677 # we know that "file" must be mentioned since we actually
678 # update it, but we want to be sure that our "." pathspec
679 # was not expanded into the argument list of any command.
680 # So look only for "not-changed".
681 ! grep -E "^trace: (built-in|exec|run_command): .*not-changed" trace.out
682 '
683
684 test_expect_success 'hunk-editing handles custom comment char' '
685 git reset --hard &&
686 echo change >>file &&
687 test_config core.commentChar "\$" &&
688 echo e | GIT_EDITOR=true git add -p &&
689 git diff --exit-code
690 '
691
692 test_expect_success 'add -p works even with color.ui=always' '
693 git reset --hard &&
694 echo change >>file &&
695 test_config color.ui always &&
696 echo y | git add -p &&
697 echo file >expect &&
698 git diff --cached --name-only >actual &&
699 test_cmp expect actual
700 '
701
702 test_expect_success 'setup different kinds of dirty submodules' '
703 test_create_repo for-submodules &&
704 (
705 cd for-submodules &&
706 test_commit initial &&
707 test_create_repo dirty-head &&
708 (
709 cd dirty-head &&
710 test_commit initial
711 ) &&
712 cp -R dirty-head dirty-otherwise &&
713 cp -R dirty-head dirty-both-ways &&
714 git add dirty-head &&
715 git add dirty-otherwise dirty-both-ways &&
716 git commit -m initial &&
717
718 cd dirty-head &&
719 test_commit updated &&
720 cd ../dirty-both-ways &&
721 test_commit updated &&
722 echo dirty >>initial &&
723 : >untracked &&
724 cd ../dirty-otherwise &&
725 echo dirty >>initial &&
726 : >untracked
727 ) &&
728 git -C for-submodules diff-files --name-only >actual &&
729 cat >expected <<-\EOF &&
730 dirty-both-ways
731 dirty-head
732 dirty-otherwise
733 EOF
734 test_cmp expected actual &&
735 git -C for-submodules diff-files --name-only --ignore-submodules=dirty >actual &&
736 cat >expected <<-\EOF &&
737 dirty-both-ways
738 dirty-head
739 EOF
740 test_cmp expected actual
741 '
742
743 test_expect_success 'status ignores dirty submodules (except HEAD)' '
744 git -C for-submodules add -i </dev/null >output &&
745 grep dirty-head output &&
746 grep dirty-both-ways output &&
747 ! grep dirty-otherwise output
748 '
749
750 test_expect_success 'set up pathological context' '
751 git reset --hard &&
752 test_write_lines a a a a a a a a a a a >a &&
753 git add a &&
754 git commit -m a &&
755 test_write_lines c b a a a a a a a b a a a a >a &&
756 test_write_lines a a a a a a a b a a a a >expected-1 &&
757 test_write_lines b a a a a a a a b a a a a >expected-2 &&
758 # check editing can cope with missing header and deleted context lines
759 # as well as changes to other lines
760 test_write_lines +b " a" >patch
761 '
762
763 test_expect_success 'add -p works with pathological context lines' '
764 git reset &&
765 printf "%s\n" n y |
766 git add -p &&
767 git cat-file blob :a >actual &&
768 test_cmp expected-1 actual
769 '
770
771 test_expect_success 'add -p patch editing works with pathological context lines' '
772 git reset &&
773 # n q q below is in case edit fails
774 printf "%s\n" e y n q q |
775 git add -p &&
776 git cat-file blob :a >actual &&
777 test_cmp expected-2 actual
778 '
779
780 test_expect_success 'checkout -p works with pathological context lines' '
781 test_write_lines a a a a a a >a &&
782 git add a &&
783 test_write_lines a b a b a b a b a b a > a&&
784 test_write_lines s n n y q | git checkout -p &&
785 test_write_lines a b a b a a b a b a >expect &&
786 test_cmp expect a
787 '
788
789 test_expect_success 'show help from add--helper' '
790 git reset --hard &&
791 cat >expect <<-EOF &&
792
793 <BOLD>*** Commands ***<RESET>
794 1: <BOLD;BLUE>s<RESET>tatus 2: <BOLD;BLUE>u<RESET>pdate 3: <BOLD;BLUE>r<RESET>evert 4: <BOLD;BLUE>a<RESET>dd untracked
795 5: <BOLD;BLUE>p<RESET>atch 6: <BOLD;BLUE>d<RESET>iff 7: <BOLD;BLUE>q<RESET>uit 8: <BOLD;BLUE>h<RESET>elp
796 <BOLD;BLUE>What now<RESET>> <BOLD;RED>status - show paths with changes<RESET>
797 <BOLD;RED>update - add working tree state to the staged set of changes<RESET>
798 <BOLD;RED>revert - revert staged set of changes back to the HEAD version<RESET>
799 <BOLD;RED>patch - pick hunks and update selectively<RESET>
800 <BOLD;RED>diff - view diff between HEAD and index<RESET>
801 <BOLD;RED>add untracked - add contents of untracked files to the staged set of changes<RESET>
802 <BOLD>*** Commands ***<RESET>
803 1: <BOLD;BLUE>s<RESET>tatus 2: <BOLD;BLUE>u<RESET>pdate 3: <BOLD;BLUE>r<RESET>evert 4: <BOLD;BLUE>a<RESET>dd untracked
804 5: <BOLD;BLUE>p<RESET>atch 6: <BOLD;BLUE>d<RESET>iff 7: <BOLD;BLUE>q<RESET>uit 8: <BOLD;BLUE>h<RESET>elp
805 <BOLD;BLUE>What now<RESET>>$SP
806 Bye.
807 EOF
808 test_write_lines h | force_color git add -i >actual.colored &&
809 test_decode_color <actual.colored >actual &&
810 test_i18ncmp expect actual
811 '
812
813 test_done