]> git.ipfire.org Git - thirdparty/git.git/commitdiff
cmd_bisect__helper: defer parsing no-checkout flag
authorAaron Lipman <alipman88@gmail.com>
Fri, 7 Aug 2020 21:58:36 +0000 (17:58 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 7 Aug 2020 22:13:03 +0000 (15:13 -0700)
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 <alipman88@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
bisect.c
bisect.h
builtin/bisect--helper.c
git-bisect.sh

index a11fdb14734b6e03117c92c1876473153ccefd68..950ff6f533aeeb579174cc2fdacac8058c485e2a 100644 (file)
--- a/bisect.c
+++ b/bisect.c
@@ -989,7 +989,7 @@ void read_bisect_terms(const char **read_bad, const char **read_good)
  * If no_checkout is non-zero, the bisection process does not
  * checkout the trial commit but instead simply updates BISECT_HEAD.
  */
-enum bisect_error bisect_next_all(struct repository *r, const char *prefix, int no_checkout)
+enum bisect_error bisect_next_all(struct repository *r, const char *prefix)
 {
        struct rev_info revs;
        struct commit_list *tried;
@@ -997,6 +997,7 @@ enum bisect_error bisect_next_all(struct repository *r, const char *prefix, int
        enum bisect_error res = BISECT_OK;
        struct object_id *bisect_rev;
        char *steps_msg;
+       int no_checkout = ref_exists("BISECT_HEAD");
        int first_parent_only = 0; /* TODO: pass --first-parent flag from git bisect start */
 
        read_bisect_terms(&term_bad, &term_good);
index a63af0505fe4fc2dd4b2b7381f4e7948c4e27e9a..7f30b94db31deb71f6fcd4664348bf6f769c81d1 100644 (file)
--- a/bisect.h
+++ b/bisect.h
@@ -58,9 +58,7 @@ enum bisect_error {
        BISECT_INTERNAL_SUCCESS_MERGE_BASE = -11
 };
 
-enum bisect_error bisect_next_all(struct repository *r,
-                   const char *prefix,
-                   int no_checkout);
+enum bisect_error bisect_next_all(struct repository *r, const char *prefix);
 
 int estimate_bisect_steps(int all);
 
index ec4996282e36e2edcd4109321f83b921a24c5a32..4b175d1c05cd2fc968389ee0f58013492ebc86c6 100644 (file)
@@ -19,7 +19,7 @@ static GIT_PATH_FUNC(git_path_head_name, "head-name")
 static GIT_PATH_FUNC(git_path_bisect_names, "BISECT_NAMES")
 
 static const char * const git_bisect_helper_usage[] = {
-       N_("git bisect--helper --next-all [--no-checkout]"),
+       N_("git bisect--helper --next-all"),
        N_("git bisect--helper --write-terms <bad_term> <good_term>"),
        N_("git bisect--helper --bisect-clean-state"),
        N_("git bisect--helper --bisect-reset [<commit>]"),
@@ -421,9 +421,9 @@ finish:
        return res;
 }
 
-static int bisect_start(struct bisect_terms *terms, int no_checkout,
-                       const char **argv, int argc)
+static int bisect_start(struct bisect_terms *terms, const char **argv, int argc)
 {
+       int no_checkout = 0;
        int i, has_double_dash = 0, must_write_terms = 0, bad_seen = 0;
        int flags, pathspec_pos, res = 0;
        struct string_list revs = STRING_LIST_INIT_DUP;
@@ -632,7 +632,7 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
                BISECT_TERMS,
                BISECT_START
        } cmdmode = 0;
-       int no_checkout = 0, res = 0, nolog = 0;
+       int res = 0, nolog = 0;
        struct option options[] = {
                OPT_CMDMODE(0, "next-all", &cmdmode,
                         N_("perform 'git bisect next'"), NEXT_ALL),
@@ -654,8 +654,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
                         N_("print out the bisect terms"), BISECT_TERMS),
                OPT_CMDMODE(0, "bisect-start", &cmdmode,
                         N_("start the bisect session"), BISECT_START),
-               OPT_BOOL(0, "no-checkout", &no_checkout,
-                        N_("update BISECT_HEAD instead of checking out the current commit")),
                OPT_BOOL(0, "no-log", &nolog,
                         N_("no log for BISECT_WRITE")),
                OPT_END()
@@ -671,7 +669,7 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
 
        switch (cmdmode) {
        case NEXT_ALL:
-               res = bisect_next_all(the_repository, prefix, no_checkout);
+               res = bisect_next_all(the_repository, prefix);
                break;
        case WRITE_TERMS:
                if (argc != 2)
@@ -713,7 +711,7 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
                break;
        case BISECT_START:
                set_terms(&terms, "bad", "good");
-               res = bisect_start(&terms, no_checkout, argv, argc);
+               res = bisect_start(&terms, argv, argc);
                break;
        default:
                return error("BUG: unknown subcommand '%d'", cmdmode);
index 08a6ed57ddb115413013ce5cd4c9a786b1a2bef9..8fbda2e2c7ad0532ee73a5a6a6b116859792aa98 100755 (executable)
@@ -153,7 +153,7 @@ bisect_next() {
        git bisect--helper --bisect-next-check $TERM_GOOD $TERM_BAD $TERM_GOOD|| exit
 
        # Perform all bisection computation, display and checkout
-       git bisect--helper --next-all $(test -f "$GIT_DIR/BISECT_HEAD" && echo --no-checkout)
+       git bisect--helper --next-all
        res=$?
 
        # Check if we should exit because bisection is finished