3 test_description
='add -i basic tests'
4 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
5 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
8 .
"$TEST_DIRECTORY"/lib-terminal.sh
10 if ! test_have_prereq PERL
12 skip_all
='skipping add -i tests, perl not available'
19 sed -e '/^index/s/[0-9a-f]*[1-9a-f][0-9a-f]*\.\./1234567../' \
20 -e '/^index/s/\.\.[0-9a-f]*[1-9a-f][0-9a-f]*/..9abcdef/' \
21 -e '/^index/s/ 00*\.\./ 0000000../' \
22 -e '/^index/s/\.\.00*$/..0000000/' \
23 -e '/^index/s/\.\.00* /..0000000 /' \
26 test_cmp
"$1.filtered" "$2.filtered"
29 # This function uses a trick to manipulate the interactive add to use color:
30 # the `want_color()` function special-cases the situation where a pager was
31 # spawned and Git now wants to output colored text: to detect that situation,
32 # the environment variable `GIT_PAGER_IN_USE` is set. However, color is
33 # suppressed despite that environment variable if the `TERM` variable
34 # indicates a dumb terminal, so we set that variable, too.
37 # The first element of $@ may be a shell function, as a result POSIX
38 # does not guarantee that "one-shot assignment" will not persist after
39 # the function call. Thus, we prevent these variables from escaping
40 # this function's context with this subshell.
42 GIT_PAGER_IN_USE
=true
&&
44 export GIT_PAGER_IN_USE TERM
&&
49 test_expect_success
'setup (initial)' '
55 test_expect_success
'status works (initial)' '
56 git add -i </dev/null >output &&
57 grep "+1/-0 *+2/-0 file" output
60 test_expect_success
'setup expected' '
63 index 0000000..d95f3ad
71 test_expect_success
'diff works (initial)' '
72 test_write_lines d 1 | git add -i >output &&
73 sed -ne "/new file/,/content/p" <output >diff &&
74 diff_cmp expected diff
76 test_expect_success
'revert works (initial)' '
78 test_write_lines r 1 | git add -i &&
79 git ls-files >output &&
83 test_expect_success
'add untracked (multiple)' '
84 test_when_finished "git reset && rm [1-9]" &&
85 touch $(test_seq 9) &&
86 test_write_lines a "2-5 8-" | git add -i -- [1-9] &&
87 test_write_lines 2 3 4 5 8 9 >expected &&
88 git ls-files [1-9] >output &&
89 test_cmp expected output
92 test_expect_success
'setup (commit)' '
93 echo baseline >file &&
95 git commit -m commit &&
96 echo content >>file &&
101 test_expect_success
'status works (commit)' '
102 git add -i </dev/null >output &&
103 grep "+1/-0 *+2/-0 file" output
106 test_expect_success
'setup expected' '
107 cat >expected <<-\EOF
108 index 180b47c..b6f2c08 100644
117 test_expect_success
'diff works (commit)' '
118 test_write_lines d 1 | git add -i >output &&
119 sed -ne "/^index/,/content/p" <output >diff &&
120 diff_cmp expected diff
122 test_expect_success
'revert works (commit)' '
124 test_write_lines r 1 | git add -i &&
125 git add -i </dev/null >output &&
126 grep "unchanged *+3/-0 file" output
129 test_expect_success
'setup expected' '
130 cat >expected <<-\EOF
134 test_expect_success
'dummy edit works' '
136 test_write_lines e a | git add -p &&
138 diff_cmp expected diff
141 test_expect_success
'setup patch' '
151 test_expect_success
'setup fake editor' '
152 write_script "fake_editor.sh" <<-\EOF &&
153 mv -f "$1" oldpatch &&
156 test_set_editor "$(pwd)/fake_editor.sh"
159 test_expect_success
'bad edit rejected' '
161 test_write_lines e n d | git add -p >output &&
162 grep "hunk does not apply" output
165 test_expect_success
'setup patch' '
172 test_expect_success
'garbage edit rejected' '
174 test_write_lines e n d | git add -p >output &&
175 grep "hunk does not apply" output
178 test_expect_success
'setup patch' '
188 test_expect_success
'setup expected' '
189 cat >expected <<-\EOF
190 diff --git a/file b/file
191 index b5dd6c9..f910ae9 100644
203 test_expect_success
'real edit works' '
204 test_write_lines e n d | git add -p &&
206 diff_cmp expected output
209 test_expect_success
'setup file' '
210 test_write_lines a "" b "" c >file &&
212 test_write_lines a "" d "" c >file
215 test_expect_success
'setup patch' '
229 test_expect_success
'setup expected' '
231 diff --git a/file b/file
232 index b5dd6c9..f910ae9 100644
245 test_expect_success
'edit can strip spaces from empty context lines' '
246 test_write_lines e n q | git add -p 2>error &&
247 test_must_be_empty error &&
249 diff_cmp expected output
252 test_expect_success
'skip files similarly as commit -a' '
254 echo file >.gitignore &&
255 echo changed >file &&
256 echo y | git add -p file &&
259 git commit -am commit &&
260 git diff >expected &&
261 diff_cmp expected output &&
262 git reset --hard HEAD^
266 test_expect_success FILEMODE
'patch does not affect mode' '
268 echo content >>file &&
270 printf "n\\ny\\n" | git add -p &&
271 git show :file | grep content &&
272 git diff file | grep "new mode"
275 test_expect_success FILEMODE
'stage mode but not hunk' '
277 echo content >>file &&
279 printf "y\\nn\\n" | git add -p &&
280 git diff --cached file | grep "new mode" &&
281 git diff file | grep "+content"
285 test_expect_success FILEMODE
'stage mode and hunk' '
287 echo content >>file &&
289 printf "y\\ny\\n" | git add -p &&
290 git diff --cached file | grep "new mode" &&
291 git diff --cached file | grep "+content" &&
292 test -z "$(git diff file)"
295 # end of tests disabled when filemode is not usable
297 test_expect_success
'different prompts for mode change/deleted' '
301 git add --chmod=+x file deleted &&
302 echo changed >file &&
304 test_write_lines n n n |
305 git -c core.filemode=true add -p >actual &&
306 sed -n "s/^\(([0-9/]*) Stage .*?\).*/\1/p" actual >actual.filtered &&
307 cat >expect <<-\EOF &&
308 (1/1) Stage deletion [y,n,q,a,d,?]?
309 (1/2) Stage mode change [y,n,q,a,d,j,J,g,/,?]?
310 (2/2) Stage this hunk [y,n,q,a,d,K,g,/,e,?]?
312 test_cmp expect actual.filtered
315 test_expect_success
'correct message when there is nothing to do' '
318 test_i18ngrep "No changes" err &&
319 printf "\\0123" >binary &&
321 printf "\\0abc" >binary &&
323 test_i18ngrep "Only binary files changed" err
326 test_expect_success
'setup again' '
328 test_chmod +x file &&
329 echo content >>file &&
330 test_write_lines A B C D>file2 &&
334 # Write the patch file with a new line at the top and bottom
335 test_expect_success
'setup patch' '
337 index 180b47c..b6f2c08 100644
345 \ No newline at end of file
346 diff --git a/file2 b/file2
347 index 8422d40..35b930a 100644
361 # Expected output, diff is similar to the patch but w/ diff at the top
362 test_expect_success
'setup expected' '
363 echo diff --git a/file b/file >expected &&
364 sed -e "/^index 180b47c/s/ 100644/ 100755/" \
366 -e /Y/d patch >>expected &&
367 cat >expected-output <<-\EOF
375 \ No newline at end of file
384 \ No newline at end of file
410 # Test splitting the first patch, then adding both
411 test_expect_success
'add first line works' '
412 git commit -am "clear local changes" &&
414 test_write_lines s y y s y n y | git add -p 2>error >raw-output &&
415 sed -n -e "s/^([1-9]\/[1-9]) Stage this hunk[^@]*\(@@ .*\)/\1/" \
416 -e "/^[-+@ \\\\]"/p raw-output >output &&
417 test_must_be_empty error &&
418 git diff --cached >diff &&
419 diff_cmp expected diff &&
420 test_cmp expected-output output
423 test_expect_success
'setup expected' '
424 cat >expected <<-\EOF
425 diff --git a/non-empty b/non-empty
426 deleted file mode 100644
427 index d95f3ad..0000000
435 test_expect_success
'deleting a non-empty file' '
437 echo content >non-empty &&
439 git commit -m non-empty &&
441 echo y | git add -p non-empty &&
442 git diff --cached >diff &&
443 diff_cmp expected diff
446 test_expect_success
'setup expected' '
447 cat >expected <<-\EOF
448 diff --git a/empty b/empty
449 deleted file mode 100644
450 index e69de29..0000000
454 test_expect_success
'deleting an empty file' '
458 git commit -m empty &&
460 echo y | git add -p empty &&
461 git diff --cached >diff &&
462 diff_cmp expected diff
465 test_expect_success
'adding an empty file' '
469 test_commit initial &&
473 git commit -m empty &&
474 git tag added-file &&
475 git reset --hard HEAD^ &&
476 test_path_is_missing empty &&
478 echo y | git checkout -p added-file -- >actual &&
479 test_path_is_file empty &&
480 test_i18ngrep "Apply addition to index and worktree" actual
484 test_expect_success
'split hunk setup' '
486 test_write_lines 10 20 30 40 50 60 >test &&
489 git commit -m test &&
491 test_write_lines 10 15 20 21 22 23 24 30 40 50 60 >test
494 test_expect_success
'goto hunk' '
495 test_when_finished "git reset" &&
496 tr _ " " >expect <<-EOF &&
497 (2/2) Stage this hunk [y,n,q,a,d,K,g,/,e,?]? + 1: -1,2 +1,3 +15
499 go to which hunk? @@ -1,2 +1,3 @@
503 (1/2) Stage this hunk [y,n,q,a,d,j,J,g,/,e,?]?_
505 test_write_lines s y g 1 | git add -p >actual &&
506 tail -n 7 <actual >actual.trimmed &&
507 test_cmp expect actual.trimmed
510 test_expect_success
'navigate to hunk via regex' '
511 test_when_finished "git reset" &&
512 tr _ " " >expect <<-EOF &&
513 (2/2) Stage this hunk [y,n,q,a,d,K,g,/,e,?]? @@ -1,2 +1,3 @@
517 (1/2) Stage this hunk [y,n,q,a,d,j,J,g,/,e,?]?_
519 test_write_lines s y /1,2 | git add -p >actual &&
520 tail -n 5 <actual >actual.trimmed &&
521 test_cmp expect actual.trimmed
524 test_expect_success
'split hunk "add -p (edit)"' '
525 # Split, say Edit and do nothing. Then:
527 # 1. Broken version results in a patch that does not apply and
528 # only takes [y/n] (edit again) so the first q is discarded
529 # and then n attempts to discard the edit. Repeat q enough
532 # 2. Correct version applies the (not)edited version, and asks
533 # about the next hunk, against which we say q and program
535 printf "%s\n" s e q n q q |
536 EDITOR=: git add -p &&
541 test_expect_failure
'split hunk "add -p (no, yes, edit)"' '
542 test_write_lines 5 10 20 21 30 31 40 50 60 >test &&
544 # test sequence is s(plit), n(o), y(es), e(dit)
545 # q n q q is there to make sure we exit at the end.
546 printf "%s\n" s n y e q n q q |
547 EDITOR=: git add -p 2>error &&
548 test_must_be_empty error &&
553 test_expect_success
'split hunk with incomplete line at end' '
555 printf "missing LF" >>test &&
557 test_write_lines before 10 20 30 40 50 60 70 >test &&
558 git grep --cached missing &&
559 test_write_lines s n y q | git add -p &&
560 test_must_fail git grep --cached missing &&
562 test_must_fail git grep --cached before
565 test_expect_failure
'edit, adding lines to the first hunk' '
566 test_write_lines 10 11 20 30 40 50 51 60 >test &&
568 tr _ " " >patch <<-EOF &&
578 # test sequence is s(plit), e(dit), n(o)
579 # q n q q is there to make sure we exit at the end.
580 printf "%s\n" s e n q n q q |
581 EDITOR=./fake_editor.sh git add -p 2>error &&
582 test_must_be_empty error &&
583 git diff --cached >actual &&
587 test_expect_success
'patch mode ignores unmerged entries' '
589 test_commit conflict &&
590 test_commit non-conflict &&
591 git checkout -b side &&
592 test_commit side conflict.t &&
594 test_commit main conflict.t &&
595 test_must_fail git merge side &&
596 echo changed >non-conflict.t &&
597 echo y | git add -p >output &&
598 ! grep a/conflict.t output &&
599 cat >expected <<-\EOF &&
600 * Unmerged path conflict.t
601 diff --git a/non-conflict.t b/non-conflict.t
602 index f766221..5ea2ed4 100644
609 git diff --cached >diff &&
610 diff_cmp expected diff
613 test_expect_success
'index is refreshed after applying patch' '
615 echo content >test &&
616 printf y | git add -p &&
617 git diff-files --exit-code
620 test_expect_success
'diffs can be colorized' '
623 echo content >test &&
625 force_color git add -p >output 2>&1 <y &&
626 git diff-files --exit-code &&
628 # We do not want to depend on the exact coloring scheme
629 # git uses for diffs, so just check that we saw some kind of color.
630 grep "$(printf "\\033")" output
633 test_expect_success
'colors can be overridden' '
635 test_when_finished "git rm -f color-test" &&
636 test_write_lines context old more-context >color-test &&
637 git add color-test &&
638 test_write_lines context new more-context another-one >color-test &&
640 echo trigger an error message >input &&
642 -c color.interactive.error=blue \
643 add -i 2>err.raw <input &&
644 test_decode_color <err.raw >err &&
645 grep "<BLUE>Huh (trigger)?<RESET>" err &&
647 test_write_lines help quit >input &&
649 -c color.interactive.header=red \
650 -c color.interactive.help=green \
651 -c color.interactive.prompt=yellow \
652 add -i >actual.raw <input &&
653 test_decode_color <actual.raw >actual &&
654 cat >expect <<-\EOF &&
655 <RED> staged unstaged path<RESET>
656 1: +3/-0 +2/-1 color-test
658 <RED>*** Commands ***<RESET>
659 1: <YELLOW>s<RESET>tatus 2: <YELLOW>u<RESET>pdate 3: <YELLOW>r<RESET>evert 4: <YELLOW>a<RESET>dd untracked
660 5: <YELLOW>p<RESET>atch 6: <YELLOW>d<RESET>iff 7: <YELLOW>q<RESET>uit 8: <YELLOW>h<RESET>elp
661 <YELLOW>What now<RESET>> <GREEN>status - show paths with changes<RESET>
662 <GREEN>update - add working tree state to the staged set of changes<RESET>
663 <GREEN>revert - revert staged set of changes back to the HEAD version<RESET>
664 <GREEN>patch - pick hunks and update selectively<RESET>
665 <GREEN>diff - view diff between HEAD and index<RESET>
666 <GREEN>add untracked - add contents of untracked files to the staged set of changes<RESET>
667 <RED>*** Commands ***<RESET>
668 1: <YELLOW>s<RESET>tatus 2: <YELLOW>u<RESET>pdate 3: <YELLOW>r<RESET>evert 4: <YELLOW>a<RESET>dd untracked
669 5: <YELLOW>p<RESET>atch 6: <YELLOW>d<RESET>iff 7: <YELLOW>q<RESET>uit 8: <YELLOW>h<RESET>elp
670 <YELLOW>What now<RESET>> Bye.
672 test_cmp expect actual &&
674 : exercise recolor_hunk by editing and then look at the hunk again &&
675 test_write_lines s e K q >input &&
677 -c color.interactive.prompt=yellow \
678 -c color.diff.meta=italic \
679 -c color.diff.frag=magenta \
680 -c color.diff.context=cyan \
681 -c color.diff.old=bold \
682 -c color.diff.new=blue \
683 -c core.editor=touch \
684 add -p >actual.raw <input &&
685 test_decode_color <actual.raw >actual.decoded &&
686 sed "s/index [0-9a-f]*\\.\\.[0-9a-f]* 100644/<INDEX-LINE>/" <actual.decoded >actual &&
687 cat >expect <<-\EOF &&
688 <ITALIC>diff --git a/color-test b/color-test<RESET>
689 <ITALIC><INDEX-LINE><RESET>
690 <ITALIC>--- a/color-test<RESET>
691 <ITALIC>+++ b/color-test<RESET>
692 <MAGENTA>@@ -1,3 +1,4 @@<RESET>
693 <CYAN> context<RESET>
695 <BLUE>+<RESET><BLUE>new<RESET>
696 <CYAN> more-context<RESET>
697 <BLUE>+<RESET><BLUE>another-one<RESET>
698 <YELLOW>(1/1) Stage this hunk [y,n,q,a,d,s,e,?]? <RESET><BOLD>Split into 2 hunks.<RESET>
699 <MAGENTA>@@ -1,3 +1,3 @@<RESET>
700 <CYAN> context<RESET>
702 <BLUE>+<RESET><BLUE>new<RESET>
703 <CYAN> more-context<RESET>
704 <YELLOW>(1/2) Stage this hunk [y,n,q,a,d,j,J,g,/,e,?]? <RESET><MAGENTA>@@ -3 +3,2 @@<RESET>
705 <CYAN> more-context<RESET>
706 <BLUE>+<RESET><BLUE>another-one<RESET>
707 <YELLOW>(2/2) Stage this hunk [y,n,q,a,d,K,g,/,e,?]? <RESET><MAGENTA>@@ -1,3 +1,3 @@<RESET>
708 <CYAN> context<RESET>
711 <CYAN> more-context<RESET>
712 <YELLOW>(1/2) Stage this hunk [y,n,q,a,d,j,J,g,/,e,?]? <RESET>
714 test_cmp expect actual
717 test_expect_success
'colorized diffs respect diff.wsErrorHighlight' '
725 force_color git -c diff.wsErrorHighlight=all add -p >output.raw 2>&1 <y &&
726 test_decode_color <output.raw >output &&
730 test_expect_success
'diffFilter filters diff' '
733 echo content >test &&
734 test_config interactive.diffFilter "sed s/^/foo:/" &&
736 force_color git add -p >output 2>&1 <y &&
738 # avoid depending on the exact coloring or content of the prompts,
739 # and just make sure we saw our diff prefixed
740 grep foo:.*content output
743 test_expect_success
'detect bogus diffFilter output' '
746 echo content >test &&
747 test_config interactive.diffFilter "sed 1d" &&
749 force_color test_must_fail git add -p <y
752 test_expect_success
'diff.algorithm is passed to `git diff-files`' '
757 echo changed >file &&
758 test_must_fail git -c diff.algorithm=bogus add -p 2>err &&
759 test_i18ngrep "error: option diff-algorithm accepts " err
762 test_expect_success
'patch-mode via -i prompts for files' '
767 git add -i <<-\EOF &&
776 git diff --cached --name-only >actual &&
777 diff_cmp expect actual
780 test_expect_success
'add -p handles globs' '
785 echo base >subdir/two.c &&
787 git commit -m base &&
789 echo change >one.c &&
790 echo change >subdir/two.c &&
791 git add -p "*.c" <<-\EOF &&
796 cat >expect <<-\EOF &&
800 git diff --cached --name-only >actual &&
801 test_cmp expect actual
804 test_expect_success
'add -p handles relative paths' '
807 echo base >relpath.c &&
809 git commit -m relpath &&
811 echo change >relpath.c &&
813 git -C subdir add -p .. 2>error <<-\EOF &&
817 test_must_be_empty error &&
819 cat >expect <<-\EOF &&
822 git diff --cached --name-only >actual &&
823 test_cmp expect actual
826 test_expect_success
'add -p does not expand argument lists' '
829 echo content >not-changed &&
830 git add not-changed &&
831 git commit -m "add not-changed file" &&
834 GIT_TRACE=$(pwd)/trace.out git add -p . <<-\EOF &&
838 # we know that "file" must be mentioned since we actually
839 # update it, but we want to be sure that our "." pathspec
840 # was not expanded into the argument list of any command.
841 # So look only for "not-changed".
842 ! grep -E "^trace: (built-in|exec|run_command): .*not-changed" trace.out
845 test_expect_success
'hunk-editing handles custom comment char' '
847 echo change >>file &&
848 test_config core.commentChar "\$" &&
849 echo e | GIT_EDITOR=true git add -p &&
853 test_expect_success
'add -p works even with color.ui=always' '
855 echo change >>file &&
856 test_config color.ui always &&
857 echo y | git add -p &&
859 git diff --cached --name-only >actual &&
860 test_cmp expect actual
863 test_expect_success
'setup different kinds of dirty submodules' '
864 test_create_repo for-submodules &&
867 test_commit initial &&
868 test_create_repo dirty-head &&
873 cp -R dirty-head dirty-otherwise &&
874 cp -R dirty-head dirty-both-ways &&
875 git add dirty-head &&
876 git add dirty-otherwise dirty-both-ways &&
877 git commit -m initial &&
880 test_commit updated &&
881 cd ../dirty-both-ways &&
882 test_commit updated &&
883 echo dirty >>initial &&
885 cd ../dirty-otherwise &&
886 echo dirty >>initial &&
889 git -C for-submodules diff-files --name-only >actual &&
890 cat >expected <<-\EOF &&
894 test_cmp expected actual &&
895 git -C for-submodules diff-files --name-only --ignore-submodules=none >actual &&
896 cat >expected <<-\EOF &&
901 test_cmp expected actual &&
902 git -C for-submodules diff-files --name-only --ignore-submodules=dirty >actual &&
903 cat >expected <<-\EOF &&
907 test_cmp expected actual
910 test_expect_success
'status ignores dirty submodules (except HEAD)' '
911 git -C for-submodules add -i </dev/null >output &&
912 grep dirty-head output &&
913 grep dirty-both-ways output &&
914 ! grep dirty-otherwise output
917 test_expect_success
'set up pathological context' '
919 test_write_lines a a a a a a a a a a a >a &&
922 test_write_lines c b a a a a a a a b a a a a >a &&
923 test_write_lines a a a a a a a b a a a a >expected-1 &&
924 test_write_lines b a a a a a a a b a a a a >expected-2 &&
925 # check editing can cope with missing header and deleted context lines
926 # as well as changes to other lines
927 test_write_lines +b " a" >patch
930 test_expect_success
'add -p works with pathological context lines' '
934 git cat-file blob :a >actual &&
935 test_cmp expected-1 actual
938 test_expect_success
'add -p patch editing works with pathological context lines' '
940 # n q q below is in case edit fails
941 printf "%s\n" e y n q q |
943 git cat-file blob :a >actual &&
944 test_cmp expected-2 actual
947 test_expect_success
'checkout -p works with pathological context lines' '
948 test_write_lines a a a a a a >a &&
950 test_write_lines a b a b a b a b a b a >a &&
951 test_write_lines s n n y q | git checkout -p &&
952 test_write_lines a b a b a a b a b a >expect &&
956 # This should be called from a subshell as it sets a temporary editor
958 write_script new-file-editor.sh
<<-\EOF &&
959 sed /^#/d "$1" >patch &&
960 sed /^+c/d patch >"$1"
962 test_set_editor "$(pwd)/new-file-editor.sh" &&
963 test_write_lines a b c d e f >new-file &&
964 test_write_lines a b d e f >new-file-expect &&
965 test_write_lines "@@ -0,0 +1,6 @@" +a +b +c +d +e +f >patch-expect
968 test_expect_success 'add -N followed by add -p patch editing' '
972 git add -N new-file &&
973 test_write_lines e n q | git add -p &&
974 git cat-file blob :new-file >actual &&
975 test_cmp new-file-expect actual &&
976 test_cmp patch-expect patch
980 test_expect_success 'checkout -p patch editing of added file' '
985 git commit -m "add new file" &&
987 git commit -m "remove new file" &&
988 test_write_lines e n q | git checkout -p HEAD^ &&
989 test_cmp new-file-expect new-file &&
990 test_cmp patch-expect patch
994 test_expect_success 'show help from add--helper' '
996 cat >expect <<-EOF &&
998 <BOLD>*** Commands ***<RESET>
999 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
1000 5: <BOLD;BLUE>p<RESET>atch 6: <BOLD;BLUE>d<RESET>iff 7: <BOLD;BLUE>q<RESET>uit 8: <BOLD;BLUE>h<RESET>elp
1001 <BOLD;BLUE>What now<RESET>> <BOLD;RED>status - show paths with changes
<RESET
>
1002 <BOLD
;RED
>update
- add working tree state to the staged
set of changes
<RESET
>
1003 <BOLD
;RED
>revert
- revert staged
set of changes back to the HEAD version
<RESET
>
1004 <BOLD
;RED
>patch - pick hunks and update selectively
<RESET
>
1005 <BOLD
;RED
>diff - view
diff between HEAD and index
<RESET
>
1006 <BOLD
;RED
>add untracked
- add contents of untracked files to the staged
set of changes
<RESET
>
1007 <BOLD
>*** Commands
***<RESET
>
1008 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
1009 5: <BOLD
;BLUE
>p
<RESET
>atch
6: <BOLD
;BLUE
>d
<RESET
>iff
7: <BOLD
;BLUE
>q
<RESET
>uit
8: <BOLD
;BLUE
>h
<RESET
>elp
1010 <BOLD
;BLUE
>What now
<RESET
>>$SP
1013 test_write_lines h | force_color git add
-i >actual.colored
&&
1014 test_decode_color
<actual.colored
>actual
&&
1015 test_cmp expect actual