From: Jeff King <peff@peff.net>
To: "Michal Čihař" <michal@cihar.com>
Cc: git@vger.kernel.org
Subject: Re: git cat-file -e behavior
Date: Mon, 29 Feb 2016 07:36:45 -0500 [thread overview]
Message-ID: <20160229123645.GA20754@sigill.intra.peff.net> (raw)
In-Reply-To: <56D436A2.4090202@cihar.com>
On Mon, Feb 29, 2016 at 01:16:34PM +0100, Michal Čihař wrote:
> Dne 29.2.2016 v 12:44 Jeff King napsal(a):
> > It looks like it has been this way forever. The first thing we do with
> > the object is resolve its name to a sha1, and that's where the error you
> > see comes from. And then we actually check whether we have the object.
> >
> > I think the intended use was to feed it a sha1 to see if it exists. Then
> > the name-resolution step is a noop.
>
> I found this as best way to check whether file exists in branch.
> Checking git ls-tree output seems less error prone than checking return
> value of git cat-file -e...
I think the usual way to do that would be:
git rev-parse --verify $branch:$path >/dev/null
which just resolves the name (not that what you are doing is wrong, I
just think rev-parse is the way we usually do it in our scripts).
That _will_ write a message to stderr when the name doesn't resolve.
-Peff
next prev parent reply other threads:[~2016-02-29 12:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-29 9:58 git cat-file -e behavior Michal Čihař
2016-02-29 11:44 ` Jeff King
2016-02-29 12:16 ` Michal Čihař
2016-02-29 12:36 ` Jeff King [this message]
2016-02-29 12:40 ` Jeff King
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=20160229123645.GA20754@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=michal@cihar.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).