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
'update can stage deletions' '
110 test_write_lines u t "" | git add -i &&
111 git ls-files to-delete >output &&
112 test_must_be_empty output
115 test_expect_success
'setup expected' '
116 cat >expected <<-\EOF
117 index 180b47c..b6f2c08 100644
126 test_expect_success
'diff works (commit)' '
127 test_write_lines d 1 | git add -i >output &&
128 sed -ne "/^index/,/content/p" <output >diff &&
129 diff_cmp expected diff
131 test_expect_success
'revert works (commit)' '
133 test_write_lines r 1 | git add -i &&
134 git add -i </dev/null >output &&
135 grep "unchanged *+3/-0 file" output
138 test_expect_success
'setup expected' '
139 cat >expected <<-\EOF
143 test_expect_success
'dummy edit works' '
145 test_write_lines e a | git add -p &&
147 diff_cmp expected diff
150 test_expect_success
'setup patch' '
160 test_expect_success
'setup fake editor' '
161 write_script "fake_editor.sh" <<-\EOF &&
162 mv -f "$1" oldpatch &&
165 test_set_editor "$(pwd)/fake_editor.sh"
168 test_expect_success
'bad edit rejected' '
170 test_write_lines e n d | git add -p >output &&
171 grep "hunk does not apply" output
174 test_expect_success
'setup patch' '
181 test_expect_success
'garbage edit rejected' '
183 test_write_lines e n d | git add -p >output &&
184 grep "hunk does not apply" output
187 test_expect_success
'setup patch' '
197 test_expect_success
'setup expected' '
198 cat >expected <<-\EOF
199 diff --git a/file b/file
200 index b5dd6c9..f910ae9 100644
212 test_expect_success
'real edit works' '
213 test_write_lines e n d | git add -p &&
215 diff_cmp expected output
218 test_expect_success
'setup file' '
219 test_write_lines a "" b "" c >file &&
221 test_write_lines a "" d "" c >file
224 test_expect_success
'setup patch' '
238 test_expect_success
'setup expected' '
240 diff --git a/file b/file
241 index b5dd6c9..f910ae9 100644
254 test_expect_success
'edit can strip spaces from empty context lines' '
255 test_write_lines e n q | git add -p 2>error &&
256 test_must_be_empty error &&
258 diff_cmp expected output
261 test_expect_success
'skip files similarly as commit -a' '
263 echo file >.gitignore &&
264 echo changed >file &&
265 echo y | git add -p file &&
268 git commit -am commit &&
269 git diff >expected &&
270 diff_cmp expected output &&
271 git reset --hard HEAD^
275 test_expect_success FILEMODE
'patch does not affect mode' '
277 echo content >>file &&
279 printf "n\\ny\\n" | git add -p &&
280 git show :file | grep content &&
281 git diff file | grep "new mode"
284 test_expect_success FILEMODE
'stage mode but not hunk' '
286 echo content >>file &&
288 printf "y\\nn\\n" | git add -p &&
289 git diff --cached file | grep "new mode" &&
290 git diff file | grep "+content"
294 test_expect_success FILEMODE
'stage mode and hunk' '
296 echo content >>file &&
298 printf "y\\ny\\n" | git add -p &&
299 git diff --cached file | grep "new mode" &&
300 git diff --cached file | grep "+content" &&
301 test -z "$(git diff file)"
304 # end of tests disabled when filemode is not usable
306 test_expect_success
'different prompts for mode change/deleted' '
310 git add --chmod=+x file deleted &&
311 echo changed >file &&
313 test_write_lines n n n |
314 git -c core.filemode=true add -p >actual &&
315 sed -n "s/^\(([0-9/]*) Stage .*?\).*/\1/p" actual >actual.filtered &&
316 cat >expect <<-\EOF &&
317 (1/1) Stage deletion [y,n,q,a,d,?]?
318 (1/2) Stage mode change [y,n,q,a,d,j,J,g,/,?]?
319 (2/2) Stage this hunk [y,n,q,a,d,K,g,/,e,?]?
321 test_cmp expect actual.filtered
324 test_expect_success
'correct message when there is nothing to do' '
327 test_i18ngrep "No changes" err &&
328 printf "\\0123" >binary &&
330 printf "\\0abc" >binary &&
332 test_i18ngrep "Only binary files changed" err
335 test_expect_success
'setup again' '
337 test_chmod +x file &&
338 echo content >>file &&
339 test_write_lines A B C D>file2 &&
343 # Write the patch file with a new line at the top and bottom
344 test_expect_success
'setup patch' '
346 index 180b47c..b6f2c08 100644
354 \ No newline at end of file
355 diff --git a/file2 b/file2
356 index 8422d40..35b930a 100644
370 # Expected output, diff is similar to the patch but w/ diff at the top
371 test_expect_success
'setup expected' '
372 echo diff --git a/file b/file >expected &&
373 sed -e "/^index 180b47c/s/ 100644/ 100755/" \
375 -e /Y/d patch >>expected &&
376 cat >expected-output <<-\EOF
384 \ No newline at end of file
393 \ No newline at end of file
419 # Test splitting the first patch, then adding both
420 test_expect_success
'add first line works' '
421 git commit -am "clear local changes" &&
423 test_write_lines s y y s y n y | git add -p 2>error >raw-output &&
424 sed -n -e "s/^([1-9]\/[1-9]) Stage this hunk[^@]*\(@@ .*\)/\1/" \
425 -e "/^[-+@ \\\\]"/p raw-output >output &&
426 test_must_be_empty error &&
427 git diff --cached >diff &&
428 diff_cmp expected diff &&
429 test_cmp expected-output output
432 test_expect_success
'setup expected' '
433 cat >expected <<-\EOF
434 diff --git a/non-empty b/non-empty
435 deleted file mode 100644
436 index d95f3ad..0000000
444 test_expect_success
'deleting a non-empty file' '
446 echo content >non-empty &&
448 git commit -m non-empty &&
450 echo y | git add -p non-empty &&
451 git diff --cached >diff &&
452 diff_cmp expected diff
455 test_expect_success
'setup expected' '
456 cat >expected <<-\EOF
457 diff --git a/empty b/empty
458 deleted file mode 100644
459 index e69de29..0000000
463 test_expect_success
'deleting an empty file' '
467 git commit -m empty &&
469 echo y | git add -p empty &&
470 git diff --cached >diff &&
471 diff_cmp expected diff
474 test_expect_success
'adding an empty file' '
478 test_commit initial &&
482 git commit -m empty &&
483 git tag added-file &&
484 git reset --hard HEAD^ &&
485 test_path_is_missing empty &&
487 echo y | git checkout -p added-file -- >actual &&
488 test_path_is_file empty &&
489 test_i18ngrep "Apply addition to index and worktree" actual
493 test_expect_success
'split hunk setup' '
495 test_write_lines 10 20 30 40 50 60 >test &&
498 git commit -m test &&
500 test_write_lines 10 15 20 21 22 23 24 30 40 50 60 >test
503 test_expect_success
'goto hunk' '
504 test_when_finished "git reset" &&
505 tr _ " " >expect <<-EOF &&
506 (2/2) Stage this hunk [y,n,q,a,d,K,g,/,e,?]? + 1: -1,2 +1,3 +15
508 go to which hunk? @@ -1,2 +1,3 @@
512 (1/2) Stage this hunk [y,n,q,a,d,j,J,g,/,e,?]?_
514 test_write_lines s y g 1 | git add -p >actual &&
515 tail -n 7 <actual >actual.trimmed &&
516 test_cmp expect actual.trimmed
519 test_expect_success
'navigate to hunk via regex' '
520 test_when_finished "git reset" &&
521 tr _ " " >expect <<-EOF &&
522 (2/2) Stage this hunk [y,n,q,a,d,K,g,/,e,?]? @@ -1,2 +1,3 @@
526 (1/2) Stage this hunk [y,n,q,a,d,j,J,g,/,e,?]?_
528 test_write_lines s y /1,2 | git add -p >actual &&
529 tail -n 5 <actual >actual.trimmed &&
530 test_cmp expect actual.trimmed
533 test_expect_success
'split hunk "add -p (edit)"' '
534 # Split, say Edit and do nothing. Then:
536 # 1. Broken version results in a patch that does not apply and
537 # only takes [y/n] (edit again) so the first q is discarded
538 # and then n attempts to discard the edit. Repeat q enough
541 # 2. Correct version applies the (not)edited version, and asks
542 # about the next hunk, against which we say q and program
544 printf "%s\n" s e q n q q |
545 EDITOR=: git add -p &&
550 test_expect_success
'setup ADD_I_USE_BUILTIN check' '
552 if ! test_have_prereq ADD_I_USE_BUILTIN
558 test_expect_
$result 'split hunk "add -p (no, yes, edit)"' '
559 test_write_lines 5 10 20 21 30 31 40 50 60 >test &&
561 # test sequence is s(plit), n(o), y(es), e(dit)
562 # q n q q is there to make sure we exit at the end.
563 printf "%s\n" s n y e q n q q |
564 EDITOR=: git add -p 2>error &&
565 test_must_be_empty error &&
570 test_expect_success
'split hunk with incomplete line at end' '
572 printf "missing LF" >>test &&
574 test_write_lines before 10 20 30 40 50 60 70 >test &&
575 git grep --cached missing &&
576 test_write_lines s n y q | git add -p &&
577 test_must_fail git grep --cached missing &&
579 test_must_fail git grep --cached before
582 test_expect_
$result 'edit, adding lines to the first hunk' '
583 test_write_lines 10 11 20 30 40 50 51 60 >test &&
585 tr _ " " >patch <<-EOF &&
595 # test sequence is s(plit), e(dit), n(o)
596 # q n q q is there to make sure we exit at the end.
597 printf "%s\n" s e n q n q q |
598 EDITOR=./fake_editor.sh git add -p 2>error &&
599 test_must_be_empty error &&
600 git diff --cached >actual &&
604 test_expect_success
'patch mode ignores unmerged entries' '
606 test_commit conflict &&
607 test_commit non-conflict &&
608 git checkout -b side &&
609 test_commit side conflict.t &&
611 test_commit main conflict.t &&
612 test_must_fail git merge side &&
613 echo changed >non-conflict.t &&
614 echo y | git add -p >output &&
615 ! grep a/conflict.t output &&
616 cat >expected <<-\EOF &&
617 * Unmerged path conflict.t
618 diff --git a/non-conflict.t b/non-conflict.t
619 index f766221..5ea2ed4 100644
626 git diff --cached >diff &&
627 diff_cmp expected diff
630 test_expect_success
'index is refreshed after applying patch' '
632 echo content >test &&
633 printf y | git add -p &&
634 git diff-files --exit-code
637 test_expect_success
'diffs can be colorized' '
640 echo content >test &&
642 force_color git add -p >output 2>&1 <y &&
643 git diff-files --exit-code &&
645 # We do not want to depend on the exact coloring scheme
646 # git uses for diffs, so just check that we saw some kind of color.
647 grep "$(printf "\\033")" output
650 test_expect_success
'colors can be overridden' '
652 test_when_finished "git rm -f color-test" &&
653 test_write_lines context old more-context >color-test &&
654 git add color-test &&
655 test_write_lines context new more-context another-one >color-test &&
657 echo trigger an error message >input &&
659 -c color.interactive.error=blue \
660 add -i 2>err.raw <input &&
661 test_decode_color <err.raw >err &&
662 grep "<BLUE>Huh (trigger)?<RESET>" err &&
664 test_write_lines help quit >input &&
666 -c color.interactive.header=red \
667 -c color.interactive.help=green \
668 -c color.interactive.prompt=yellow \
669 add -i >actual.raw <input &&
670 test_decode_color <actual.raw >actual &&
671 cat >expect <<-\EOF &&
672 <RED> staged unstaged path<RESET>
673 1: +3/-0 +2/-1 color-test
675 <RED>*** Commands ***<RESET>
676 1: <YELLOW>s<RESET>tatus 2: <YELLOW>u<RESET>pdate 3: <YELLOW>r<RESET>evert 4: <YELLOW>a<RESET>dd untracked
677 5: <YELLOW>p<RESET>atch 6: <YELLOW>d<RESET>iff 7: <YELLOW>q<RESET>uit 8: <YELLOW>h<RESET>elp
678 <YELLOW>What now<RESET>> <GREEN>status - show paths with changes<RESET>
679 <GREEN>update - add working tree state to the staged set of changes<RESET>
680 <GREEN>revert - revert staged set of changes back to the HEAD version<RESET>
681 <GREEN>patch - pick hunks and update selectively<RESET>
682 <GREEN>diff - view diff between HEAD and index<RESET>
683 <GREEN>add untracked - add contents of untracked files to the staged set of changes<RESET>
684 <RED>*** Commands ***<RESET>
685 1: <YELLOW>s<RESET>tatus 2: <YELLOW>u<RESET>pdate 3: <YELLOW>r<RESET>evert 4: <YELLOW>a<RESET>dd untracked
686 5: <YELLOW>p<RESET>atch 6: <YELLOW>d<RESET>iff 7: <YELLOW>q<RESET>uit 8: <YELLOW>h<RESET>elp
687 <YELLOW>What now<RESET>> Bye.
689 test_cmp expect actual &&
691 : exercise recolor_hunk by editing and then look at the hunk again &&
692 test_write_lines s e K q >input &&
694 -c color.interactive.prompt=yellow \
695 -c color.diff.meta=italic \
696 -c color.diff.frag=magenta \
697 -c color.diff.context=cyan \
698 -c color.diff.old=bold \
699 -c color.diff.new=blue \
700 -c core.editor=touch \
701 add -p >actual.raw <input &&
702 test_decode_color <actual.raw >actual.decoded &&
703 sed "s/index [0-9a-f]*\\.\\.[0-9a-f]* 100644/<INDEX-LINE>/" <actual.decoded >actual &&
704 cat >expect <<-\EOF &&
705 <ITALIC>diff --git a/color-test b/color-test<RESET>
706 <ITALIC><INDEX-LINE><RESET>
707 <ITALIC>--- a/color-test<RESET>
708 <ITALIC>+++ b/color-test<RESET>
709 <MAGENTA>@@ -1,3 +1,4 @@<RESET>
710 <CYAN> context<RESET>
712 <BLUE>+<RESET><BLUE>new<RESET>
713 <CYAN> more-context<RESET>
714 <BLUE>+<RESET><BLUE>another-one<RESET>
715 <YELLOW>(1/1) Stage this hunk [y,n,q,a,d,s,e,?]? <RESET><BOLD>Split into 2 hunks.<RESET>
716 <MAGENTA>@@ -1,3 +1,3 @@<RESET>
717 <CYAN> context<RESET>
719 <BLUE>+<RESET><BLUE>new<RESET>
720 <CYAN> more-context<RESET>
721 <YELLOW>(1/2) Stage this hunk [y,n,q,a,d,j,J,g,/,e,?]? <RESET><MAGENTA>@@ -3 +3,2 @@<RESET>
722 <CYAN> more-context<RESET>
723 <BLUE>+<RESET><BLUE>another-one<RESET>
724 <YELLOW>(2/2) Stage this hunk [y,n,q,a,d,K,g,/,e,?]? <RESET><MAGENTA>@@ -1,3 +1,3 @@<RESET>
725 <CYAN> context<RESET>
728 <CYAN> more-context<RESET>
729 <YELLOW>(1/2) Stage this hunk [y,n,q,a,d,j,J,g,/,e,?]? <RESET>
731 test_cmp expect actual
734 test_expect_success
'colorized diffs respect diff.wsErrorHighlight' '
742 force_color git -c diff.wsErrorHighlight=all add -p >output.raw 2>&1 <y &&
743 test_decode_color <output.raw >output &&
747 test_expect_success
'diffFilter filters diff' '
750 echo content >test &&
751 test_config interactive.diffFilter "sed s/^/foo:/" &&
753 force_color git add -p >output 2>&1 <y &&
755 # avoid depending on the exact coloring or content of the prompts,
756 # and just make sure we saw our diff prefixed
757 grep foo:.*content output
760 test_expect_success
'detect bogus diffFilter output' '
763 echo content >test &&
764 test_config interactive.diffFilter "sed 1d" &&
766 force_color test_must_fail git add -p <y
769 test_expect_success
'diff.algorithm is passed to `git diff-files`' '
774 echo changed >file &&
775 test_must_fail git -c diff.algorithm=bogus add -p 2>err &&
776 test_i18ngrep "error: option diff-algorithm accepts " err
779 test_expect_success
'patch-mode via -i prompts for files' '
784 git add -i <<-\EOF &&
793 git diff --cached --name-only >actual &&
794 diff_cmp expect actual
797 test_expect_success
'add -p handles globs' '
802 echo base >subdir/two.c &&
804 git commit -m base &&
806 echo change >one.c &&
807 echo change >subdir/two.c &&
808 git add -p "*.c" <<-\EOF &&
813 cat >expect <<-\EOF &&
817 git diff --cached --name-only >actual &&
818 test_cmp expect actual
821 test_expect_success
'add -p handles relative paths' '
824 echo base >relpath.c &&
826 git commit -m relpath &&
828 echo change >relpath.c &&
830 git -C subdir add -p .. 2>error <<-\EOF &&
834 test_must_be_empty error &&
836 cat >expect <<-\EOF &&
839 git diff --cached --name-only >actual &&
840 test_cmp expect actual
843 test_expect_success
'add -p does not expand argument lists' '
846 echo content >not-changed &&
847 git add not-changed &&
848 git commit -m "add not-changed file" &&
851 GIT_TRACE=$(pwd)/trace.out git add -p . <<-\EOF &&
855 # we know that "file" must be mentioned since we actually
856 # update it, but we want to be sure that our "." pathspec
857 # was not expanded into the argument list of any command.
858 # So look only for "not-changed".
859 ! grep -E "^trace: (built-in|exec|run_command): .*not-changed" trace.out
862 test_expect_success
'hunk-editing handles custom comment char' '
864 echo change >>file &&
865 test_config core.commentChar "\$" &&
866 echo e | GIT_EDITOR=true git add -p &&
870 test_expect_success
'add -p works even with color.ui=always' '
872 echo change >>file &&
873 test_config color.ui always &&
874 echo y | git add -p &&
876 git diff --cached --name-only >actual &&
877 test_cmp expect actual
880 test_expect_success
'setup different kinds of dirty submodules' '
881 test_create_repo for-submodules &&
884 test_commit initial &&
885 test_create_repo dirty-head &&
890 cp -R dirty-head dirty-otherwise &&
891 cp -R dirty-head dirty-both-ways &&
892 git add dirty-head &&
893 git add dirty-otherwise dirty-both-ways &&
894 git commit -m initial &&
897 test_commit updated &&
898 cd ../dirty-both-ways &&
899 test_commit updated &&
900 echo dirty >>initial &&
902 cd ../dirty-otherwise &&
903 echo dirty >>initial &&
906 git -C for-submodules diff-files --name-only >actual &&
907 cat >expected <<-\EOF &&
911 test_cmp expected actual &&
912 git -C for-submodules diff-files --name-only --ignore-submodules=none >actual &&
913 cat >expected <<-\EOF &&
918 test_cmp expected actual &&
919 git -C for-submodules diff-files --name-only --ignore-submodules=dirty >actual &&
920 cat >expected <<-\EOF &&
924 test_cmp expected actual
927 test_expect_success
'status ignores dirty submodules (except HEAD)' '
928 git -C for-submodules add -i </dev/null >output &&
929 grep dirty-head output &&
930 grep dirty-both-ways output &&
931 ! grep dirty-otherwise output
934 test_expect_success
'set up pathological context' '
936 test_write_lines a a a a a a a a a a a >a &&
939 test_write_lines c b a a a a a a a b a a a a >a &&
940 test_write_lines a a a a a a a b a a a a >expected-1 &&
941 test_write_lines b a a a a a a a b a a a a >expected-2 &&
942 # check editing can cope with missing header and deleted context lines
943 # as well as changes to other lines
944 test_write_lines +b " a" >patch
947 test_expect_success
'add -p works with pathological context lines' '
951 git cat-file blob :a >actual &&
952 test_cmp expected-1 actual
955 test_expect_success
'add -p patch editing works with pathological context lines' '
957 # n q q below is in case edit fails
958 printf "%s\n" e y n q q |
960 git cat-file blob :a >actual &&
961 test_cmp expected-2 actual
964 test_expect_success
'checkout -p works with pathological context lines' '
965 test_write_lines a a a a a a >a &&
967 test_write_lines a b a b a b a b a b a >a &&
968 test_write_lines s n n y q | git checkout -p &&
969 test_write_lines a b a b a a b a b a >expect &&
973 # This should be called from a subshell as it sets a temporary editor
975 write_script new-file-editor.sh
<<-\EOF &&
976 sed /^#/d "$1" >patch &&
977 sed /^+c/d patch >"$1"
979 test_set_editor "$(pwd)/new-file-editor.sh" &&
980 test_write_lines a b c d e f >new-file &&
981 test_write_lines a b d e f >new-file-expect &&
982 test_write_lines "@@ -0,0 +1,6 @@" +a +b +c +d +e +f >patch-expect
985 test_expect_success 'add -N followed by add -p patch editing' '
989 git add -N new-file &&
990 test_write_lines e n q | git add -p &&
991 git cat-file blob :new-file >actual &&
992 test_cmp new-file-expect actual &&
993 test_cmp patch-expect patch
997 test_expect_success 'checkout -p patch editing of added file' '
1002 git commit -m "add new file" &&
1004 git commit -m "remove new file" &&
1005 test_write_lines e n q | git checkout -p HEAD^ &&
1006 test_cmp new-file-expect new-file &&
1007 test_cmp patch-expect patch
1011 test_expect_success 'show help from add--helper' '
1013 cat >expect <<-EOF &&
1015 <BOLD>*** Commands ***<RESET>
1016 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
1017 5: <BOLD;BLUE>p<RESET>atch 6: <BOLD;BLUE>d<RESET>iff 7: <BOLD;BLUE>q<RESET>uit 8: <BOLD;BLUE>h<RESET>elp
1018 <BOLD;BLUE>What now<RESET>> <BOLD;RED>status - show paths with changes
<RESET
>
1019 <BOLD
;RED
>update
- add working tree state to the staged
set of changes
<RESET
>
1020 <BOLD
;RED
>revert
- revert staged
set of changes back to the HEAD version
<RESET
>
1021 <BOLD
;RED
>patch - pick hunks and update selectively
<RESET
>
1022 <BOLD
;RED
>diff - view
diff between HEAD and index
<RESET
>
1023 <BOLD
;RED
>add untracked
- add contents of untracked files to the staged
set of changes
<RESET
>
1024 <BOLD
>*** Commands
***<RESET
>
1025 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
1026 5: <BOLD
;BLUE
>p
<RESET
>atch
6: <BOLD
;BLUE
>d
<RESET
>iff
7: <BOLD
;BLUE
>q
<RESET
>uit
8: <BOLD
;BLUE
>h
<RESET
>elp
1027 <BOLD
;BLUE
>What now
<RESET
>>$SP
1030 test_write_lines h | force_color git add
-i >actual.colored
&&
1031 test_decode_color
<actual.colored
>actual
&&
1032 test_cmp expect actual