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

Re: [PATCH 0/5] gitweb: Improve search code

From
Phil Hord <hordp@cisco.com>
Date
Jun 22, 2011, 17:10 UTC
Message-ID
<4E02220F.10800@cisco.com>
In-Reply-To
<1308756535-29701-1-git-send-email-jnareb@gmail.com>
Admin note: Should I have changed the subject or kept it?
On 06/22/2011 11:28 AM, Jakub Narebski wrote:
> P.S. Another addition that I sometimes wanted git to have would be
> 'filename' or 'find' search: searching for file by name.
>
> What do you think of it?
I like it.  +1 from me.

I normally revert to 'git log --name-status | less <CR> /filename.foo', which is awful, of course. I've always assumed there's a better way I haven't discovered yet. But if there is, well... I haven't discovered it yet.

This syntax works on some files, but is limited and/or broken:
   # Finds all commits touching the file named './foo.bar', iff
./foo.bar exists in the current commit.
   git log -- foo.bar
I say 'broken', but maybe it's not; it feels like it is when I do this:
   # Returns zero logs
   git log -- some-deleted-file.txt
   # Returns at least two logs
   git log --all -- some-deleted-file.txt

I think I understand why that happens (search optimization), but it is unexpected from the user's perspective. I also suspect it will miss the 'pre-resurrection' commits for files which were deleted and resurrected in the past.

What do you think of these as new 'Commit limiters' for git log:
       --name=<pattern>, --name-glob=<glob>
           Limit the commits output to ones touching files that match the
           specified pattern (regular expression) or glob (shell glob
pattern).
This could be further modified by --diff-filter, --all-match, etc.
   # Find all commits which deleted a file named **/foo.**
   git log --name="/foo[.]" --diff-filter=D
   # Find all commits which deleted a file named **/foo.**
   #   or one named **/bar.**
   git log --name="/foo[.]" --name="/bar[.]" --diff-filter=D
   # Find all commits which touched both a file named **/foo.**
   #   and one named **/bar.**
   git log --name="/foo[.]" --name="/bar[.]" --all-match
Or this alternate form:
       --name-pattern, --name-glob
           Treat all <path> selectors as pattern (regular expression) or
glob (shell glob pattern).

I think I prefer the former, since the latter does not allow for a combination of raw names, pattern names and glob names. Also, it does not (intuitively) support --all-match.

   # Find all commits which deleted a file named **/foo.**
   git log --name-pattern --diff-filter=D -- "/foo[.]"
   git log --name-glob --diff-filter=D -- "/foo.*"
   # Find all commits which deleted a file named **/foo.**
   #   or one named **/bar.**
   git log --name-pattern --diff-filter=D -- "/foo[.]" "/bar[.]"
   # Find all commits which touched both a file named **/foo.**
   #   and one named **/bar.**
   #  -- Can't be done?

Finally, do the extensions belong on rev-list as well? The 'git rev-list' command seems underpowered compared to 'git log'.

Phil
Previous: Jakub NarebskiNext: Jakub Narebski
Message 7 of 10 in “gitweb: Improve search code”
  1. 0/5 gitweb: Improve search codeJakub Narebski, Jun 22, 2011
  2. 1/5 gitweb: 'pickaxe' and 'grep' features requires 'search' to be enabledJakub Narebski, Jun 22, 2011
  3. 2/5 gitweb: Check permissions first in git_searchJakub Narebski, Jun 22, 2011
  4. 3/5 gitweb: Split body of git_search into subroutinesJakub Narebski, Jun 22, 2011
  5. 4/5 gitweb: Clean up code in git_search_* subroutinesJakub Narebski, Jun 22, 2011
  6. 5/5 gitweb: Make git_search_* subroutines render whole pagesJakub Narebski, Jun 22, 2011
  7. Phil HordJun 22, 2011
  8. Jakub NarebskiJun 22, 2011
  9. Phil HordJun 22, 2011
  10. Junio C HamanoJun 22, 2011

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.