From 0c5dc7431a01d325e815ce722d80ad549a41e632 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Wed, 2 Aug 2017 18:24:51 -0400 Subject: t6018: flesh out empty input/output rev-list tests In 751a2ac6e (rev-list --exclude: tests, 2013-11-01), we added a few tests for handling "empty" inputs with rev-list (i.e., where the user gave us some pattern but it turned out not to queue any objects for traversal), all of which were marked as failing. In preparation for working on this area of the code, let's give each test a more descriptive name. Let's also include one more case which we should cover: feeding a --glob pattern that doesn't match anything. We can also drop the explanatory comment; we'll be converting these to expect_success in the next few patches, so the discussion isn't necessary. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/t6018-rev-list-glob.sh | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 't') diff --git a/t/t6018-rev-list-glob.sh b/t/t6018-rev-list-glob.sh index 381f35ed16..f8367b829c 100755 --- a/t/t6018-rev-list-glob.sh +++ b/t/t6018-rev-list-glob.sh @@ -255,27 +255,19 @@ test_expect_success 'rev-list accumulates multiple --exclude' ' compare rev-list "--exclude=refs/remotes/* --exclude=refs/tags/* --all" --branches ' - -# "git rev-list" is likely to be a bug in the calling script and may -# deserve an error message, but do cases where set of refs programmatically -# given using globbing and/or --stdin need to fail with the same error, or -# are we better off reporting a success with no output? The following few -# tests document the current behaviour to remind us that we might want to -# think about this issue. - -test_expect_failure 'rev-list may want to succeed with empty output on no input (1)' ' +test_expect_failure 'rev-list should succeed with empty output on empty stdin' ' >expect && git rev-list --stdin actual && test_cmp expect actual ' -test_expect_failure 'rev-list may want to succeed with empty output on no input (2)' ' +test_expect_failure 'rev-list should succeed with empty output with all refs excluded' ' >expect && git rev-list --exclude=* --all >actual && test_cmp expect actual ' -test_expect_failure 'rev-list may want to succeed with empty output on no input (3)' ' +test_expect_failure 'rev-list should succeed with empty output with empty --all' ' ( test_create_repo empty && cd empty && @@ -285,6 +277,12 @@ test_expect_failure 'rev-list may want to succeed with empty output on no input ) ' +test_expect_failure 'rev-list should succeed with empty output with empty glob' ' + >expect && + git rev-list --glob=does-not-match-anything >actual && + test_cmp expect actual +' + test_expect_success 'shortlog accepts --glob/--tags/--remotes' ' compare shortlog "subspace/one subspace/two" --branches=subspace && -- cgit v1.2.1 From 0159ba3226f75fbd6d3dc0e92c325cb11f2f0699 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Wed, 2 Aug 2017 18:26:06 -0400 Subject: rev-list: don't show usage when we see empty ref patterns If the user gives us no starting point for a traversal, we want to complain with our normal usage message. But if they tried to do so with "--all" or "--glob", but that happened not to match any refs, the usage message isn't helpful. We should just give them the empty output they asked for instead. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/t6018-rev-list-glob.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 't') diff --git a/t/t6018-rev-list-glob.sh b/t/t6018-rev-list-glob.sh index f8367b829c..d3453c583c 100755 --- a/t/t6018-rev-list-glob.sh +++ b/t/t6018-rev-list-glob.sh @@ -261,13 +261,13 @@ test_expect_failure 'rev-list should succeed with empty output on empty stdin' ' test_cmp expect actual ' -test_expect_failure 'rev-list should succeed with empty output with all refs excluded' ' +test_expect_success 'rev-list should succeed with empty output with all refs excluded' ' >expect && git rev-list --exclude=* --all >actual && test_cmp expect actual ' -test_expect_failure 'rev-list should succeed with empty output with empty --all' ' +test_expect_success 'rev-list should succeed with empty output with empty --all' ' ( test_create_repo empty && cd empty && @@ -277,7 +277,7 @@ test_expect_failure 'rev-list should succeed with empty output with empty --all' ) ' -test_expect_failure 'rev-list should succeed with empty output with empty glob' ' +test_expect_success 'rev-list should succeed with empty output with empty glob' ' >expect && git rev-list --glob=does-not-match-anything >actual && test_cmp expect actual -- cgit v1.2.1 From 5d34d1ac06fe70fc0a7a8f35ddf9e7690114dda7 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Wed, 2 Aug 2017 18:30:19 -0400 Subject: 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 Signed-off-by: Junio C Hamano --- t/t4202-log.sh | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 't') diff --git a/t/t4202-log.sh b/t/t4202-log.sh index 3f3531f0a4..36d120c969 100755 --- a/t/t4202-log.sh +++ b/t/t4202-log.sh @@ -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 && -- cgit v1.2.1