From: Jakob Pfender <jpfender@elegosoft.com>
To: git@vger.kernel.org
Subject: [PATCH] revision.c: Clarify error message for missing objects
Date: Mon, 14 Mar 2011 16:11:54 +0100 [thread overview]
Message-ID: <4D7E303A.5090605@elegosoft.com> (raw)
In-Reply-To: <7vzkp1y0jr.fsf@alter.siamese.dyndns.org>
[Sorry Junio, accidentally sent this to just you the first time around]
If "git show" is invoked on a hash for a file that doesn't exist, the
produced error message was "fatal: bad object <hash>". This is
misleading as the object isn't bad, but missing. As a matter of fact, if
an object is bad, this error message is never produced, because
parse_object() terminates with its own error message if the object is
corrupt.
This patch introduces a check to see whether an object exists (with the
appropriate error message if it doesn't) and removes the unnecessary and
misleading original error message if parse_object() fails.
Signed-off-by: Jakob Pfender <jpfender@elegosoft.com>
---
revision.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/revision.c b/revision.c
index 86d2470..085aac2 100644
--- a/revision.c
+++ b/revision.c
@@ -173,9 +173,9 @@ static struct object *get_reference(struct rev_info
*revs, const char *name, con
{
struct object *object;
+ if (sha1_object_info(sha1, NULL) < 0)
+ die("Not a valid object name %s", name);
object = parse_object(sha1);
- if (!object)
- die("bad object %s", name);
object->flags |= flags;
return object;
}
--
1.7.0.4
next prev parent reply other threads:[~2011-03-14 15:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-11 18:28 [Buglet] "git show <random-40-hexdigit>" gives an unclear error message Junio C Hamano
2011-03-14 15:11 ` Jakob Pfender [this message]
2011-03-14 17:40 ` [PATCH] revision.c: Clarify error message for missing objects 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=4D7E303A.5090605@elegosoft.com \
--to=jpfender@elegosoft.com \
--cc=git@vger.kernel.org \
/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).