Skip to content

Commit be5fe20

Browse files
alipman88gitster
authored andcommitted
cmd_bisect__helper: defer parsing no-checkout flag
cmd_bisect__helper() is intended as a temporary shim layer serving as an interface for git-bisect.sh. This function and git-bisect.sh should eventually be replaced by a C implementation, cmd_bisect(), serving as an entrypoint for all "git bisect ..." shell commands: cmd_bisect() will only parse the first token following "git bisect", and dispatch the remaining args to the appropriate function ["bisect_start()", "bisect_next()", etc.]. Thus, cmd_bisect__helper() should not be responsible for parsing flags like --no-checkout. Instead, let the --no-checkout flag remain in the argv array, so it may be evaluated alongside the other options already parsed by bisect_start(). Signed-off-by: Aaron Lipman <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0fe305a commit be5fe20

File tree

4 files changed

+10
-13
lines changed

4 files changed

+10
-13
lines changed

bisect.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -989,14 +989,15 @@ void read_bisect_terms(const char **read_bad, const char **read_good)
989989
* If no_checkout is non-zero, the bisection process does not
990990
* checkout the trial commit but instead simply updates BISECT_HEAD.
991991
*/
992-
enum bisect_error bisect_next_all(struct repository *r, const char *prefix, int no_checkout)
992+
enum bisect_error bisect_next_all(struct repository *r, const char *prefix)
993993
{
994994
struct rev_info revs;
995995
struct commit_list *tried;
996996
int reaches = 0, all = 0, nr, steps;
997997
enum bisect_error res = BISECT_OK;
998998
struct object_id *bisect_rev;
999999
char *steps_msg;
1000+
int no_checkout = ref_exists("BISECT_HEAD");
10001001
int first_parent_only = 0; /* TODO: pass --first-parent flag from git bisect start */
10011002

10021003
read_bisect_terms(&term_bad, &term_good);

bisect.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@ enum bisect_error {
5858
BISECT_INTERNAL_SUCCESS_MERGE_BASE = -11
5959
};
6060

61-
enum bisect_error bisect_next_all(struct repository *r,
62-
const char *prefix,
63-
int no_checkout);
61+
enum bisect_error bisect_next_all(struct repository *r, const char *prefix);
6462

6563
int estimate_bisect_steps(int all);
6664

builtin/bisect--helper.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ static GIT_PATH_FUNC(git_path_head_name, "head-name")
1919
static GIT_PATH_FUNC(git_path_bisect_names, "BISECT_NAMES")
2020

2121
static const char * const git_bisect_helper_usage[] = {
22-
N_("git bisect--helper --next-all [--no-checkout]"),
22+
N_("git bisect--helper --next-all"),
2323
N_("git bisect--helper --write-terms <bad_term> <good_term>"),
2424
N_("git bisect--helper --bisect-clean-state"),
2525
N_("git bisect--helper --bisect-reset [<commit>]"),
@@ -421,9 +421,9 @@ static int bisect_append_log_quoted(const char **argv)
421421
return res;
422422
}
423423

424-
static int bisect_start(struct bisect_terms *terms, int no_checkout,
425-
const char **argv, int argc)
424+
static int bisect_start(struct bisect_terms *terms, const char **argv, int argc)
426425
{
426+
int no_checkout = 0;
427427
int i, has_double_dash = 0, must_write_terms = 0, bad_seen = 0;
428428
int flags, pathspec_pos, res = 0;
429429
struct string_list revs = STRING_LIST_INIT_DUP;
@@ -632,7 +632,7 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
632632
BISECT_TERMS,
633633
BISECT_START
634634
} cmdmode = 0;
635-
int no_checkout = 0, res = 0, nolog = 0;
635+
int res = 0, nolog = 0;
636636
struct option options[] = {
637637
OPT_CMDMODE(0, "next-all", &cmdmode,
638638
N_("perform 'git bisect next'"), NEXT_ALL),
@@ -654,8 +654,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
654654
N_("print out the bisect terms"), BISECT_TERMS),
655655
OPT_CMDMODE(0, "bisect-start", &cmdmode,
656656
N_("start the bisect session"), BISECT_START),
657-
OPT_BOOL(0, "no-checkout", &no_checkout,
658-
N_("update BISECT_HEAD instead of checking out the current commit")),
659657
OPT_BOOL(0, "no-log", &nolog,
660658
N_("no log for BISECT_WRITE")),
661659
OPT_END()
@@ -671,7 +669,7 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
671669

672670
switch (cmdmode) {
673671
case NEXT_ALL:
674-
res = bisect_next_all(the_repository, prefix, no_checkout);
672+
res = bisect_next_all(the_repository, prefix);
675673
break;
676674
case WRITE_TERMS:
677675
if (argc != 2)
@@ -713,7 +711,7 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
713711
break;
714712
case BISECT_START:
715713
set_terms(&terms, "bad", "good");
716-
res = bisect_start(&terms, no_checkout, argv, argc);
714+
res = bisect_start(&terms, argv, argc);
717715
break;
718716
default:
719717
return error("BUG: unknown subcommand '%d'", cmdmode);

git-bisect.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ bisect_next() {
153153
git bisect--helper --bisect-next-check $TERM_GOOD $TERM_BAD $TERM_GOOD|| exit
154154

155155
# Perform all bisection computation, display and checkout
156-
git bisect--helper --next-all $(test -f "$GIT_DIR/BISECT_HEAD" && echo --no-checkout)
156+
git bisect--helper --next-all
157157
res=$?
158158

159159
# Check if we should exit because bisection is finished

0 commit comments

Comments
 (0)