git-svn: fix log command to avoid infinite loop on long commit messages
authorEric Wong <normalperson@yhbt.net>
Sun, 8 Apr 2007 07:59:22 +0000 (00:59 -0700)
committerJunio C Hamano <junkio@cox.net>
Mon, 9 Apr 2007 02:54:07 +0000 (19:54 -0700)
This bug has been around since the the conversion to use the
Git.pm library back in October or November. Eventually I'd like
"git rev-list/log" to have the option to not truncate overly
long messages.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
git-svn.perl
index e4079fb76cca3bc61d9e44f7a0d3e74836ff62d4..ac44f60b81412753248c78fbe73fe7f6a212b6df 100755 (executable)
@@ -3263,12 +3263,19 @@ package Git::SVN::Log;
 sub cmt_showable {
        my ($c) = @_;
        return 1 if defined $c->{r};
+
+       # big commit message got truncated by the 16k pretty buffer in rev-list
        if ($c->{l} && $c->{l}->[-1] eq "...\n" &&
                                $c->{a_raw} =~ /\@([a-f\d\-]+)>$/) {
+               @{$c->{l}} = ();
                my @log = command(qw/cat-file commit/, $c->{c});
-               shift @log while ($log[0] ne "\n");
+
+               # shift off the headers
+               shift @log while ($log[0] ne '');
                shift @log;
-               @{$c->{l}} = grep !/^git-svn-id: /, @log;
+
+               # TODO: make $c->{l} not have a trailing newline in the future
+               @{$c->{l}} = map { "$_\n" } grep !/^git-svn-id: /, @log;
 
                (undef, $c->{r}, undef) = ::extract_metadata(
                                (grep(/^git-svn-id: /, @log))[-1]);