git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/3] gitweb: Use rev-list pattern search options.

From
RFRobert Fitzsimons <robfitz@273k.net>
Date
Dec 23, 2006, 03:35 UTC
Message-ID
<11668449162618-git-send-email-robfitz@273k.net>
Use rev-list pattern search options instead of hand coded perl.
Signed-off-by: Robert Fitzsimons <robfitz@273k.net>
---
 gitweb/gitweb.perl |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index ebbc397..cc6bd0c 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -4172,20 +4172,20 @@ sub git_search {
 	print "<table cellspacing=\"0\">\n";
 	my $alternate = 1;
 	if ($searchtype eq 'commit' or $searchtype eq 'author' or $searchtype eq 'committer') {
+		my $greptype;
+		if ($searchtype eq 'commit') {
+			$greptype = "--grep=";
+		} elsif ($searchtype eq 'author') {
+			$greptype = "--author=";
+		} elsif ($searchtype eq 'committer') {
+			$greptype = "--committer=";
+		}
 		$/ = "\0";
 		open my $fd, "-|", git_cmd(), "rev-list",
-			"--header", "--parents", $hash, "--"
+			"--header", "--parents", ($greptype . $searchtext),
+			 $hash, "--"
 			or next;
 		while (my $commit_text = <$fd>) {
-			if (!grep m/$searchtext/i, $commit_text) {
-				next;
-			}
-			if ($searchtype eq 'author' && !grep m/\nauthor .*$searchtext/i, $commit_text) {
-				next;
-			}
-			if ($searchtype eq 'committer' && !grep m/\ncommitter .*$searchtext/i, $commit_text) {
-				next;
-			}
 			my @commit_lines = split "\n", $commit_text;
 			my %co = parse_commit(undef, \@commit_lines);
 			if (!%co) {
-- 
1.4.4.3.gae7ae3
Next: Robert Fitzsimons
Message 1 of 10 in “gitweb: Use rev-list pattern search options.”
  1. 1/3 gitweb: Use rev-list pattern search options.Robert Fitzsimons, Dec 23, 2006
  2. 2/3 gitweb: Require a minimum of two character for the search text.Robert Fitzsimons, Dec 23, 2006
  3. 3/3 gitweb: Allow search to be disabled from the config file.Robert Fitzsimons, Dec 23, 2006
  4. Jakub NarebskiDec 23, 2006
  5. Robert FitzsimonsDec 23, 2006
  6. Jakub NarebskiDec 23, 2006
  7. gitweb: Paginate commit/author/committer search outputRobert Fitzsimons, Dec 23, 2006
  8. Jakub NarebskiDec 23, 2006
  9. Robert FitzsimonsDec 23, 2006
  10. Jakub NarebskiDec 23, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.