Skip to content

Commit 4cd66e7

Browse files
ramsay-jonesgitster
authored andcommitted
bisect--helper: use BISECT_TERMS in 'bisect skip' command
Commit e4c7b33 ("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/[email protected]/T/#m207791568054b0f8cf1a3942878ea36293273c7d Reported-by: Trygve Aaberge <[email protected]> Signed-off-by: Bagas Sanjaya <[email protected]> Signed-off-by: Ramsay Jones <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 311531c commit 4cd66e7

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

builtin/bisect--helper.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,6 +1126,7 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
11261126
break;
11271127
case BISECT_SKIP:
11281128
set_terms(&terms, "bad", "good");
1129+
get_terms(&terms);
11291130
res = bisect_skip(&terms, argv, argc);
11301131
break;
11311132
default:

t/t6030-bisect-porcelain.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -922,6 +922,17 @@ test_expect_success 'bisect start takes options and revs in any order' '
922922
test_cmp expected actual
923923
'
924924

925+
# Bisect is started with --term-new and --term-old arguments,
926+
# then skip. The HEAD should be changed.
927+
test_expect_success 'bisect skip works with --term*' '
928+
git bisect reset &&
929+
git bisect start --term-new=fixed --term-old=unfixed HEAD $HASH1 &&
930+
hash_skipped_from=$(git rev-parse --verify HEAD) &&
931+
git bisect skip &&
932+
hash_skipped_to=$(git rev-parse --verify HEAD) &&
933+
test "$hash_skipped_from" != "$hash_skipped_to"
934+
'
935+
925936
test_expect_success 'git bisect reset cleans bisection state properly' '
926937
git bisect reset &&
927938
git bisect start &&

0 commit comments

Comments
 (0)