Skip to content

Commit 5d34d1a

Browse files
peffgitster
authored andcommitted
revision: do not fallback to default when rev_input_given is set
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0159ba3 commit 5d34d1a

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

revision.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2316,7 +2316,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
23162316
opt->tweak(revs, opt);
23172317
if (revs->show_merge)
23182318
prepare_show_merge(revs);
2319-
if (revs->def && !revs->pending.nr && !got_rev_arg) {
2319+
if (revs->def && !revs->pending.nr && !revs->rev_input_given && !got_rev_arg) {
23202320
struct object_id oid;
23212321
struct object *object;
23222322
struct object_context oc;

t/t4202-log.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,6 +1523,12 @@ test_expect_success 'log diagnoses bogus HEAD' '
15231523
test_i18ngrep broken stderr
15241524
'
15251525

1526+
test_expect_success 'log does not default to HEAD when rev input is given' '
1527+
>expect &&
1528+
git log --branches=does-not-exist >actual &&
1529+
test_cmp expect actual
1530+
'
1531+
15261532
test_expect_success 'set up --source tests' '
15271533
git checkout --orphan source-a &&
15281534
test_commit one &&

0 commit comments

Comments
 (0)