diff mbox series

[v4,01/16] bisect: verify that a bogus option won't try to start a bisection

Message ID 30ddbd7affc83e9b20ecdd66d941f1acc2cbc787.1656354677.git.gitgitgadget@gmail.com (mailing list archive)
State New, archived
Headers show
Series Finish converting git bisect into a built-in | expand

Commit Message

Johannes Schindelin June 27, 2022, 6:31 p.m. UTC
From: Johannes Schindelin <johannes.schindelin@gmx.de>

We do not want `git bisect --bogus-option` to start a bisection. To
verify that, we look for the tell-tale error message `You need to start
by "git bisect start"` and fail if it was found.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 t/t6030-bisect-porcelain.sh | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Junio C Hamano June 28, 2022, 2:12 a.m. UTC | #1
"Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
writes:

> From: Johannes Schindelin <johannes.schindelin@gmx.de>
>
> We do not want `git bisect --bogus-option` to start a bisection. To
> verify that, we look for the tell-tale error message `You need to start
> by "git bisect start"` and fail if it was found.
>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---

Sorry, but this looks unclear to me.

In the test "--bisect-terms" is used, and from "git grep" it does
seem to be one of the valid options "git bisect--helper" can take.
It is unclear if the patch wanted to literally use "--bogus-option"
insteaed of it but used "--bisect-terms" by mistake, or if that
valid option is "bogus" only in the sense that the option is not yet
relevant immediately after "git bisect reset" before a new "git
bisect start" session has begun.  IOW, "bogus" both in the patch
title and the test title needs to be clarified.

To put it another way, can we demonstrate the same correctness by
seeing "git bisect --no-such-option" fail immediately after "git
bisect reset"?



>  t/t6030-bisect-porcelain.sh | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh
> index 83931d482fb..6d6e72276ae 100755
> --- a/t/t6030-bisect-porcelain.sh
> +++ b/t/t6030-bisect-porcelain.sh
> @@ -900,6 +900,16 @@ test_expect_success 'bisect start with one term1 and term2' '
>  	git bisect reset
>  '
>  
> +test_expect_success 'bogus command does not start bisect' '
> +	git bisect reset &&
> +	test_must_fail git bisect --bisect-terms 1 2 2>out &&
> +	! grep "You need to start" out &&
> +	test_must_fail git bisect --bisect-terms 2>out &&
> +	! grep "You need to start" out &&
> +	grep "git bisect.*visualize" out &&
> +	git bisect reset
> +'
> +
>  test_expect_success 'bisect replay with term1 and term2' '
>  	git bisect replay log_to_replay.txt >bisect_result &&
>  	grep "$HASH2 is the first term1 commit" bisect_result &&
diff mbox series

Patch

diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh
index 83931d482fb..6d6e72276ae 100755
--- a/t/t6030-bisect-porcelain.sh
+++ b/t/t6030-bisect-porcelain.sh
@@ -900,6 +900,16 @@  test_expect_success 'bisect start with one term1 and term2' '
 	git bisect reset
 '
 
+test_expect_success 'bogus command does not start bisect' '
+	git bisect reset &&
+	test_must_fail git bisect --bisect-terms 1 2 2>out &&
+	! grep "You need to start" out &&
+	test_must_fail git bisect --bisect-terms 2>out &&
+	! grep "You need to start" out &&
+	grep "git bisect.*visualize" out &&
+	git bisect reset
+'
+
 test_expect_success 'bisect replay with term1 and term2' '
 	git bisect replay log_to_replay.txt >bisect_result &&
 	grep "$HASH2 is the first term1 commit" bisect_result &&