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

Re: [PATCHv2] grep: use slash for path delimiter, not colon

From
Jeff King <peff@peff.net>
Date
Aug 26, 2013, 19:28 UTC
Message-ID
<20130826192826.GA23598@sigill.intra.peff.net>
In-Reply-To
<1377528372-31206-1-git-send-email-hordp@cisco.com>
On Mon, Aug 26, 2013 at 10:46:12AM -0400, Phil Hord wrote:
Show 6 quoted lines
> This version is a bit more deterministic and also adds a test.
> 
> It accepts the expense of examining the path argument again to 
> determine if it is a tree-ish + path rather than just a tree (commit).
> The get_sha1 call occurs one extra time for each tree-ish argument,
> so it's not expensive.

I don't like this approach in general because it lacks atomicity. IOW, the thing you are looking up may change between the two get_sha1 calls. You're _almost_ good here because you don't actually care what the second call returns, but only which features it _would_ have used. But you may see the second call fail because the ref doesn't exist anymore, or points to a different tree, and you will erroneously use ":" instead of "/".

I admit this is not that likely, but I'd really rather avoid introducing such races if we can.

> We avoid mucking with the object_array API this way, and also do not
> rely on the object-type to tell us anything about the way the object
> name was spelled.

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.
-Peff
Previous: Phil HordNext: Jeff King
Message 2 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.