git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Phil Hord <hordp@cisco.com>
Cc: git@vger.kernel.org, phil.hord@gmail.com,
	Junio C Hamano <gitster@pobox.com>,
	Jonathan Nieder <jrnieder@gmail.com>
Subject: Re: [PATCHv2] grep: use slash for path delimiter, not colon
Date: Mon, 26 Aug 2013 15:28:26 -0400	[thread overview]
Message-ID: <20130826192826.GA23598@sigill.intra.peff.net> (raw)
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:

> 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

  reply	other threads:[~2013-08-26 19:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-26 14:46 [PATCHv2] grep: use slash for path delimiter, not colon Phil Hord
2013-08-26 19:28 ` Jeff King [this message]
2013-08-26 19:53   ` Jeff King
2013-08-26 19:54     ` [PATCH 1/2] grep: stop using object_array Jeff King
2013-08-26 19:56     ` [PATCH 2/2] grep: use slash for path delimiter, not colon 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
2013-08-27  3:37     ` [PATCHv2] " Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130826192826.GA23598@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=hordp@cisco.com \
    --cc=jrnieder@gmail.com \
    --cc=phil.hord@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).