Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
switch to git-rev-list for commit reading
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>
gitweb.cgi
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
55d0b8e
)
diff --git
a/gitweb.cgi
b/gitweb.cgi
index fa5b6355a6c7d05b4a9857d1d9990ffc22f3c299..53980efeba3ab6eb2326835f1e1c7e7439ade0b8 100755
(executable)
--- a/
gitweb.cgi
+++ b/
gitweb.cgi
@@
-443,21
+443,28
@@
sub git_read_commit {
my @commit_lines;
my %co;
my @commit_lines;
my %co;
- my @parents;
if (defined $commit_text) {
@commit_lines = @$commit_text;
} else {
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;
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;
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;
} elsif ($line =~ m/^author (.*) ([0-9]+) (.*)$/) {
$co{'author'} = $1;
$co{'author_epoch'} = $2;
@@
-476,21
+483,9
@@
sub git_read_commit {
}
}
if (!defined $co{'tree'}) {
}
}
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);
foreach my $title (@commit_lines) {
if ($title ne "") {
$co{'title'} = chop_str($title, 80, 5);
@@
-515,6
+510,11
@@
sub git_read_commit {
last;
}
}
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 $age = time - $co{'committer_epoch'};
$co{'age'} = $age;
@@
-2081,7
+2081,7
@@
sub git_search {
my $alternate = 0;
if ($commit_search) {
$/ = "\0";
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;
while (my $commit_text = <$fd>) {
if (!grep m/$searchtext/i, $commit_text) {
next;
@@
-2093,8
+2093,7
@@
sub git_search {
next;
}
my @commit_lines = split "\n", $commit_text;
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;
}
if (!%co) {
next;
}
@@
-2107,7
+2106,7
@@
sub git_search {
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>" .
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=$co
mmit
", -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) {
my $comment = $co{'comment'};
foreach my $line (@$comment) {
if ($line =~ m/^(.*)($searchtext)(.*)$/i) {
@@
-2122,8
+2121,8
@@
sub git_search {
}
print "</td>\n" .
"<td class=\"link\">" .
}
print "</td>\n" .
"<td class=\"link\">" .
- $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$co
mmit
"}, "commit") .
- " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$co
mmit
"}, "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";
}
print "</td>\n" .
"</tr>\n";
}