]> git.ipfire.org Git - thirdparty/git.git/commitdiff
add -i (Perl version): color header to match the C version
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Mon, 16 Nov 2020 16:08:30 +0000 (16:08 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 16 Nov 2020 23:59:02 +0000 (15:59 -0800)
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>
git-add--interactive.perl

index 8a720187125798e7e18d145a68210f0d9e6780f7..b42e15a5756142fa65b8a494a59c185b912912bb 100755 (executable)
@@ -483,10 +483,8 @@ sub list_and_choose {
                my $last_lf = 0;
 
                if ($opts->{HEADER}) {
-                       if (!$opts->{LIST_FLAT}) {
-                               print "     ";
-                       }
-                       print colored $header_color, "$opts->{HEADER}\n";
+                       my $indent = $opts->{LIST_FLAT} ? "" : "     ";
+                       print colored $header_color, "$indent$opts->{HEADER}\n";
                }
                for ($i = 0; $i < @stuff; $i++) {
                        my $chosen = $chosen[$i] ? '*' : ' ';