{"thread":{"id":"12327","subject":"[PATCH 3/4] gitweb: Simplify fixed string search","startedAt":"2008-02-26T12:22:04Z","lastAt":"2008-02-27T19:47:36Z","messageCount":9,"participants":["Jakub Narebski","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"69986","messageId":"1204028528-18941-1-git-send-email-jnareb@gmail.com","threadId":"12327","inReplyTo":null,"subject":"[PATCH 0/4] Improve gitweb search, and other things","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2008-02-26T12:22:04Z","receivedAt":"2008-02-26T12:22:04Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Table of contents:\n~~~~~~~~~~~~~~~~~~\n [PATCH 1/4] Add '--fixed-strings' option to \"git log --grep\" and friends\n [PATCH 2/4] gitweb: Change parse_commits signature to allow for\n             multiple options\n [PATCH 3/4] gitweb: Simplify fixed string search\n [PATCH 4/4] gitweb: Clearly distinguish regexp / exact match searches\n\nDescription of series:\n~~~~~~~~~~~~~~~~~~~~~~~\nWhen testing earlier improvements to gitweb commit search (searching\ncommit messages), I have noticed that searching for \"don't\" didn't\nfind anything from gitweb, while 'git log --grep=\"don't\"' returns\nquite a number of commits.  After examination I have realized that it\nwas caused by the fact that 'quotemeta' in Perl quotes also \"'\"\n(single quote character), and grep (which \"git log --grep=<pattern>\"\nuses) doesn't do the unquoting for unnecessary quoted characters.\n\nAt first I have thought about implementing our own limited quoting\nsubroutine, quoteregexmeta() to quote only regular expression\nmeta-characters.  The \"grep\" search (using git-grep) by default uses\nextended POSIX regexps, so there would be need also for\nquoteextremeta() subroutine, unless gitweb would pass '-E' option to\n\"git log\" when searching/limiting output.  This unfortunately needs\n_three_ versions of search query: original search text, to be passed\nfor \"next page\" links, fill default/current value of search form text\n(entry) field, and perhaps show in the page title; regexp quoted for\ngrep, to be passed to \"git log --grep\" and friends or \"git grep\";\nregexp quoted for Perl (we can use quotemeta() here) for showing match\ninfo (matched fragment).  It is a bit complicated and error prone. \n(Well, maybe all that is not really necessary...)\n\nWith git-grep search (tree search) and pickaxe search (diff search) it\nis easy, as pickaxe search is by default fixed strings search, and\ngit-grep has -F / --fixed-strings option.  Option which \n\"git log --grep=<pattern>\" was lacking...\n\nFirst commit in series adds then -F / --fixed-strings option for\nsearching commit messages by git-log / git-rev-list.  It was quite\neasy to do, thanks to well written infrastructure.  This patch can\nbe seen as standalone patch (adding option for consistency), and I\nhave even send it as\n  Message-Id: <200802241647.08871.jnareb@gmail.com>\nBut I have thought the chance of it being accepted would be better\nif there were some use case for it.\n\nTherefore next commits in series makes use of just introduced ability\nto use --fixed-strings option to consider the limiting patterns to be\nfixed strings.\n\nFor this we have to pass both --grep=$seachstring (or equivalent for\nother commit message search searchtypes) and --fixed-strings option.\nTherefore parse_commits() subroutine calling convention, which allowed\nto pass optionally only single extra option had to be changed.\n\nMeanwhile when looking at gitweb installed at http://repo.or.cz I seen\nthat it includes checkbox to switch between fixed strings search, and\nregexp search.  (IIRC patch was send to git mailing list, and lost\nsomehow, not being resent enough for inclusion[*1*]).  The repo.or.cz\ngitweb is based on 'next' branch of http://repo.or.cz/git/gitweb.git\nfork of git.  This change also required more than one pattern limiting\noption to be passed down to git-rev-list.\n\nSo I have then extracted this change, and put it as second commit in\nthis series.  This made it easy to implement fixed strings search in\ngitweb not by quoting regexp meta-characters, but by using just\nimplemented --fixed-strings option.\n\nFinally I have though \"why not\", and cherry-picked Petr \"Pasky\" Baudis\naddition of fixed-strings/regexp search checkbox.  This made last,\nfourth commit in this series.\n\n[*1*] Petr \"Pasky\" Baudis is much less active on git mailing list lately.\n\nShortlog:\n~~~~~~~~~\nJakub Narebski (3):\n      Add '--fixed-strings' option to \"git log --grep\" and friends\n      gitweb: Change parse_commits signature to allow for multiple options\n      gitweb: Simplify fixed string search\n\nPetr Baudis (1):\n      gitweb: Clearly distinguish regexp / exact match searches\n\nDiffstat:\n~~~~~~~~~\n Documentation/git-rev-list.txt     |    1 +\n Documentation/rev-list-options.txt |    5 +++\n gitweb/gitweb.perl                 |   58 +++++++++++++++++++++++------------\n revision.c                         |   10 +++++-\n 4 files changed, 53 insertions(+), 21 deletions(-)\n\n-- \n1.5.4.2\n"},{"id":"69984","messageId":"1204028528-18941-2-git-send-email-jnareb@gmail.com","threadId":"12327","inReplyTo":"1204028528-18941-1-git-send-email-jnareb@gmail.com","subject":"[PATCH 1/4] Add '--fixed-strings' option to \"git log --grep\" and friends","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2008-02-26T12:22:05Z","receivedAt":"2008-02-26T12:22:05Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Add support for -F | --fixed-strings option to \"git log --grep\"\nand friends: \"git log --author\", \"git log --committer=<pattern>\".\nCode is based on implementation of this option in \"git grep\".\n\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\nThis would simplify ignore-case searching for a fixed string from\nwithin gitweb, as gitweb wouldn't then have to deal with differences\nin quoting and unquoting (if you quote character which doesn't need\nquoting, would git (grep) unquote it?) between searched phrase,\nbasic/extended regular expression as understood by git/by grep,\nand regular expressions in Perl (when showing matched info).\n\n[I am not sure if the above paragraph should be added to commit\nmessage, so it is in patch comments. Feel free to add it.] \n\nThis patch can be also seen as \"consistency\" patch: git-grep\nimplements --fixed-strings, but \"git log --grep\" didn't.\n\n\nP.S. I see that neither git-log, nor git-grep are converted to\nparseopt interface. What are plans for it, if any?\n\n Documentation/git-rev-list.txt     |    1 +\n Documentation/rev-list-options.txt |    5 +++++\n revision.c                         |   10 +++++++++-\n 3 files changed, 15 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/git-rev-list.txt b/Documentation/git-rev-list.txt\nindex 5b96eab..a8d489f 100644\n--- a/Documentation/git-rev-list.txt\n+++ b/Documentation/git-rev-list.txt\n@@ -31,6 +31,7 @@ SYNOPSIS\n \t     [ \\--(author|committer|grep)=<pattern> ]\n \t     [ \\--regexp-ignore-case | \\-i ]\n \t     [ \\--extended-regexp | \\-E ]\n+\t     [ \\--fixed-strings | \\-F ]\n \t     [ \\--date={local|relative|default|iso|rfc|short} ]\n \t     [ [\\--objects | \\--objects-edge] [ \\--unpacked ] ]\n \t     [ \\--pretty | \\--header ]\ndiff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt\nindex a8138e2..259072c 100644\n--- a/Documentation/rev-list-options.txt\n+++ b/Documentation/rev-list-options.txt\n@@ -153,6 +153,11 @@ limiting may be applied.\n \tConsider the limiting patterns to be extended regular expressions\n \tinstead of the default basic regular expressions.\n \n+-F, --fixed-strings::\n+\n+\tConsider the limiting patterns to be fixed strings (don't interpret\n+\tpattern as a regular expression).\n+\n --remove-empty::\n \n \tStop when a given path disappears from the tree.\ndiff --git a/revision.c b/revision.c\nindex d3e8658..5df7961 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -942,6 +942,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch\n \tint left = 1;\n \tint all_match = 0;\n \tint regflags = 0;\n+\tint fixed = 0;\n \n \t/* First, search for \"--\" */\n \tseen_dashdash = 0;\n@@ -1238,6 +1239,11 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch\n \t\t\t\tregflags |= REG_ICASE;\n \t\t\t\tcontinue;\n \t\t\t}\n+\t\t\tif (!strcmp(arg, \"--fixed-strings\") ||\n+\t\t\t    !strcmp(arg, \"-F\")) {\n+\t\t\t\tfixed = 1;\n+\t\t\t\tcontinue;\n+\t\t\t}\n \t\t\tif (!strcmp(arg, \"--all-match\")) {\n \t\t\t\tall_match = 1;\n \t\t\t\tcontinue;\n@@ -1293,8 +1299,10 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch\n \t\t}\n \t}\n \n-\tif (revs->grep_filter)\n+\tif (revs->grep_filter) {\n \t\trevs->grep_filter->regflags |= regflags;\n+\t\trevs->grep_filter->fixed = fixed;\n+\t}\n \n \tif (show_merge)\n \t\tprepare_show_merge(revs);\n-- \n1.5.4.2\n"},{"id":"69985","messageId":"1204028528-18941-3-git-send-email-jnareb@gmail.com","threadId":"12327","inReplyTo":"1204028528-18941-1-git-send-email-jnareb@gmail.com","subject":"[PATCH 2/4] gitweb: Change parse_commits signature to allow for multiple options","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2008-02-26T12:22:06Z","receivedAt":"2008-02-26T12:22:06Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Change order of parameters in parse_commits() to have $filename\nbefore @args (extra options), to allow for multiple extra options,\nfor example both '--grep=<pattern>' and '--fixed-strings'.\n\nChange all callers to follow new calling convention.\n\nThis is part of commit b98f0a7c in http://repo.or.cz/git/gitweb.git\n  gitweb: Clearly distinguish regexp / exact match searches\nby Petr \"Pasky\" Baudis.\n\nSigned-off-by: Petr Baudis <pasky@suse.cz>\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\nThe paragraph starting with \"This is part of commit...\" can be now,\nI think, safely removed, as the rest of mentioned commit is now fourth\n(last) part of this patch series.\n\n\nBTW. I'm not quite sure about authorship and DCO (signoff) for this\npatch. It was a part of commit by pasky, but this commit was not\nwritten by him. I have written it based on parts of mentioned commit,\nfollowing variable naming and such; therefore I assumed authorship for\nthis commit.\n\nOriginal commit was signed off by pasky, and IMHO this signoff applies\nalso to the part of it, therefore I have used also pasky signoff.\n\n\n gitweb/gitweb.perl |   10 +++++-----\n 1 files changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex fc95e2c..3b4b15a 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -2079,7 +2079,7 @@ sub parse_commit {\n }\n \n sub parse_commits {\n-\tmy ($commit_id, $maxcount, $skip, $arg, $filename) = @_;\n+\tmy ($commit_id, $maxcount, $skip, $filename, @args) = @_;\n \tmy @cos;\n \n \t$maxcount ||= 1;\n@@ -2089,7 +2089,7 @@ sub parse_commits {\n \n \topen my $fd, \"-|\", git_cmd(), \"rev-list\",\n \t\t\"--header\",\n-\t\t($arg ? ($arg) : ()),\n+\t\t@args,\n \t\t(\"--max-count=\" . $maxcount),\n \t\t(\"--skip=\" . $skip),\n \t\t@extra_options,\n@@ -5172,7 +5172,7 @@ sub git_history {\n \t\t$ftype = git_get_type($hash);\n \t}\n \n-\tmy @commitlist = parse_commits($hash_base, 101, (100 * $page), \"--full-history\", $file_name);\n+\tmy @commitlist = parse_commits($hash_base, 101, (100 * $page), $file_name, \"--full-history\");\n \n \tmy $paging_nav = '';\n \tif ($page > 0) {\n@@ -5255,7 +5255,7 @@ sub git_search {\n \t\t\t$greptype = \"--committer=\";\n \t\t}\n \t\t$greptype .= $search_regexp;\n-\t\tmy @commitlist = parse_commits($hash, 101, (100 * $page), $greptype);\n+\t\tmy @commitlist = parse_commits($hash, 101, (100 * $page), undef, $greptype);\n \n \t\tmy $paging_nav = '';\n \t\tif ($page > 0) {\n@@ -5507,7 +5507,7 @@ sub git_feed {\n \n \t# log/feed of current (HEAD) branch, log of given branch, history of file/directory\n \tmy $head = $hash || 'HEAD';\n-\tmy @commitlist = parse_commits($head, 150, 0, undef, $file_name);\n+\tmy @commitlist = parse_commits($head, 150, 0, $file_name);\n \n \tmy %latest_commit;\n \tmy %latest_date;\n-- \n1.5.4.2\n"},{"id":"69983","messageId":"1204028528-18941-4-git-send-email-jnareb@gmail.com","threadId":"12327","inReplyTo":"1204028528-18941-1-git-send-email-jnareb@gmail.com","subject":"[PATCH 3/4] gitweb: Simplify fixed string search","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2008-02-26T12:22:07Z","receivedAt":"2008-02-26T12:22:07Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Use '--fixed-strings' option to git-rev-list to simplify and improve\nsearching commit messages (commit search).  It allows to search for\nexample for \"don't\" successfully.\n\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\nThe second part of this chunk follows \"correct style in neighborhood\nof changes\" idea.\n\n gitweb/gitweb.perl |    8 +++++---\n 1 files changed, 5 insertions(+), 3 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 3b4b15a..90cf78e 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -5254,14 +5254,16 @@ sub git_search {\n \t\t} elsif ($searchtype eq 'committer') {\n \t\t\t$greptype = \"--committer=\";\n \t\t}\n-\t\t$greptype .= $search_regexp;\n-\t\tmy @commitlist = parse_commits($hash, 101, (100 * $page), undef, $greptype);\n+\t\t$greptype .= $searchtext;\n+\t\tmy @commitlist = parse_commits($hash, 101, (100 * $page), undef,\n+\t\t                               $greptype, '--fixed-strings');\n \n \t\tmy $paging_nav = '';\n \t\tif ($page > 0) {\n \t\t\t$paging_nav .=\n \t\t\t\t$cgi->a({-href => href(action=>\"search\", hash=>$hash,\n-\t\t\t\t                       searchtext=>$searchtext, searchtype=>$searchtype)},\n+\t\t\t\t                       searchtext=>$searchtext,\n+\t\t\t\t                       searchtype=>$searchtype)},\n \t\t\t\t        \"first\");\n \t\t\t$paging_nav .= \" &sdot; \" .\n \t\t\t\t$cgi->a({-href => href(-replay=>1, page=>$page-1),\n-- \n1.5.4.2\n"},{"id":"69987","messageId":"1204028528-18941-5-git-send-email-jnareb@gmail.com","threadId":"12327","inReplyTo":"1204028528-18941-1-git-send-email-jnareb@gmail.com","subject":"[PATCH 4/4] gitweb: Clearly distinguish regexp / exact match searches","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2008-02-26T12:22:08Z","receivedAt":"2008-02-26T12:22:08Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"From: Petr Baudis <pasky@ucw.cz>\n\nThis patch does a couple of things:\n\n* Makes commit/author/committer search case insensitive\n\n\tTo be consistent with the grep search; I see no convincing\n\treason for the search to be case sensitive, and you might\n\tget in trouble especially with contributors e.g. from Japan\n\tor France where they sometimes like to uppercase their last\n\tname.\n\n* Makes grep search by default search for fixed strings\n\n\tSince we will have a checkbox.\n\n* Introduces 're' checkbox that enables POSIX extended regexp searches\n\n\tThis works for all the search types. The idea comes from Jakub.\n\nIt does not make much sense (and is not easy at all) to untangle most\nof these changes from each other, thus they all go in a single patch.\n\n[jn: Cherry-picked from Pasky's http://repo.or.cz/git/gitweb.git]\n\nSigned-off-by: Petr Baudis <pasky@suse.cz>\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\nCherry-picked, and resolved conflict.\n\n gitweb/gitweb.perl |   44 ++++++++++++++++++++++++++++++--------------\n 1 files changed, 30 insertions(+), 14 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 90cf78e..20dc5d5 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -472,13 +472,15 @@ if (defined $searchtype) {\n \t}\n }\n \n+our $search_use_regexp = $cgi->param('sr');\n+\n our $searchtext = $cgi->param('s');\n our $search_regexp;\n if (defined $searchtext) {\n \tif (length($searchtext) < 2) {\n \t\tdie_error(undef, \"At least two characters are required for search parameter\");\n \t}\n-\t$search_regexp = quotemeta $searchtext;\n+\t$search_regexp = $search_use_regexp ? $searchtext : quotemeta $searchtext;\n }\n \n # now read PATH_INFO and use it as alternative to parameters\n@@ -608,6 +610,7 @@ sub href(%) {\n \t\tsearchtype => \"st\",\n \t\tsnapshot_format => \"sf\",\n \t\textra_options => \"opt\",\n+\t\tsearch_use_regexp => \"sr\",\n \t);\n \tmy %mapping = @mapping;\n \n@@ -2584,6 +2587,10 @@ EOF\n \t\t      $cgi->sup($cgi->a({-href => href(action=>\"search_help\")}, \"?\")) .\n \t\t      \" search:\\n\",\n \t\t      $cgi->textfield(-name => \"s\", -value => $searchtext) . \"\\n\" .\n+\t\t      \"<span title=\\\"Extended regular expression\\\">\" .\n+\t\t      $cgi->checkbox(-name => 'sr', -value => 1, -label => 're',\n+\t\t                     -checked => $search_use_regexp) .\n+\t\t      \"</span>\" .\n \t\t      \"</div>\" .\n \t\t      $cgi->end_form() . \"\\n\";\n \t}\n@@ -5256,7 +5263,8 @@ sub git_search {\n \t\t}\n \t\t$greptype .= $searchtext;\n \t\tmy @commitlist = parse_commits($hash, 101, (100 * $page), undef,\n-\t\t                               $greptype, '--fixed-strings');\n+\t\t                               $greptype, '--regexp-ignore-case',\n+\t\t                               $search_use_regexp ? '--extended-regexp' : '--fixed-strings');\n \n \t\tmy $paging_nav = '';\n \t\tif ($page > 0) {\n@@ -5300,8 +5308,9 @@ sub git_search {\n \t\tmy $git_command = git_cmd_str();\n \t\tmy $searchqtext = $searchtext;\n \t\t$searchqtext =~ s/'/'\\\\''/;\n+\t\tmy $pickaxe_flags = $search_use_regexp ? '--pickaxe-regex' : '';\n \t\topen my $fd, \"-|\", \"$git_command rev-list $hash | \" .\n-\t\t\t\"$git_command diff-tree -r --stdin -S\\'$searchqtext\\'\";\n+\t\t\t\"$git_command diff-tree -r --stdin -S\\'$searchqtext\\' $pickaxe_flags\";\n \t\tundef %co;\n \t\tmy @files;\n \t\twhile (my $line = <$fd>) {\n@@ -5365,7 +5374,9 @@ sub git_search {\n \t\tmy $alternate = 1;\n \t\tmy $matches = 0;\n \t\t$/ = \"\\n\";\n-\t\topen my $fd, \"-|\", git_cmd(), 'grep', '-n', '-i', '-E', $searchtext, $co{'tree'};\n+\t\topen my $fd, \"-|\", git_cmd(), 'grep', '-n',\n+\t\t\t$search_use_regexp ? ('-E', '-i') : '-F',\n+\t\t\t$searchtext, $co{'tree'};\n \t\tmy $lastfile = '';\n \t\twhile (my $line = <$fd>) {\n \t\t\tchomp $line;\n@@ -5395,7 +5406,7 @@ sub git_search {\n \t\t\t\tprint \"<div class=\\\"binary\\\">Binary file</div>\\n\";\n \t\t\t} else {\n \t\t\t\t$ltext = untabify($ltext);\n-\t\t\t\tif ($ltext =~ m/^(.*)($searchtext)(.*)$/i) {\n+\t\t\t\tif ($ltext =~ m/^(.*)($search_regexp)(.*)$/i) {\n \t\t\t\t\t$ltext = esc_html($1, -nbsp=>1);\n \t\t\t\t\t$ltext .= '<span class=\"match\">';\n \t\t\t\t\t$ltext .= esc_html($2, -nbsp=>1);\n@@ -5430,27 +5441,31 @@ sub git_search_help {\n \tgit_header_html();\n \tgit_print_page_nav('','', $hash,$hash,$hash);\n \tprint <<EOT;\n+<p><strong>Pattern</strong> is by default a normal string that is matched precisely (but without\n+regard to case, except in the case of pickaxe). However, when you check the <em>re</em> checkbox,\n+the pattern entered is recognized as the POSIX extended\n+<a href=\"http://en.wikipedia.org/wiki/Regular_expression\">regular expression</a> (also case\n+insensitive).</p>\n <dl>\n <dt><b>commit</b></dt>\n-<dd>The commit messages and authorship information will be scanned for the given string.</dd>\n+<dd>The commit messages and authorship information will be scanned for the given pattern.</dd>\n EOT\n \tmy ($have_grep) = gitweb_check_feature('grep');\n \tif ($have_grep) {\n \t\tprint <<EOT;\n <dt><b>grep</b></dt>\n <dd>All files in the currently selected tree (HEAD unless you are explicitly browsing\n-    a different one) are searched for the given\n-<a href=\"http://en.wikipedia.org/wiki/Regular_expression\">regular expression</a>\n-(POSIX extended) and the matches are listed. On large\n-trees, this search can take a while and put some strain on the server, so please use it with\n-some consideration.</dd>\n+    a different one) are searched for the given pattern. On large trees, this search can take\n+a while and put some strain on the server, so please use it with some consideration. Note that\n+due to git-grep peculiarity, currently if regexp mode is turned off, the matches are\n+case-sensitive.</dd>\n EOT\n \t}\n \tprint <<EOT;\n <dt><b>author</b></dt>\n-<dd>Name and e-mail of the change author and date of birth of the patch will be scanned for the given string.</dd>\n+<dd>Name and e-mail of the change author and date of birth of the patch will be scanned for the given pattern.</dd>\n <dt><b>committer</b></dt>\n-<dd>Name and e-mail of the committer and date of commit will be scanned for the given string.</dd>\n+<dd>Name and e-mail of the committer and date of commit will be scanned for the given pattern.</dd>\n EOT\n \tmy ($have_pickaxe) = gitweb_check_feature('pickaxe');\n \tif ($have_pickaxe) {\n@@ -5458,7 +5473,8 @@ EOT\n <dt><b>pickaxe</b></dt>\n <dd>All commits that caused the string to appear or disappear from any file (changes that\n added, removed or \"modified\" the string) will be listed. This search can take a while and\n-takes a lot of strain on the server, so please use it wisely.</dd>\n+takes a lot of strain on the server, so please use it wisely. Note that since you may be\n+interested even in changes just changing the case as well, this search is case sensitive.</dd>\n EOT\n \t}\n \tprint \"</dl>\\n\";\n-- \n1.5.4.2\n"},{"id":"70053","messageId":"7vfxvf2osk.fsf@gitster.siamese.dyndns.org","threadId":"12327","inReplyTo":"1204028528-18941-2-git-send-email-jnareb@gmail.com","subject":"Re: [PATCH 1/4] Add '--fixed-strings' option to \"git log --grep\" and friends","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-02-27T01:03:55Z","receivedAt":"2008-02-27T01:03:55Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jakub Narebski <jnareb@gmail.com> writes:\n\n> Add support for -F | --fixed-strings option to \"git log --grep\"\n> and friends: \"git log --author\", \"git log --committer=<pattern>\".\n> Code is based on implementation of this option in \"git grep\".\n>\n> Signed-off-by: Jakub Narebski <jnareb@gmail.com>\n> ---\n> This would simplify ignore-case searching for a fixed string from\n> within gitweb, as gitweb wouldn't then have to deal with differences\n> in quoting and unquoting (if you quote character which doesn't need\n> quoting, would git (grep) unquote it?) between searched phrase,\n> basic/extended regular expression as understood by git/by grep,\n> and regular expressions in Perl (when showing matched info).\n>\n> [I am not sure if the above paragraph should be added to commit\n> message, so it is in patch comments. Feel free to add it.] \n\nI do not understand the issue from reading that paragraph, so it\nprobably means that (1) it does not help even if it is in the\ncommit log message, and/or (2) more readable explanation may\nhelp in the commit log message ;-).\n\nThe rule for grep input should be known by anybody who writes\nscripts around grep, so I do not think this patch is absolutely\nnecessary if this is only for gitweb.  But for command line\nend-user usage, fixed string search _might be_ useful, although\nI've personally never felt need for that.  So I am reluctant to\nsee it grab a short-and-sweet -F option letter that might have\nbetter uses, but I do not have major objection against a more\nexplicit --fixed-strings.\n\nBy the way, do you allow the default regexp search in gitweb?\nIf so, how do you handle a malformed regexp that a user gives\nyou?  For example,\n\n\t$ git log --grep=\"don\\('t\" -1\n\nbarfs, and I suspect that you can catch the exit status 128 from\ndie() and say something other than \"nothing found\" if you really\nwanted to.\n"},{"id":"70055","messageId":"200802270237.18044.jnareb@gmail.com","threadId":"12327","inReplyTo":"7vfxvf2osk.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 1/4] Add '--fixed-strings' option to \"git log --grep\" and friends","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2008-02-27T01:37:16Z","receivedAt":"2008-02-27T01:37:16Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Junio C Hamano wrote:\n> Jakub Narebski <jnareb@gmail.com> writes:\n> \n> > Add support for -F | --fixed-strings option to \"git log --grep\"\n> > and friends: \"git log --author\", \"git log --committer=<pattern>\".\n> > Code is based on implementation of this option in \"git grep\".\n> >\n> > Signed-off-by: Jakub Narebski <jnareb@gmail.com>\n> > ---\n> > This would simplify ignore-case searching for a fixed string from\n> > within gitweb, as gitweb wouldn't then have to deal with differences\n> > in quoting and unquoting (if you quote character which doesn't need\n> > quoting, would git (grep) unquote it?) between searched phrase,\n> > basic/extended regular expression as understood by git/by grep,\n> > and regular expressions in Perl (when showing matched info).\n> >\n> > [I am not sure if the above paragraph should be added to commit\n> > message, so it is in patch comments. Feel free to add it.] \n> \n> I do not understand the issue from reading that paragraph, so it\n> probably means that (1) it does not help even if it is in the\n> commit log message, and/or (2) more readable explanation may\n> help in the commit log message ;-).\n\nWhat I meant here that gitweb using --fixed-strings option for\ncommit message search is example usage of this new feature. \n\nOtherwise we would have to have in gitweb original $searchtext\n(for links, description, page title, etc.), $search_grep_regexp\n(for grep, or rather for \"git log --grep\" and friends, basic/extended \nregexp meta quoted), and finally $search_regexp to be used in gitweb, \ni.e. in Perl to show match.\n\n> The rule for grep input should be known by anybody who writes\n> scripts around grep, so I do not think this patch is absolutely\n> necessary if this is only for gitweb.\n\nI have written it this way not only because it is simpler than correct \nescaping, but also because git-grep has this option (consistency).\nBesides it was very easy to add.\n\n> But for command line \n> end-user usage, fixed string search _might be_ useful, although\n> I've personally never felt need for that.  So I am reluctant to\n> see it grab a short-and-sweet -F option letter that might have\n> better uses, but I do not have major objection against a more\n> explicit --fixed-strings.\n\nFeel free to drop support for '-F' short option then, both in code\nand in documentation.\n\nI have checked that git-log doesn't support '-F' short option; \nadditionally '-F' is used in git commands as '--file', i.e. \"-F <file>\" \nto get contents (commit message, tag comment/message). Therefore it was \nunlikely that \"git log\" and friends would acquire \"-F <file>\" option.\n\n> By the way, do you allow the default regexp search in gitweb?\n> If so, how do you handle a malformed regexp that a user gives\n> you?  For example,\n> \n> \t$ git log --grep=\"don\\('t\" -1\n> \n> barfs, and I suspect that you can catch the exit status 128 from\n> die() and say something other than \"nothing found\" if you really\n> wanted to.\n\nErrr... to be sure I don't know. From what I have checked it shows\n\"nothing found\", but I guess it could be more explicit.\n\n-- \nJakub Narebski\nPoland\n"},{"id":"70072","messageId":"200802271020.21662.jnareb@gmail.com","threadId":"12327","inReplyTo":"7vfxvf2osk.fsf@gitster.siamese.dyndns.org","subject":"[PATCH 1/4 (alternate)] Add '--fixed-strings' option to \"git log --grep\" and friends","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2008-02-27T09:20:21Z","receivedAt":"2008-02-27T09:20:21Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Add support for '--fixed-strings' option to \"git log --grep\"\nand friends: \"git log --author\", \"git log --committer\".\nCode is based on implementation of this option in \"git grep\".\n\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\nOn Wed, 27 Feb 2008, Junio C Hamano wrote:\n\n> So I am reluctant to\n> see it grab a short-and-sweet -F option letter that might have\n> better uses, but I do not have major objection against a more\n> explicit --fixed-strings.\n\nThis version doesn't use '-F' short option.\n\n Documentation/git-rev-list.txt     |    1 +\n Documentation/rev-list-options.txt |    5 +++++\n revision.c                         |    9 ++++++++-\n 3 files changed, 14 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/git-rev-list.txt b/Documentation/git-rev-list.txt\nindex 5b96eab..0291225 100644\n--- a/Documentation/git-rev-list.txt\n+++ b/Documentation/git-rev-list.txt\n@@ -31,6 +31,7 @@ SYNOPSIS\n \t     [ \\--(author|committer|grep)=<pattern> ]\n \t     [ \\--regexp-ignore-case | \\-i ]\n \t     [ \\--extended-regexp | \\-E ]\n+\t     [ \\--fixed-strings ]\n \t     [ \\--date={local|relative|default|iso|rfc|short} ]\n \t     [ [\\--objects | \\--objects-edge] [ \\--unpacked ] ]\n \t     [ \\--pretty | \\--header ]\ndiff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt\nindex a8138e2..826ac62 100644\n--- a/Documentation/rev-list-options.txt\n+++ b/Documentation/rev-list-options.txt\n@@ -153,6 +153,11 @@ limiting may be applied.\n \tConsider the limiting patterns to be extended regular expressions\n \tinstead of the default basic regular expressions.\n \n+--fixed-strings::\n+\n+\tConsider the limiting patterns to be fixed strings (don't interpret\n+\tpattern as a regular expression).\n+\n --remove-empty::\n \n \tStop when a given path disappears from the tree.\ndiff --git a/revision.c b/revision.c\nindex d3e8658..4daeac1 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -942,6 +942,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch\n \tint left = 1;\n \tint all_match = 0;\n \tint regflags = 0;\n+\tint fixed = 0;\n \n \t/* First, search for \"--\" */\n \tseen_dashdash = 0;\n@@ -1238,6 +1239,10 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch\n \t\t\t\tregflags |= REG_ICASE;\n \t\t\t\tcontinue;\n \t\t\t}\n+\t\t\tif (!strcmp(arg, \"--fixed-strings\")) {\n+\t\t\t\tfixed = 1;\n+\t\t\t\tcontinue;\n+\t\t\t}\n \t\t\tif (!strcmp(arg, \"--all-match\")) {\n \t\t\t\tall_match = 1;\n \t\t\t\tcontinue;\n@@ -1293,8 +1298,10 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch\n \t\t}\n \t}\n \n-\tif (revs->grep_filter)\n+\tif (revs->grep_filter) {\n \t\trevs->grep_filter->regflags |= regflags;\n+\t\trevs->grep_filter->fixed = fixed;\n+\t}\n \n \tif (show_merge)\n \t\tprepare_show_merge(revs);\n-- \n1.5.4.2\n"},{"id":"70148","messageId":"7vpruitc4n.fsf@gitster.siamese.dyndns.org","threadId":"12327","inReplyTo":"200802271020.21662.jnareb@gmail.com","subject":"Re: [PATCH 1/4 (alternate)] Add '--fixed-strings' option to \"git log --grep\" and friends","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-02-27T19:47:36Z","receivedAt":"2008-02-27T19:47:36Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jakub Narebski <jnareb@gmail.com> writes:\n\n>> So I am reluctant to\n>> see it grab a short-and-sweet -F option letter that might have\n>> better uses, but I do not have major objection against a more\n>> explicit --fixed-strings.\n>\n> This version doesn't use '-F' short option.\n\nThanks for re-rolling, but after having slept on it, I think\nyour original is just fine, so I'll take it with short and sweet\n\"-F\" option.\n"}]}