summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 55d0b8e)
raw | patch | inline | side by side (parent: 55d0b8e)
author | Kay Sievers <kay.sievers@suse.de> | |
Tue, 13 Sep 2005 00:21:59 +0000 (02:21 +0200) | ||
committer | Kay Sievers <kay.sievers@suse.de> | |
Tue, 13 Sep 2005 00:21:59 +0000 (02:21 +0200) |
This way we don't need to parse the "grafts".
Signed-off-by: Kay Sievers <kay.sievers@suse.de>
Signed-off-by: Kay Sievers <kay.sievers@suse.de>
gitweb.cgi | patch | blob | history |
diff --git a/gitweb.cgi b/gitweb.cgi
index fa5b6355a6c7d05b4a9857d1d9990ffc22f3c299..53980efeba3ab6eb2326835f1e1c7e7439ade0b8 100755 (executable)
--- a/gitweb.cgi
+++ b/gitweb.cgi
my @commit_lines;
my %co;
- my @parents;
if (defined $commit_text) {
@commit_lines = @$commit_text;
} else {
- open my $fd, "-|", "$gitbin/git-cat-file commit $commit_id" or return;
- @commit_lines = map { chomp; $_ } <$fd>;
+ $/ = "\0";
+ open my $fd, "-|", "$gitbin/git-rev-list --header --parents --max-count=1 $commit_id" or return;
+ @commit_lines = split '\n', <$fd>;
close $fd or return;
+ $/ = "\n";
+ pop @commit_lines;
}
+ my $header = shift @commit_lines;
+ if (!($header =~ m/^[0-9a-fA-F]{40}/)) {
+ return;
+ }
+ ($co{'id'}, my @parents) = split ' ', $header;
+ $co{'parents'} = \@parents;
+ $co{'parent'} = $parents[0];
while (my $line = shift @commit_lines) {
last if $line eq "\n";
if ($line =~ m/^tree ([0-9a-fA-F]{40})$/) {
$co{'tree'} = $1;
- } elsif ($line =~ m/^parent ([0-9a-fA-F]{40})$/) {
- push @parents, $1;
} elsif ($line =~ m/^author (.*) ([0-9]+) (.*)$/) {
$co{'author'} = $1;
$co{'author_epoch'} = $2;
}
}
if (!defined $co{'tree'}) {
- return undef
+ return;
};
- if (!($commit_id =~ m/^[0-9a-fA-F]{40}$/)) {
- # lookup hash by textual id
- open my $fd, "-|", "$gitbin/git-rev-parse --verify $commit_id" or return;
- my $hash_id = <$fd>;
- close $fd or return;
- chomp $hash_id;
- $co{'id'} = $hash_id
- } else {
- $co{'id'} = $commit_id;
- }
- $co{'parents'} = \@parents;
- $co{'parent'} = $parents[0];
- $co{'comment'} = \@commit_lines;
+
foreach my $title (@commit_lines) {
if ($title ne "") {
$co{'title'} = chop_str($title, 80, 5);
last;
}
}
+ # remove added spaces
+ foreach my $line (@commit_lines) {
+ $line =~ s/^ //;
+ }
+ $co{'comment'} = \@commit_lines;
my $age = time - $co{'committer_epoch'};
$co{'age'} = $age;
my $alternate = 0;
if ($commit_search) {
$/ = "\0";
- open my $fd, "-|", "$gitbin/git-rev-list --header $hash";
+ open my $fd, "-|", "$gitbin/git-rev-list --header --parents $hash" or next;
while (my $commit_text = <$fd>) {
if (!grep m/$searchtext/i, $commit_text) {
next;
next;
}
my @commit_lines = split "\n", $commit_text;
- my $commit = shift @commit_lines;
- my %co = git_read_commit($commit, \@commit_lines);
+ my %co = git_read_commit(undef, \@commit_lines);
if (!%co) {
next;
}
print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
"<td><i>" . escapeHTML(chop_str($co{'author_name'}, 15, 5)) . "</i></td>\n" .
"<td>" .
- $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "list"}, "<b>" . escapeHTML(chop_str($co{'title'}, 50)) . "</b><br/>");
+ $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$co{'id'}", -class => "list"}, "<b>" . escapeHTML(chop_str($co{'title'}, 50)) . "</b><br/>");
my $comment = $co{'comment'};
foreach my $line (@$comment) {
if ($line =~ m/^(.*)($searchtext)(.*)$/i) {
}
print "</td>\n" .
"<td class=\"link\">" .
- $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") .
- " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$commit"}, "tree");
+ $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$co{'id'}"}, "commit") .
+ " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$co{'id'}"}, "tree");
print "</td>\n" .
"</tr>\n";
}