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
Jeff King <peff@peff.net>
Date
Aug 26, 2013, 21:13 UTC
Message-ID
<20130826211320.GA26417@sigill.intra.peff.net>
In-Reply-To
<CABURp0pPzRH5JdPEooyZw0iccD891E1i_CbTqDfVJnx+drfQEw@mail.gmail.com>
On Mon, Aug 26, 2013 at 05:03:04PM -0400, Phil Hord wrote:
Show 10 quoted lines
> >   $ git grep -l foo HEAD | head -1
> >   HEAD:RelNotes/1.5.1.5.txt
> >
> > we still limit to the current directory, but the output does not note
> > this (it should be "HEAD:./RelNotes/1.5.1.5.txt"). I think this bug is
> > orthogonal to Phil's patch, though.
> 
> Maybe not.  My path completes the assumption that the L:R value
> returned by grep is an object ref; but Junio still thought it wasn't.
> I think this is another case where his view was correct.

I certainly assumed it was, because it is in most cases it is. And something like "HEAD:RelNotes/1.5.1.5.txt" certainly _looks_ like one, and is generated by the current git. And what is the point of coming up with a file listing if the names you return do not actually exist?

Show 7 quoted lines
> There's more bad news on this front.
> 
>     $ cd Documentation
>     $ git grep -l foo HEAD .. | head -1
>     HEAD:../.gitignore
> 
> That's not a valid ref, either (though maybe it could be).

Yes, though we seem to normalize paths already. So the other entries from that command are (in git.git):

  HEAD:../.mailmap
  HEAD:RelNotes/1.5.1.5.txt
So we could either:
  1. Prepend the current path before normalizing to yield:
      HEAD:.mailmap
      HEAD:Documentation/RelNotes/1.5.1.5.txt
  2. Teach the get_sha1 path parser about "..", and prepend "./" when we
     are in a prefixed subdir.
      HEAD:./../.mailmap
      HEAD:./RelNotes/1.5.1.5.txt
-Peff
Previous: Phil HordNext: Junio C Hamano
Message 10 of 11 in “[PATCHv2] grep: use slash for path delimiter, not colon”
  1. Phil HordAug 26, 2013
  2. Jeff KingAug 26, 2013
  3. Jeff KingAug 26, 2013
  4. 1/2 grep: stop using object_arrayJeff King, Aug 26, 2013
  5. 2/2 grep: use slash for path delimiter, not colonJeff King, Aug 26, 2013
  6. Johannes SixtAug 26, 2013
  7. Phil HordAug 26, 2013
  8. Jeff KingAug 26, 2013
  9. Phil HordAug 26, 2013
  10. Jeff KingAug 26, 2013
  11. Junio C HamanoAug 27, 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.