Skip to content

Commit

Permalink
add -i (Perl version): color header to match the C version
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
dscho authored and gitster committed Nov 16, 2020
1 parent afae3cb commit 0cb8939
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions git-add--interactive.perl
Original file line number Diff line number Diff line change
Expand Up @@ -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] ? '*' : ' ';
Expand Down

0 comments on commit 0cb8939

Please sign in to comment.