Skip to content
/ git Public
forked from git/git

Commit

Permalink
revision: do not fallback to default when rev_input_given is set
Browse files Browse the repository at this point in the history
If revs->def is set (as it is in "git log") and there are no
pending objects after parsing the user's input, then we show
whatever is in "def". But if the user _did_ ask for some
input that just happened to be empty (e.g., "--glob" that
does not match anything), showing the default revision is
confusing. We should just show nothing, as that is what the
user's request yielded.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
peff authored and gitster committed Aug 2, 2017
1 parent 0159ba3 commit 5d34d1a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion revision.c
Original file line number Diff line number Diff line change
Expand Up @@ -2316,7 +2316,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
opt->tweak(revs, opt);
if (revs->show_merge)
prepare_show_merge(revs);
if (revs->def && !revs->pending.nr && !got_rev_arg) {
if (revs->def && !revs->pending.nr && !revs->rev_input_given && !got_rev_arg) {
struct object_id oid;
struct object *object;
struct object_context oc;
Expand Down
6 changes: 6 additions & 0 deletions t/t4202-log.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1523,6 +1523,12 @@ test_expect_success 'log diagnoses bogus HEAD' '
test_i18ngrep broken stderr
'

test_expect_success 'log does not default to HEAD when rev input is given' '
>expect &&
git log --branches=does-not-exist >actual &&
test_cmp expect actual
'

test_expect_success 'set up --source tests' '
git checkout --orphan source-a &&
test_commit one &&
Expand Down

0 comments on commit 5d34d1a

Please sign in to comment.