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:40:32 -0500 [thread overview]
Message-ID: <20160229124032.GA21158@sigill.intra.peff.net> (raw)
In-Reply-To: <20160229114455.GD29769@sigill.intra.peff.net>
On Mon, Feb 29, 2016 at 06:44:55AM -0500, Jeff King wrote:
> [...]but it would be easy to change:
>
> diff --git a/builtin/cat-file.c b/builtin/cat-file.c
> index 54db118..afde169 100644
> --- a/builtin/cat-file.c
> +++ b/builtin/cat-file.c
> @@ -35,6 +35,9 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
> if (unknown_type)
> flags |= LOOKUP_UNKNOWN_OBJECT;
>
> + if (opt == 'e')
> + return !has_sha1_file(sha1);
> +
> if (get_sha1_with_context(obj_name, 0, sha1, &obj_context))
> die("Not a valid object name %s", obj_name);
>
> @@ -58,9 +61,6 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
> printf("%lu\n", size);
> return 0;
>
> - case 'e':
> - return !has_sha1_file(sha1);
> -
> case 'c':
> if (!obj_context.path[0])
> die("git cat-file --textconv %s: <object> must be <sha1:path>",
This is wrong, of course. We still need to call get_sha1, but just need
to not die. So it's more like this (totally untested, naturally):
diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index 54db118..44add8c 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -35,8 +35,11 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
if (unknown_type)
flags |= LOOKUP_UNKNOWN_OBJECT;
- if (get_sha1_with_context(obj_name, 0, sha1, &obj_context))
+ if (get_sha1_with_context(obj_name, 0, sha1, &obj_context)) {
+ if (opt == 'e')
+ return 1;
die("Not a valid object name %s", obj_name);
+ }
buf = NULL;
switch (opt) {
-Peff
prev parent reply other threads:[~2016-02-29 12:40 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
2016-02-29 12:40 ` Jeff King [this message]
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=20160229124032.GA21158@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).