public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox•com>
To: Jeff King <peff@peff•net>
Cc: Tummala Dhanvi <dhanvicse@gmail•com>,
	Git Mailing List <git@vger•kernel.org>
Subject: Re: [PATCH] log: diagnose empty HEAD more clearly
Date: Fri, 05 Jun 2015 13:47:40 -0700	[thread overview]
Message-ID: <xmqqvbf1rifn.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <20150604083430.GB5771@peff.net> (Jeff King's message of "Thu, 4 Jun 2015 04:34:30 -0400")

Jeff King <peff@peff•net> writes:

> But if you are OK to eventually stop dying, I think this line of
> reasoning is OK.
>
>> diff --git a/builtin/log.c b/builtin/log.c
>> index 4c4e6be..3b568a1 100644
>> --- a/builtin/log.c
>> +++ b/builtin/log.c
>> @@ -148,6 +148,9 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
>>  		rev->diffopt.output_format |= DIFF_FORMAT_NO_OUTPUT;
>>  	argc = setup_revisions(argc, argv, rev, opt);
>>  
>> +	if (!rev->pending.nr && !opt->def)
>> +		die("you do not have a commit yet on your branch");
>
> Do we want to mention the name of the branch here? I guess it does not
> really matter. Perhaps "the current branch" would be better than "your
> branch", though. Maybe:
>
>   fatal: you do not have any commits yet on the current branch
>
> This message hopefully goes away in the long run, but we'll have it for
> a while.
>
>> +static void default_to_head_if_exists(struct setup_revision_opt *opt)
>> +{
>> +	unsigned char unused[20];
>> +
>> +	if (resolve_ref_unsafe("HEAD", RESOLVE_REF_READING, unused, NULL))
>> +		opt->def = "HEAD";
>> +}
>
> This approach looks sane to me. Want to wrap it up with a commit
> message and a test?

There is an unmerged attempt jc/log-missing-default-HEAD in my
"broken-out" repository https://github.com/gitster/git; I do agree
that we should spend more cycles after deciding to error out to
give a more detailed diagnosis, but I didn't have enough energy
to bring myself do that, so I've tentatively merged your version
instead of this one.

  reply	other threads:[~2015-06-05 20:47 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-03  5:54 Minor bug report Tummala Dhanvi
2015-06-03  6:20 ` Jeff King
2015-06-03  6:48   ` Junio C Hamano
2015-06-03  8:14     ` [PATCH] log: diagnose empty HEAD more clearly Jeff King
2015-06-03 17:24       ` Junio C Hamano
2015-06-04  7:31         ` Stefan Näwe
2015-06-04  8:45           ` Jeff King
2015-06-04  8:34         ` Jeff King
2015-06-05 20:47           ` Junio C Hamano [this message]
2015-06-03 15:39     ` Minor bug report Dennis Kaarsemaker
2015-06-04  8:21       ` 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=xmqqvbf1rifn.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox$(echo .)com \
    --cc=dhanvicse@gmail$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=peff@peff$(echo .)net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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