diff options
author | Junio C Hamano <gitster@pobox.com> | 2015-06-03 10:24:02 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-06-03 13:00:54 -0700 |
commit | e813563bc0cc911188309ca8a2eb42228c38cf5e (patch) | |
tree | 577182679f682e06d6e4678628b5afb515d09860 /revision.h | |
parent | f86f31ab33c3406adebbb9f9f61be550dcc5a472 (diff) | |
download | git-jc/log-missing-default-HEAD.tar.gz |
log: diagnose empty HEAD more clearlyjc/log-missing-default-HEAD
If you init or clone an empty repository, the initial message from
running "git log" is not very friendly:
$ git init
Initialized empty Git repository in /home/peff/foo/.git/
$ git log
fatal: bad default revision 'HEAD'
The user didn't say anything about 'HEAD'. This error is given only
because "git log" and friends blindly default to 'HEAD' without even
checking if that is a sensible default to use. We can instead detect
this case and give them a more friendly error message.
$ git log
fatal: you do not have a commit yet on your branch
In a future version of Git, if we are willing to accept an
incompatiblity to give a better end-user experience like we did at
2.0, it may even make more sense to turn this an non-error in such a
future version of Git. If you have one commit and ask "log", you
get one commit back. If you have no commit and ask "log", it is OK
to say that you should get nothing back without fuss. But that is
outside the scope of this change.
Note that we still do fail if the user explicitly says HEAD from the
command line, and this is very much deliberate:
$ git log HEAD --
fatal: bad revision 'HEAD'
$ git log HEAD
fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
In these cases, unlike the parameter-less case where the command
implicitly defaults to use "HEAD", the user claims HEAD must be
usable as a valid committish object name, and we are diagnosing
that the claim is false and issuing an error.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'revision.h')
-rw-r--r-- | revision.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/revision.h b/revision.h index 0ea8b4e255..0838ef1db3 100644 --- a/revision.h +++ b/revision.h @@ -228,6 +228,7 @@ extern volatile show_early_output_fn_t show_early_output; struct setup_revision_opt { const char *def; + int def_HEAD_missing; void (*tweak)(struct rev_info *, struct setup_revision_opt *); const char *submodule; int assume_dashdash; |