]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin/bisect--helper.c
bisect: don't use invalid oid as rev when starting
[thirdparty/git.git] / builtin / bisect--helper.c
index 3055b2bb50e3d02670c2984072d75ea7014cdca7..2fcc023a3b828f0f9e1102b19b900d6ae03d7f70 100644 (file)
@@ -282,11 +282,11 @@ static int mark_good(const char *refname, const struct object_id *oid,
        return 1;
 }
 
-static const char *need_bad_and_good_revision_warning =
+static const char need_bad_and_good_revision_warning[] =
        N_("You need to give me at least one %s and %s revision.\n"
           "You can use \"git bisect %s\" and \"git bisect %s\" for that.");
 
-static const char *need_bisect_start_warning =
+static const char need_bisect_start_warning[] =
        N_("You need to start by \"git bisect start\".\n"
           "You then need to give me at least one %s and %s revision.\n"
           "You can use \"git bisect %s\" and \"git bisect %s\" for that.");
@@ -474,14 +474,13 @@ static int bisect_start(struct bisect_terms *terms, int no_checkout,
                } else if (starts_with(arg, "--") &&
                         !one_of(arg, "--term-good", "--term-bad", NULL)) {
                        return error(_("unrecognized option: '%s'"), arg);
-               } else {
-                       char *commit_id = xstrfmt("%s^{commit}", arg);
-                       if (get_oid(commit_id, &oid) && has_double_dash)
-                               die(_("'%s' does not appear to be a valid "
-                                     "revision"), arg);
-
+               } else if (!get_oidf(&oid, "%s^{commit}", arg)) {
                        string_list_append(&revs, oid_to_hex(&oid));
-                       free(commit_id);
+               } else if (has_double_dash) {
+                       die(_("'%s' does not appear to be a valid "
+                             "revision"), arg);
+               } else {
+                       break;
                }
        }
        pathspec_pos = i;