From 3f714537ae72948a35db827d87363226200af646 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Sun, 7 Aug 2005 20:03:52 +0200 Subject: [PATCH] v021 --- gitweb.pl | 103 +++++++++++++++++------------------------------------- 1 file changed, 33 insertions(+), 70 deletions(-) diff --git a/gitweb.pl b/gitweb.pl index 6d604d732e..284a1588ea 100755 --- a/gitweb.pl +++ b/gitweb.pl @@ -109,7 +109,7 @@ print <) ([0-9]+) (.*)$/) { - $co{'$author'} = $1; - $co{'$author_time'} = $2; - $co{'$author_timezone'} = $3; + $co{'author'} = $1; + $co{'author_time'} = $2; + $co{'author_timezone'} = $3; } } - my $shortlog = <$fd>; - chomp($shortlog); - $co{'shortlog'} = escapeHTML($shortlog); - my $comment = $shortlog . "
"; - while (my $line = <$fd>) { - chomp($line); - if ($line =~ m/signed-off-by:/i) { - $comment .= '
' . escapeHTML($line) . "
\n"; - } else { - $comment .= escapeHTML($line) . "
\n"; - } - } - $co{'comment'} = $comment; + $co{'parents'} = \@parents; + my (@comment) = map { chomp; $_ } <$fd>; + $co{'comment'} = \@comment; + $co{'title'} = $comment[0]; close $fd; - return %co; } @@ -354,45 +344,9 @@ if ($action eq "blob") { my $time = $1; my $commit = $2; my $parent = $3; - my @parents; - my ($author, $author_time, $author_timezone); - my ($committer, $committer_time, $committer_timezone); - my $tree; - my $comment; - my $shortlog; - open my $fd, "-|", "$gitbin/cat-file", "commit", $commit; - while (my $line = <$fd>) { - chomp($line); - last if $line eq ""; - if ($line =~ m/^tree (.*)$/) { - $tree = $1; - } elsif ($line =~ m/^parent (.*)$/) { - push @parents, $1; - } elsif ($line =~ m/^committer (.*>) ([0-9]+) (.*)$/) { - $committer = $1; - $committer_time = $2; - $committer_timezone = $3; - } elsif ($line =~ m/^author (.*>) ([0-9]+) (.*)$/) { - $author = $1; - $author_time = $2; - $author_timezone = $3; - } - } - $shortlog = <$fd>; - chomp($shortlog); - $shortlog = escapeHTML($shortlog); - $comment = $shortlog . "
"; - while (my $line = <$fd>) { - chomp($line); - if ($line =~ m/signed-off-by:/i) { - $comment .= '
' . escapeHTML($line) . "
\n"; - } else { - $comment .= escapeHTML($line) . "
\n"; - } - } - close $fd; - my $age = time-$committer_time; + my %co = git_commit($commit); + my $age = time - $co{'committer_time'}; my $age_string; if ($age > 60*60*24*365*2) { $age_string = int $age/60/60/24/365; @@ -424,20 +378,21 @@ if ($action eq "blob") { } print "\n"; print "" . $age_string . "\n"; - print "" . $cgi->a({-href => "$myself/$project/commit/$commit"}, $shortlog) . ""; + print "" . $cgi->a({-href => "$myself/$project/commit/$commit"}, $co{'title'}) . ""; print "\n"; print "\n"; print ""; print $cgi->a({-href => "$myself/$project/commitdiff/$commit"}, "view diff") . "
\n"; print $cgi->a({-href => "$myself/$project/commit/$commit"}, "view commit") . "
\n"; - print $cgi->a({-href => "$myself/$project/tree/$tree"}, "view tree") . "
\n"; + print $cgi->a({-href => "$myself/$project/tree/$co{'tree'}"}, "view tree") . "
\n"; print "\n"; print "\n"; - print "author    " . escapeHTML($author) . " [" . gmtime($author_time) . " " . $author_timezone . "]
\n"; - print "committer " . escapeHTML($committer) . " [" . gmtime($committer_time) . " " . $committer_timezone . "]
\n"; + print "author    " . escapeHTML($co{'author'}) . " [" . gmtime($co{'author_time'}) . " " . $co{'author_timezone'} . "]
\n"; + print "committer " . escapeHTML($co{'committer'}) . " [" . gmtime($co{'committer_time'}) . " " . $co{'committer_timezone'} . "]
\n"; print "commit    $commit
\n"; - print "tree      $tree
\n"; - foreach my $par (@parents) { + print "tree      $co{'tree'}
\n"; + my $parents = $co{'parents'}; + foreach my $par (@$parents) { print "parent    $par
\n"; } print ""; @@ -445,12 +400,20 @@ if ($action eq "blob") { print "\n"; print "\n"; print "\n"; - print "$comment

\n"; + my $comment = $co{'comment'}; + foreach my $line (@$comment) { + if ($line =~ m/signed-off-by:/i) { + print '
' . escapeHTML($line) . "
\n"; + } else { + print escapeHTML($line) . "
\n"; + } + } + print "

\n"; print ""; print "\n"; } elsif ($action eq "rss") { last if ($i >= 12); - print "\n\t$age_string: $shortlog\n"; + print "\n\t$age_string: " . escapeHTML($co{'title'}) . "\n"; print "\t " . $cgi->url() . "/$project/commit/$commit\n"; print "\n"; } @@ -471,8 +434,8 @@ if ($action eq "blob") { $parent = $1; } } - my $shortlog = <$fd>; - $shortlog = escapeHTML($shortlog); + my $title = <$fd>; + $title = escapeHTML($title); close $fd; open $fd, "-|", "$gitbin/diff-tree", "-r", $parent, $hash; @@ -482,7 +445,7 @@ if ($action eq "blob") { git_header_html(); print "
\n"; print "view " . $cgi->a({-href => "$myself/$project/commitdiff/$hash"}, "diff") . "


\n"; - print "
$shortlog
\n"; + print "
$title
\n"; print "
\n";
 	foreach my $line (@difftree) {
 		# '*100644->100644	blob	9f91a116d91926df3ba936a80f020a6ab1084d2b->bb90a0c3a91eb52020d0db0e8b4f94d30e02d596	net/ipv4/route.c'
@@ -527,8 +490,8 @@ if ($action eq "blob") {
 			$parent = $1;
 		}
 	}
-	my $shortlog = <$fd>;
-	$shortlog = escapeHTML($shortlog);
+	my $title = <$fd>;
+	$title = escapeHTML($title);
 	close $fd;
 
 	open $fd, "-|", "$gitbin/diff-tree", "-r", $parent, $hash;
@@ -538,7 +501,7 @@ if ($action eq "blob") {
 	git_header_html();
 	print "
\n"; print "view " . $cgi->a({-href => "$myself/$project/commit/$hash"}, "commit") . "


\n"; - print "
$shortlog
\n"; + print "
$title
\n"; print "
\n";
 	foreach my $line (@difftree) {
 		# '*100644->100644	blob	8e5f9bbdf4de94a1bc4b4da8cb06677ce0a57716->8da3a306d0c0c070d87048d14a033df02f40a154	Makefile'
-- 
2.39.2