gitweb: fix commitdiff_plain for root commits
Signed-off-by: Matthias Lederhofer <matled@gmx.net> Signed-off-by: Junio C Hamano <junkio@cox.net>
Matthias Lederhofer committed
Aug 6, 2006 at 19:24 UTC
1568515d5b8350a6087c0976c841387d71075c01
1 file changed
+7
-1
gitweb/gitweb.perl
+7
-1
@@ -2193,6 +2193,13 @@ sub git_commitdiff {
2193
2194
sub git_commitdiff_plain {
2195
mkdir($git_temp, 0700);
2196
+ my %co = git_read_commit($hash);
2197
+ if (!%co) {
2198
+ die_error(undef, "Unknown commit object");
2199
+ }
2200
+ if (!defined $hash_parent) {
2201
+ $hash_parent = $co{'parent'} || '--root';
2202
+ }
2203
open my $fd, "-|", $GIT, "diff-tree", '-r', $hash_parent, $hash
2204
or die_error(undef, "Open git-diff-tree failed");
2205
my @difftree = map { chomp; $_ } <$fd>;
@@ -2214,7 +2221,6 @@ sub git_commitdiff_plain {
2221
}
2222
2223
print $cgi->header(-type => "text/plain", -charset => 'utf-8', '-content-disposition' => "inline; filename=\"git-$hash.patch\"");
2217
- my %co = git_read_commit($hash);
2224
my %ad = date_str($co{'author_epoch'}, $co{'author_tz'});
2225
my $comment = $co{'comment'};
2226
print "From: $co{'author'}\n" .