add -i (Perl version): color header to match the C version

Both versions of `add -i` indent non-flat lists by five spaces. However when using color the C version prints these spaces after the ANSI color codes whereas the Perl version prints them before the color codes. Change the Perl version to match the C version to allow for introducing a test that verifies that both versions produce the exact same output. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed Nov 16, 2020 at 16:08 UTC 0cb8939fb6795c9f94f9184935b6a83aebdfc47a
1 file changed +2 -4
git-add--interactive.perl
+2 -4
@@ -483,10 +483,8 @@ sub list_and_choose {
483 my $last_lf = 0;
484
485 if ($opts->{HEADER}) {
486 - if (!$opts->{LIST_FLAT}) {
487 - print " ";
488 - }
489 - print colored $header_color, "$opts->{HEADER}\n";
486 + my $indent = $opts->{LIST_FLAT} ? "" : " ";
487 + print colored $header_color, "$indent$opts->{HEADER}\n";
488 }
489 for ($i = 0; $i < @stuff; $i++) {
490 my $chosen = $chosen[$i] ? '*' : ' ';