git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH 2/2] grep: use slash for path delimiter, not colon
@ 2013-09-22 19:15 Jonathon Mah
  2013-09-24  6:57 ` Jeff King
  0 siblings, 1 reply; 8+ messages in thread
From: Jonathon Mah @ 2013-09-22 19:15 UTC (permalink / raw)
  To: phil.hord, Jeff King; +Cc: git@vger.kernel.org

> >     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

^ permalink raw reply	[flat|nested] 8+ messages in thread
* Re: [PATCHv2] grep: use slash for path delimiter, not colon
@ 2013-08-26 19:53 Jeff King
  2013-08-26 19:56 ` [PATCH 2/2] " Jeff King
  0 siblings, 1 reply; 8+ messages in thread
From: Jeff King @ 2013-08-26 19:53 UTC (permalink / raw)
  To: Phil Hord; +Cc: git, phil.hord, Junio C Hamano, Jonathan Nieder

On Mon, Aug 26, 2013 at 03:28:26PM -0400, Jeff King wrote:

> Changing the object_array API would be hard, but I don't think we need
> to do it here. Can we simply stop using object_array to pass the list,
> and instead just have a custom list?
> 
> I'll see how painful that is.

Not very, I think. Here's the series.

  [1/2]: grep: stop using object_array
  [2/2]: grep: use slash for path delimiter, not colon

-Peff

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-09-24  6:57 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-22 19:15 [PATCH 2/2] grep: use slash for path delimiter, not colon Jonathon Mah
2013-09-24  6:57 ` Jeff King
  -- strict thread matches above, loose matches on Subject: below --
2013-08-26 19:53 [PATCHv2] " Jeff King
2013-08-26 19:56 ` [PATCH 2/2] " Jeff King
2013-08-26 20:13   ` Johannes Sixt
2013-08-26 20:52     ` Phil Hord
2013-08-26 20:52     ` Jeff King
2013-08-26 21:03       ` Phil Hord
2013-08-26 21:13         ` Jeff King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).