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

[PATCH 0/4] Improve gitweb search, and other things

From
Jakub Narebski <jnareb@gmail.com>
Date
Feb 26, 2008, 12:22 UTC
Message-ID
<1204028528-18941-1-git-send-email-jnareb@gmail.com>
Table of contents:
~~~~~~~~~~~~~~~~~~
 [PATCH 1/4] Add '--fixed-strings' option to "git log --grep" and friends
 [PATCH 2/4] gitweb: Change parse_commits signature to allow for
             multiple options
 [PATCH 3/4] gitweb: Simplify fixed string search
 [PATCH 4/4] gitweb: Clearly distinguish regexp / exact match searches

Description of series: ~~~~~~~~~~~~~~~~~~~~~~~ When testing earlier improvements to gitweb commit search (searching commit messages), I have noticed that searching for "don't" didn't find anything from gitweb, while 'git log --grep="don't"' returns quite a number of commits. After examination I have realized that it was caused by the fact that 'quotemeta' in Perl quotes also "'" (single quote character), and grep (which "git log --grep=<pattern>" uses) doesn't do the unquoting for unnecessary quoted characters.

At first I have thought about implementing our own limited quoting subroutine, quoteregexmeta() to quote only regular expression meta-characters. The "grep" search (using git-grep) by default uses extended POSIX regexps, so there would be need also for quoteextremeta() subroutine, unless gitweb would pass '-E' option to "git log" when searching/limiting output. This unfortunately needs _three_ versions of search query: original search text, to be passed for "next page" links, fill default/current value of search form text (entry) field, and perhaps show in the page title; regexp quoted for grep, to be passed to "git log --grep" and friends or "git grep"; regexp quoted for Perl (we can use quotemeta() here) for showing match info (matched fragment). It is a bit complicated and error prone. (Well, maybe all that is not really necessary...)

With git-grep search (tree search) and pickaxe search (diff search) it is easy, as pickaxe search is by default fixed strings search, and git-grep has -F / --fixed-strings option. Option which "git log --grep=<pattern>" was lacking...

First commit in series adds then -F / --fixed-strings option for
searching commit messages by git-log / git-rev-list.  It was quite
easy to do, thanks to well written infrastructure.  This patch can
be seen as standalone patch (adding option for consistency), and I
have even send it as
  Message-Id: <200802241647.08871.jnareb@gmail.com>
But I have thought the chance of it being accepted would be better
if there were some use case for it.

Therefore next commits in series makes use of just introduced ability to use --fixed-strings option to consider the limiting patterns to be fixed strings.

For this we have to pass both --grep=$seachstring (or equivalent for other commit message search searchtypes) and --fixed-strings option. Therefore parse_commits() subroutine calling convention, which allowed to pass optionally only single extra option had to be changed.

Meanwhile when looking at gitweb installed at http://repo.or.cz I seen that it includes checkbox to switch between fixed strings search, and regexp search. (IIRC patch was send to git mailing list, and lost somehow, not being resent enough for inclusion[*1*]). The repo.or.cz gitweb is based on 'next' branch of http://repo.or.cz/git/gitweb.git fork of git. This change also required more than one pattern limiting option to be passed down to git-rev-list.

So I have then extracted this change, and put it as second commit in this series. This made it easy to implement fixed strings search in gitweb not by quoting regexp meta-characters, but by using just implemented --fixed-strings option.

Finally I have though "why not", and cherry-picked Petr "Pasky" Baudis addition of fixed-strings/regexp search checkbox. This made last, fourth commit in this series.

[*1*] Petr "Pasky" Baudis is much less active on git mailing list lately.
Shortlog:
~~~~~~~~~
Jakub Narebski (3):
      Add '--fixed-strings' option to "git log --grep" and friends
      gitweb: Change parse_commits signature to allow for multiple options
      gitweb: Simplify fixed string search
Petr Baudis (1):
      gitweb: Clearly distinguish regexp / exact match searches
Diffstat:
~~~~~~~~~
 Documentation/git-rev-list.txt     |    1 +
 Documentation/rev-list-options.txt |    5 +++
 gitweb/gitweb.perl                 |   58 +++++++++++++++++++++++------------
 revision.c                         |   10 +++++-
 4 files changed, 53 insertions(+), 21 deletions(-)
-- 
1.5.4.2
Next: Jakub Narebski
Message 1 of 9 in “Improve gitweb search, and other things”
  1. 0/4 Improve gitweb search, and other thingsJakub Narebski, Feb 26, 2008
  2. 1/4 Add '--fixed-strings' option to "git log --grep" and friendsJakub Narebski, Feb 26, 2008
  3. Junio C HamanoFeb 27, 2008
  4. Jakub NarebskiFeb 27, 2008
  5. 1/4 Add '--fixed-strings' option to "git log --grep" and friendsJakub Narebski, Feb 27, 2008
  6. Junio C HamanoFeb 27, 2008
  7. 2/4 gitweb: Change parse_commits signature to allow for multiple optionsJakub Narebski, Feb 26, 2008
  8. 3/4 gitweb: Simplify fixed string searchJakub Narebski, Feb 26, 2008
  9. 4/4 gitweb: Clearly distinguish regexp / exact match searchesJakub Narebski, Feb 26, 2008

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.