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

Re: [PATCH 2/2] grep: use slash for path delimiter, not colon

From
JMJonathon Mah <jmah@me.com>
Date
Sep 22, 2013, 19:15 UTC
Message-ID
<99F7DE7C-A8D7-4EDF-B9C5-8DB143BFDB53@me.com>
Show 8 quoted lines
> >     HEAD:/some/path/to/foo.txt
> >     HEAD:some/path/to/foo.txt
> 
> With my patch it prints the latter.
> 
> This is because get_sha1_with_context("HEAD:"...) returns an empty
> 'path' string.  The code decides to use ':' as the delimiter in that
> case, but it sees there already is one at the end of "HEAD:".
A few days ago I came across the same "surprising" output of git-grep, tried to adjust the code to print "git show"-able object names, and ran into similar subtleties. I just found this thread, and Jeff's code handles more cases than mine did (I didn't try Phil's initial patch), but I can add some more test cases with non-showable output (again related to git-grep's path scoping):

$ git grep -l cache HEAD:./ | head -1 HEAD:./:.gitignore

$ cd Documentation $ git grep -l cache HEAD | head -1 HEAD:CodingGuidelines

$ git grep -l cache HEAD:Documentation/CodingGuidelines ../HEAD:Documentation/CodingGuidelines (woah!)

Sorry that I don't yet have anything useful to suggest! But I can tell the story of my use case:
I have a large repository (1.6GB bare) which I don't work on, but which contains code that I need to refer to. A checkout is ~600MB and 27k files, which I'd like to avoid (it's redundant data, and would slow down backups of my drive). I found myself "git-grep"ping through parts of the tree, looking through the results, and then "git-show"ing interesting files. Having a real object name in the grep output allows copy-and-paste of the object path.

Jonathon Mah me@JonathonMah.com

Next: Jeff King
Message 1 of 2 in “Re: [PATCH 2/2] grep: use slash for path delimiter, not colon”
  1. Jonathon MahSep 22, 2013
  2. Jeff KingSep 24, 2013

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.