]> git.ipfire.org Git - thirdparty/git.git/commitdiff
bisect--helper: use BISECT_TERMS in 'bisect skip' command
authorRamsay Jones <ramsay@ramsayjones.plus.com>
Thu, 29 Apr 2021 20:15:15 +0000 (21:15 +0100)
committerJunio C Hamano <gitster@pobox.com>
Fri, 30 Apr 2021 00:56:42 +0000 (09:56 +0900)
Commit e4c7b33747 ("bisect--helper: reimplement `bisect_skip` shell
function in C", 2021-02-03), as part of the shell-to-C conversion,
forgot to read the 'terms' file (.git/BISECT_TERMS) during the new
'bisect skip' command implementation. As a result, the 'bisect skip'
command will use the default 'bad'/'good' terms. If the bisection
terms have been set to non-default values (for example by the
'bisect start' command), then the 'bisect skip' command will fail.

In order to correct this problem, we insert a call to the get_terms()
function, which reads the non-default terms from that file (if set),
in the '--bisect-skip' command implementation of 'bisect--helper'.

Also, add a test[1] to protect against potential future regression.

[1] https://lore.kernel.org/git/xmqqim45h585.fsf@gitster.g/T/#m207791568054b0f8cf1a3942878ea36293273c7d

Reported-by: Trygve Aaberge <trygveaa@gmail.com>
Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>
Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/bisect--helper.c
t/t6030-bisect-porcelain.sh

index 1fdb7d9d1060b46c4e4e357765549b9a893a2130..9d9540a0abfe20e4a725797ba7aad65eecfd5d92 100644 (file)
@@ -1126,6 +1126,7 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
                break;
        case BISECT_SKIP:
                set_terms(&terms, "bad", "good");
+               get_terms(&terms);
                res = bisect_skip(&terms, argv, argc);
                break;
        default:
index 32bb66e1eda44cfa1de67ab7c168bd856fc9d421..a1baf4e4511d33e5519a5e4feb5423342203fe36 100755 (executable)
@@ -922,6 +922,17 @@ test_expect_success 'bisect start takes options and revs in any order' '
        test_cmp expected actual
 '
 
+# Bisect is started with --term-new and --term-old arguments,
+# then skip. The HEAD should be changed.
+test_expect_success 'bisect skip works with --term*' '
+       git bisect reset &&
+       git bisect start --term-new=fixed --term-old=unfixed HEAD $HASH1 &&
+       hash_skipped_from=$(git rev-parse --verify HEAD) &&
+       git bisect skip &&
+       hash_skipped_to=$(git rev-parse --verify HEAD) &&
+       test "$hash_skipped_from" != "$hash_skipped_to"
+'
+
 test_expect_success 'git bisect reset cleans bisection state properly' '
        git bisect reset &&
        git bisect start &&