]> 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 1718df7f09899afb37facf3754556520d361e13c..2fcc023a3b828f0f9e1102b19b900d6ae03d7f70 100644 (file)
@@ -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;