]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin/bisect--helper.c
Merge branch 'ea/blame-use-oideq'
[thirdparty/git.git] / builtin / bisect--helper.c
index d19300687fe9dff04c5af08de8a63cce15e46f98..7dcc1b518831fed008f0f06463554099d60cff68 100644 (file)
@@ -16,9 +16,10 @@ static GIT_PATH_FUNC(git_path_bisect_start, "BISECT_START")
 static GIT_PATH_FUNC(git_path_bisect_log, "BISECT_LOG")
 static GIT_PATH_FUNC(git_path_head_name, "head-name")
 static GIT_PATH_FUNC(git_path_bisect_names, "BISECT_NAMES")
+static GIT_PATH_FUNC(git_path_bisect_first_parent, "BISECT_FIRST_PARENT")
 
 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>]"),
@@ -26,8 +27,8 @@ static const char * const git_bisect_helper_usage[] = {
        N_("git bisect--helper --bisect-check-and-set-terms <command> <good_term> <bad_term>"),
        N_("git bisect--helper --bisect-next-check <good_term> <bad_term> [<term>]"),
        N_("git bisect--helper --bisect-terms [--term-good | --term-old | --term-bad | --term-new]"),
-       N_("git bisect--helper --bisect-start [--term-{old,good}=<term> --term-{new,bad}=<term>]"
-                                            "[--no-checkout] [<bad> [<good>...]] [--] [<paths>...]"),
+       N_("git bisect--helper --bisect-start [--term-{new,bad}=<term> --term-{old,good}=<term>]"
+                                           " [--no-checkout] [--first-parent] [<bad> [<good>...]] [--] [<paths>...]"),
        NULL
 };
 
@@ -420,9 +421,10 @@ 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 first_parent_only = 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;
@@ -452,6 +454,8 @@ static int bisect_start(struct bisect_terms *terms, int no_checkout,
                        break;
                } else if (!strcmp(arg, "--no-checkout")) {
                        no_checkout = 1;
+               } else if (!strcmp(arg, "--first-parent")) {
+                       first_parent_only = 1;
                } else if (!strcmp(arg, "--term-good") ||
                         !strcmp(arg, "--term-old")) {
                        i++;
@@ -576,6 +580,9 @@ static int bisect_start(struct bisect_terms *terms, int no_checkout,
         */
        write_file(git_path_bisect_start(), "%s\n", start_head.buf);
 
+       if (first_parent_only)
+               write_file(git_path_bisect_first_parent(), "\n");
+
        if (no_checkout) {
                if (get_oid(start_head.buf, &oid) < 0) {
                        res = error(_("invalid ref: '%s'"), start_head.buf);
@@ -631,7 +638,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),
@@ -653,8 +660,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()
@@ -670,7 +675,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)
@@ -712,7 +717,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);