589
grep "$(printf "\\033")" output
590
'
591
592
+test_expect_success 'colors can be overridden' '
593
+ git reset --hard &&
594
+ test_when_finished "git rm -f color-test" &&
595
+ test_write_lines context old more-context >color-test &&
596
+ git add color-test &&
597
+ test_write_lines context new more-context another-one >color-test &&
598
+
599
+ echo trigger an error message >input &&
600
+ force_color git \
601
+ -c color.interactive.error=blue \
602
+ add -i 2>err.raw <input &&
603
+ test_decode_color <err.raw >err &&
604
+ grep "<BLUE>Huh (trigger)?<RESET>" err &&
605
+
606
+ test_write_lines help quit >input &&
607
+ force_color git \
608
+ -c color.interactive.header=red \
609
+ -c color.interactive.help=green \
610
+ -c color.interactive.prompt=yellow \
611
+ add -i >actual.raw <input &&
612
+ test_decode_color <actual.raw >actual &&
613
+ cat >expect <<-\EOF &&
614
+ <RED> staged unstaged path<RESET>
615
+ 1: +3/-0 +2/-1 color-test
616
+
617
+ <RED>*** Commands ***<RESET>
618
+ 1: <YELLOW>s<RESET>tatus 2: <YELLOW>u<RESET>pdate 3: <YELLOW>r<RESET>evert 4: <YELLOW>a<RESET>dd untracked
619
+ 5: <YELLOW>p<RESET>atch 6: <YELLOW>d<RESET>iff 7: <YELLOW>q<RESET>uit 8: <YELLOW>h<RESET>elp
620
+ <YELLOW>What now<RESET>> <GREEN>status - show paths with changes<RESET>
621
+ <GREEN>update - add working tree state to the staged set of changes<RESET>
622
+ <GREEN>revert - revert staged set of changes back to the HEAD version<RESET>
623
+ <GREEN>patch - pick hunks and update selectively<RESET>
624
+ <GREEN>diff - view diff between HEAD and index<RESET>
625
+ <GREEN>add untracked - add contents of untracked files to the staged set of changes<RESET>
626
+ <RED>*** Commands ***<RESET>
627
+ 1: <YELLOW>s<RESET>tatus 2: <YELLOW>u<RESET>pdate 3: <YELLOW>r<RESET>evert 4: <YELLOW>a<RESET>dd untracked
628
+ 5: <YELLOW>p<RESET>atch 6: <YELLOW>d<RESET>iff 7: <YELLOW>q<RESET>uit 8: <YELLOW>h<RESET>elp
629
+ <YELLOW>What now<RESET>> Bye.
630
+ EOF
631
+ test_cmp expect actual &&
632
+
633
+ : exercise recolor_hunk by editing and then look at the hunk again &&
634
+ test_write_lines s e K q >input &&
635
+ force_color git \
636
+ -c color.interactive.prompt=yellow \
637
+ -c color.diff.meta=italic \
638
+ -c color.diff.frag=magenta \
639
+ -c color.diff.context=cyan \
640
+ -c color.diff.old=bold \
641
+ -c color.diff.new=blue \
642
+ -c core.editor=touch \
643
+ add -p >actual.raw <input &&
644
+ test_decode_color <actual.raw >actual.decoded &&
645
+ sed "s/index [0-9a-f]*\\.\\.[0-9a-f]* 100644/<INDEX-LINE>/" <actual.decoded >actual &&
646
+ cat >expect <<-\EOF &&
647
+ <ITALIC>diff --git a/color-test b/color-test<RESET>
648
+ <ITALIC><INDEX-LINE><RESET>
649
+ <ITALIC>--- a/color-test<RESET>
650
+ <ITALIC>+++ b/color-test<RESET>
651
+ <MAGENTA>@@ -1,3 +1,4 @@<RESET>
652
+ <CYAN> context<RESET>
653
+ <BOLD>-old<RESET>
654
+ <BLUE>+<RESET><BLUE>new<RESET>
655
+ <CYAN> more-context<RESET>
656
+ <BLUE>+<RESET><BLUE>another-one<RESET>
657
+ <YELLOW>(1/1) Stage this hunk [y,n,q,a,d,s,e,?]? <RESET><BOLD>Split into 2 hunks.<RESET>
658
+ <MAGENTA>@@ -1,3 +1,3 @@<RESET>
659
+ <CYAN> context<RESET>
660
+ <BOLD>-old<RESET>
661
+ <BLUE>+<RESET><BLUE>new<RESET>
662
+ <CYAN> more-context<RESET>
663
+ <YELLOW>(1/2) Stage this hunk [y,n,q,a,d,j,J,g,/,e,?]? <RESET><MAGENTA>@@ -3 +3,2 @@<RESET>
664
+ <CYAN> more-context<RESET>
665
+ <BLUE>+<RESET><BLUE>another-one<RESET>
666
+ <YELLOW>(2/2) Stage this hunk [y,n,q,a,d,K,g,/,e,?]? <RESET><MAGENTA>@@ -1,3 +1,3 @@<RESET>
667
+ <CYAN> context<RESET>
668
+ <BOLD>-old<RESET>
669
+ <BLUE>+new<RESET>
670
+ <CYAN> more-context<RESET>
671
+ <YELLOW>(1/2) Stage this hunk [y,n,q,a,d,j,J,g,/,e,?]? <RESET>
672
+ EOF
673
+ test_cmp expect actual
674
+'
675
+
676
test_expect_success 'colorized diffs respect diff.wsErrorHighlight' '
677
git reset --hard &&
678