From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org, Reece Dunn <msclrhd@googlemail.com>
Subject: Re: [RFC] improve 'bad default revision' message for empty repo
Date: Tue, 04 Mar 2008 18:43:25 -0800 [thread overview]
Message-ID: <7v7igh51rm.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <20080305010701.GB20007@sigill.intra.peff.net> (Jeff King's message of "Tue, 4 Mar 2008 20:07:02 -0500")
Jeff King <peff@peff.net> writes:
> On Tue, Mar 04, 2008 at 09:51:02PM +0000, Reece Dunn wrote:
>
>> > > Consider the following workflow:
>> > >
>> > > $ mkdir foo
>> > > $ cd foo
>> > > $ git --bare init
>> > >
>> > > $ git log
>> > > fatal: bad default revision 'HEAD'
>> > >
>> > > This message is confusing for a newbie. Displaying "no commits" would
>> > > make more sense here.
>
> What do people think of this patch? It feels a little hack-ish to make
> guesses as to the reasons for a failure, but in my experience an empty
> repo is the cause of this message in 99% of cases.
>
> We could special-case it to HEAD and make a better message, perhaps, but
> that feels even more hack-ish.
How about doing it this way instead, then?
Saying "fatal: You haven't made a commit?" is like saying "How stupid do
you have to be to realize that you are not allowed to run git-log before
making a commit, dummy?", but that is not the message we need to be
sending. Asking for log is fine. If you are on an unborn branch and say
"git log", you deserve to get nothing. Not even an error message.
Not that I haven't thought through the ramifications of this yet; some
callers may need to be adjusted, but they should be prepared for a case
where no rev was given from the command line anyway.
---
revision.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/revision.c b/revision.c
index 63bf2c5..cdd5ad2 100644
--- a/revision.c
+++ b/revision.c
@@ -1323,10 +1323,10 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
unsigned char sha1[20];
struct object *object;
unsigned mode;
- if (get_sha1_with_mode(def, sha1, &mode))
- die("bad default revision '%s'", def);
- object = get_reference(revs, def, sha1, 0);
- add_pending_object_with_mode(revs, object, def, mode);
+ if (!get_sha1_with_mode(def, sha1, &mode)) {
+ object = get_reference(revs, def, sha1, 0);
+ add_pending_object_with_mode(revs, object, def, mode);
+ }
}
/* Did the user ask for any diff output? Run the diff! */
next prev parent reply other threads:[~2008-03-05 2:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-01 19:40 Some issues working with empty/bare repositories Reece Dunn
2008-03-03 8:10 ` Jeff King
2008-03-04 21:51 ` Reece Dunn
2008-03-05 1:07 ` [RFC] improve 'bad default revision' message for empty repo Jeff King
2008-03-05 2:43 ` Junio C Hamano [this message]
2008-03-05 4:33 ` Jeff King
2008-03-05 8:48 ` Junio C Hamano
2008-03-05 9:10 ` Jeff King
2008-03-05 9:25 ` 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=7v7igh51rm.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=msclrhd@googlemail.com \
--cc=peff@peff.net \
/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).