Code

gitweb: Use rev-list pattern search options.
authorRobert Fitzsimons <robfitz@273k.net>
Sat, 23 Dec 2006 03:35:14 +0000 (03:35 +0000)
committerJunio C Hamano <junkio@cox.net>
Sat, 23 Dec 2006 07:18:40 +0000 (23:18 -0800)
Use rev-list pattern search options instead of hand coded perl.

Signed-off-by: Robert Fitzsimons <robfitz@273k.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
gitweb/gitweb.perl

index b0e6fdfb9d84d105d203ebd335d82f28072d12e8..c1e8bbc3cb620fd0dd64edbf597c6ad2945e08a8 100755 (executable)
@@ -4176,20 +4176,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) {