diff-highlight: test color config

We added configurable colors long ago in bca45fbc1f (diff-highlight: allow configurable colors, 2014-11-20), but never actually tested it. Since we'll be touching the color code in a moment, this is a good time to beef up the tests. Note that we cover both the highlight/reset style used by the default colors, as well as the normal/highlight style added by that commit (which was previously totally untested). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Mar 23, 2026 at 02:02 UTC c6bc53ad95d5a7dda3d3a8b1bc984465c9024342
1 file changed +28
contrib/diff-highlight/t/t9400-diff-highlight.sh
+28
@@ -350,4 +350,32 @@ test_expect_success 'highlight diff that removes final newline' '
350 EOF
351 '
352
353 +test_expect_success 'configure set/reset colors' '
354 + test_config color.diff-highlight.oldhighlight bold &&
355 + test_config color.diff-highlight.oldreset nobold &&
356 + test_config color.diff-highlight.newhighlight italic &&
357 + test_config color.diff-highlight.newreset noitalic &&
358 + echo "prefix a suffix" >a &&
359 + echo "prefix b suffix" >b &&
360 + dh_test a b <<-\EOF
361 + @@ -1 +1 @@
362 + -prefix <BOLD>a<NORMAL_INTENSITY> suffix
363 + +prefix <ITALIC>b<NOITALIC> suffix
364 + EOF
365 +'
366 +
367 +test_expect_success 'configure normal/highlight colors' '
368 + test_config color.diff-highlight.oldnormal red &&
369 + test_config color.diff-highlight.oldhighlight magenta &&
370 + test_config color.diff-highlight.newnormal green &&
371 + test_config color.diff-highlight.newhighlight yellow &&
372 + echo "prefix a suffix" >a &&
373 + echo "prefix b suffix" >b &&
374 + dh_test a b <<-\EOF
375 + @@ -1 +1 @@
376 + <RED>-prefix <RESET><MAGENTA>a<RESET><RED> suffix<RESET>
377 + <GREEN>+prefix <RESET><YELLOW>b<RESET><GREEN> suffix<RESET>
378 + EOF
379 +'
380 +
381 test_done