git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Robert Fitzsimons <robfitz@273k.net>
To: git@vger.kernel.org
Cc: Robert Fitzsimons <robfitz@273k.net>
Subject: [PATCH 5/8] gitweb: Change header search action to use parse_commits.
Date: Sun, 24 Dec 2006 14:31:46 +0000	[thread overview]
Message-ID: <116697071140-git-send-email-robfitz@273k.net> (raw)
In-Reply-To: <11669707101872-git-send-email-robfitz@273k.net>


Signed-off-by: Robert Fitzsimons <robfitz@273k.net>
---
 gitweb/gitweb.perl |   23 +++++++++--------------
 1 files changed, 9 insertions(+), 14 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 42b7449..53dd225 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -2910,18 +2910,18 @@ sub git_heads_body {
 }
 
 sub git_search_grep_body {
-	my ($greplist, $from, $to, $extra) = @_;
+	my ($commitlist, $from, $to, $extra) = @_;
 	$from = 0 unless defined $from;
-	$to = $#{$greplist} if (!defined $to || $#{$greplist} < $to);
+	$to = $#{$commitlist} if (!defined $to || $#{$commitlist} < $to);
 
 	print "<table class=\"grep\" cellspacing=\"0\">\n";
 	my $alternate = 1;
 	for (my $i = $from; $i <= $to; $i++) {
-		my $commit = $greplist->[$i];
-		my %co = parse_commit($commit);
+		my %co = %{$commitlist->[$i]};
 		if (!%co) {
 			next;
 		}
+		my $commit = $co{'id'};
 		if ($alternate) {
 			print "<tr class=\"dark\">\n";
 		} else {
@@ -4307,13 +4307,8 @@ sub git_search {
 		} elsif ($searchtype eq 'committer') {
 			$greptype = "--committer=";
 		}
-		open my $fd, "-|", git_cmd(), "rev-list",
-			("--max-count=" . (100 * ($page+1))),
-			($greptype . $searchtext),
-			$hash, "--"
-			or next;
-		my @revlist = map { chomp; $_ } <$fd>;
-		close $fd;
+		$greptype .= $searchtext;
+		my @commitlist = parse_commits($hash, 101, (100 * $page), $greptype);
 
 		my $paging_nav = '';
 		if ($page > 0) {
@@ -4330,7 +4325,7 @@ sub git_search {
 			$paging_nav .= "first";
 			$paging_nav .= " &sdot; prev";
 		}
-		if ($#revlist >= (100 * ($page+1)-1)) {
+		if ($#commitlist >= 100) {
 			$paging_nav .= " &sdot; " .
 				$cgi->a({-href => href(action=>"search", hash=>$hash,
 						       searchtext=>$searchtext, searchtype=>$searchtype,
@@ -4340,7 +4335,7 @@ sub git_search {
 			$paging_nav .= " &sdot; next";
 		}
 		my $next_link = '';
-		if ($#revlist >= (100 * ($page+1)-1)) {
+		if ($#commitlist >= 100) {
 			$next_link =
 				$cgi->a({-href => href(action=>"search", hash=>$hash,
 						       searchtext=>$searchtext, searchtype=>$searchtype,
@@ -4350,7 +4345,7 @@ sub git_search {
 
 		git_print_page_nav('','', $hash,$co{'tree'},$hash, $paging_nav);
 		git_print_header_div('commit', esc_html($co{'title'}), $hash);
-		git_search_grep_body(\@revlist, ($page * 100), $#revlist, $next_link);
+		git_search_grep_body(\@commitlist, 0, 99, $next_link);
 	}
 
 	if ($searchtype eq 'pickaxe') {
-- 
1.4.4.3.ge655-dirty

  reply	other threads:[~2006-12-24 14:31 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-24 14:31 [PATCH 1/8] gitweb: Add parse_commits, used to bulk load commit objects Robert Fitzsimons
2006-12-24 14:31 ` [PATCH 2/8] gitweb: We do longer need the --parents flag in rev-list Robert Fitzsimons
2006-12-24 14:31   ` [PATCH 3/8] gitweb: Change summary, shortlog actions to use parse_commits Robert Fitzsimons
2006-12-24 14:31     ` [PATCH 4/8] gitweb: Change log action " Robert Fitzsimons
2006-12-24 14:31       ` Robert Fitzsimons [this message]
2006-12-24 14:31         ` [PATCH 6/8] gitweb: Change atom, rss actions " Robert Fitzsimons
2006-12-24 14:31           ` [PATCH 7/8] gitweb: Change history action " Robert Fitzsimons
2006-12-24 14:31             ` [PATCH 8/8] gitweb: Use rev-list --skip option Robert Fitzsimons
2006-12-25 22:49   ` [PATCH 2/8] gitweb: We do longer need the --parents flag in rev-list Jakub Narebski
2006-12-27 14:22     ` [PATCH] gitweb: Re-enable rev-list --parents for parse_commit Robert Fitzsimons

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=116697071140-git-send-email-robfitz@273k.net \
    --to=robfitz@273k.net \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).