Skip to content

Commit

Permalink
Change indent stripping behavior of 'log'
Browse files Browse the repository at this point in the history
closes RT#56427 - thanks to Mark Grimes for the patch.
  • Loading branch information
genehack committed Jul 9, 2011
1 parent 76451db commit 9f75fed
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Changes
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Revision history for {{$dist->name}}
{{$NEXT}}

Added a fix that allows the 'clone' command to work (John SJ Anderson)

Change 'log' indentation stripping behavior (RT#56427, Mark Grimes)

0.014 2010-11-12

Expand Down
3 changes: 2 additions & 1 deletion lib/Git/Wrapper.pm
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,14 @@ sub log {
$line = shift @out; # next line;
}
die "no blank line separating head from message" if $line;
my ( $initial_indent ) = $out[0] =~ /^(\s*)/ if @out;
my $message = '';
while (
@out
and $out[0] !~ /^commit (\S+)/
and length($line = shift @out)
) {
$line =~ s/^\s+//;
$line =~ s/^$initial_indent//; # strip just the indenting added by git
$message .= "$line\n";
}
$current->message($message);
Expand Down
4 changes: 2 additions & 2 deletions t/basic.t
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ is_deeply(
is( $git->status->is_dirty , 1 , 'repo is dirty' );

my $time = time;
$git->commit({ message => "FIRST" });
$git->commit({ message => "FIRST\n\n\tBODY\n" });

is( $git->status->is_dirty , 0 , 'repo is clean' );

Expand All @@ -47,7 +47,7 @@ my @log = $git->log({ date => 'raw' });
is(@log, 1, 'one log entry');
my $log = $log[0];
is($log->id, (split /\s/, $rev_list[0])[0], 'id');
is($log->message, "FIRST\n", "message");
is($log->message, "FIRST\n\n\tBODY\n", "message");
my $log_date = $log->date;
$log_date =~ s/ [+-]\d+$//;
cmp_ok(( $log_date - $time ), '<=', 5, 'date');
Expand Down

0 comments on commit 9f75fed

Please sign in to comment.