Re: [RFC] improve 'bad default revision' message for empty repo

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Mar 04, 2008 at 06:43:25PM -0800, Junio C Hamano wrote:

> 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.

I like that behavior much better, but...

> 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);
> +		}
>  	}
>  

I'm not sure it's this easy. We're basically just ignoring the error
return from get_sha1_with_mode, but do we really want to ignore _all_
errors? Specifically, should "git log --default foobar" silently produce
no commits?

I think a tighter rule that would accomplish the same thing is "if we
resolve to a ref that is yet-to-be-born, then ignore." But unfortunately
that information is lost deep within the bowels of get_sha1_with_mode.

But maybe this is good enough. It is, after all, just the "default" so
perhaps it makes sense to treat all errors as soft errors. And it will
almost always be HEAD, I think. The only script which seems to use
--default is git-svn. I'm not clear on why you would want to use
--default rather than simply specifying the refs you want.

-Peff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux