gitweb: Change header search action to use parse_commits.
Signed-off-by: Robert Fitzsimons <robfitz@273k.net> Signed-off-by: Junio C Hamano <junkio@cox.net>
Robert Fitzsimons committed
Dec 24, 2006 at 14:31 UTC
5ad66088d1166bf91cf2890682f4582049756539
1 file changed
+9
-14
gitweb/gitweb.perl
+9
-14
@@ -2910,18 +2910,18 @@ sub git_heads_body {
2910
}
2911
2912
sub git_search_grep_body {
2913
- my ($greplist, $from, $to, $extra) = @_;
2913
+ my ($commitlist, $from, $to, $extra) = @_;
2914
$from = 0 unless defined $from;
2915
- $to = $#{$greplist} if (!defined $to || $#{$greplist} < $to);
2915
+ $to = $#{$commitlist} if (!defined $to || $#{$commitlist} < $to);
2916
2917
print "<table class=\"grep\" cellspacing=\"0\">\n";
2918
my $alternate = 1;
2919
for (my $i = $from; $i <= $to; $i++) {
2920
- my $commit = $greplist->[$i];
2921
- my %co = parse_commit($commit);
2920
+ my %co = %{$commitlist->[$i]};
2921
if (!%co) {
2922
next;
2923
}
2924
+ my $commit = $co{'id'};
2925
if ($alternate) {
2926
print "<tr class=\"dark\">\n";
2927
} else {
@@ -4307,13 +4307,8 @@ sub git_search {
4307
} elsif ($searchtype eq 'committer') {
4308
$greptype = "--committer=";
4309
}
4310
- open my $fd, "-|", git_cmd(), "rev-list",
4311
- ("--max-count=" . (100 * ($page+1))),
4312
- ($greptype . $searchtext),
4313
- $hash, "--"
4314
- or next;
4315
- my @revlist = map { chomp; $_ } <$fd>;
4316
- close $fd;
4310
+ $greptype .= $searchtext;
4311
+ my @commitlist = parse_commits($hash, 101, (100 * $page), $greptype);
4312
4313
my $paging_nav = '';
4314
if ($page > 0) {
@@ -4330,7 +4325,7 @@ sub git_search {
4325
$paging_nav .= "first";
4326
$paging_nav .= " ⋅ prev";
4327
}
4333
- if ($#revlist >= (100 * ($page+1)-1)) {
4328
+ if ($#commitlist >= 100) {
4329
$paging_nav .= " ⋅ " .
4330
$cgi->a({-href => href(action=>"search", hash=>$hash,
4331
searchtext=>$searchtext, searchtype=>$searchtype,
@@ -4340,7 +4335,7 @@ sub git_search {
4335
$paging_nav .= " ⋅ next";
4336
}
4337
my $next_link = '';
4343
- if ($#revlist >= (100 * ($page+1)-1)) {
4338
+ if ($#commitlist >= 100) {
4339
$next_link =
4340
$cgi->a({-href => href(action=>"search", hash=>$hash,
4341
searchtext=>$searchtext, searchtype=>$searchtype,
@@ -4350,7 +4345,7 @@ sub git_search {
4345
4346
git_print_page_nav('','', $hash,$co{'tree'},$hash, $paging_nav);
4347
git_print_header_div('commit', esc_html($co{'title'}), $hash);
4353
- git_search_grep_body(\@revlist, ($page * 100), $#revlist, $next_link);
4348
+ git_search_grep_body(\@commitlist, 0, 99, $next_link);
4349
}
4350
4351
if ($searchtype eq 'pickaxe') {