summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Lederhofer <matled@gmx.net>2006-08-06 17:24:47 (GMT)
committerJunio C Hamano <junkio@cox.net>2006-08-06 20:42:41 (GMT)
commit1568515d5b8350a6087c0976c841387d71075c01 (patch)
treee8358263bd9c9f29d051992963503aa0bb6bbbfe
parente349d21ab47ae4a3753749c4579cce150c71c768 (diff)
downloadgit-1568515d5b8350a6087c0976c841387d71075c01.zip
git-1568515d5b8350a6087c0976c841387d71075c01.tar.gz
git-1568515d5b8350a6087c0976c841387d71075c01.tar.bz2
gitweb: fix commitdiff_plain for root commits
Signed-off-by: Matthias Lederhofer <matled@gmx.net> Signed-off-by: Junio C Hamano <junkio@cox.net>
-rwxr-xr-xgitweb/gitweb.perl8
1 files changed, 7 insertions, 1 deletions
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index b8e266e..08de2ce 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -2193,6 +2193,13 @@ sub git_commitdiff {
sub git_commitdiff_plain {
mkdir($git_temp, 0700);
+ my %co = git_read_commit($hash);
+ if (!%co) {
+ die_error(undef, "Unknown commit object");
+ }
+ if (!defined $hash_parent) {
+ $hash_parent = $co{'parent'} || '--root';
+ }
open my $fd, "-|", $GIT, "diff-tree", '-r', $hash_parent, $hash
or die_error(undef, "Open git-diff-tree failed");
my @difftree = map { chomp; $_ } <$fd>;
@@ -2214,7 +2221,6 @@ sub git_commitdiff_plain {
}
print $cgi->header(-type => "text/plain", -charset => 'utf-8', '-content-disposition' => "inline; filename=\"git-$hash.patch\"");
- my %co = git_read_commit($hash);
my %ad = date_str($co{'author_epoch'}, $co{'author_tz'});
my $comment = $co{'comment'};
print "From: $co{'author'}\n" .