Make sha1_array_append take a struct object_id *
[gitweb.git] / bisect.c
index 8e63c40d274d7693b0c41e702cbe9ed03b1d12ae..886e6308848a4115fbc23dde26350c81997a10df 100644 (file)
--- a/bisect.c
+++ b/bisect.c
@@ -413,9 +413,9 @@ static int register_ref(const char *refname, const struct object_id *oid,
                current_bad_oid = xmalloc(sizeof(*current_bad_oid));
                oidcpy(current_bad_oid, oid);
        } else if (starts_with(refname, good_prefix.buf)) {
-               sha1_array_append(&good_revs, oid->hash);
+               sha1_array_append(&good_revs, oid);
        } else if (starts_with(refname, "skip-")) {
-               sha1_array_append(&skipped_revs, oid->hash);
+               sha1_array_append(&skipped_revs, oid);
        }
 
        strbuf_release(&good_prefix);
@@ -457,7 +457,7 @@ static char *join_sha1_array_hex(struct sha1_array *array, char delim)
        int i;
 
        for (i = 0; i < array->nr; i++) {
-               strbuf_addstr(&joined_hexs, sha1_to_hex(array->sha1[i]));
+               strbuf_addstr(&joined_hexs, oid_to_hex(array->oid + i));
                if (i + 1 < array->nr)
                        strbuf_addch(&joined_hexs, delim);
        }
@@ -621,7 +621,7 @@ static void bisect_rev_setup(struct rev_info *revs, const char *prefix,
        argv_array_pushf(&rev_argv, bad_format, oid_to_hex(current_bad_oid));
        for (i = 0; i < good_revs.nr; i++)
                argv_array_pushf(&rev_argv, good_format,
-                                sha1_to_hex(good_revs.sha1[i]));
+                                oid_to_hex(good_revs.oid + i));
        argv_array_push(&rev_argv, "--");
        if (read_paths)
                read_bisect_paths(&rev_argv);
@@ -682,7 +682,7 @@ static int is_expected_rev(const struct object_id *oid)
 
 static int bisect_checkout(const unsigned char *bisect_rev, int no_checkout)
 {
-       char bisect_rev_hex[GIT_SHA1_HEXSZ + 1];
+       char bisect_rev_hex[GIT_MAX_HEXSZ + 1];
 
        memcpy(bisect_rev_hex, sha1_to_hex(bisect_rev), GIT_SHA1_HEXSZ + 1);
        update_ref(NULL, "BISECT_EXPECTED_REV", bisect_rev, NULL, 0, UPDATE_REFS_DIE_ON_ERR);
@@ -701,11 +701,11 @@ static int bisect_checkout(const unsigned char *bisect_rev, int no_checkout)
        return run_command_v_opt(argv_show_branch, RUN_GIT_CMD);
 }
 
-static struct commit *get_commit_reference(const unsigned char *sha1)
+static struct commit *get_commit_reference(const struct object_id *oid)
 {
-       struct commit *r = lookup_commit_reference(sha1);
+       struct commit *r = lookup_commit_reference(oid->hash);
        if (!r)
-               die(_("Not a valid commit name %s"), sha1_to_hex(sha1));
+               die(_("Not a valid commit name %s"), oid_to_hex(oid));
        return r;
 }
 
@@ -715,9 +715,9 @@ static struct commit **get_bad_and_good_commits(int *rev_nr)
        int i, n = 0;
 
        ALLOC_ARRAY(rev, 1 + good_revs.nr);
-       rev[n++] = get_commit_reference(current_bad_oid->hash);
+       rev[n++] = get_commit_reference(current_bad_oid);
        for (i = 0; i < good_revs.nr; i++)
-               rev[n++] = get_commit_reference(good_revs.sha1[i]);
+               rev[n++] = get_commit_reference(good_revs.oid + i);
        *rev_nr = n;
 
        return rev;
@@ -940,7 +940,7 @@ int bisect_next_all(const char *prefix, int no_checkout)
        struct commit_list *tried;
        int reaches = 0, all = 0, nr, steps;
        const unsigned char *bisect_rev;
-       char steps_msg[32];
+       char *steps_msg;
 
        read_bisect_terms(&term_bad, &term_good);
        if (read_bisect_refs())
@@ -990,14 +990,15 @@ int bisect_next_all(const char *prefix, int no_checkout)
 
        nr = all - reaches - 1;
        steps = estimate_bisect_steps(all);
-       xsnprintf(steps_msg, sizeof(steps_msg),
-                 Q_("(roughly %d step)", "(roughly %d steps)", steps),
-                 steps);
+
+       steps_msg = xstrfmt(Q_("(roughly %d step)", "(roughly %d steps)",
+                 steps), steps);
        /* TRANSLATORS: the last %s will be replaced with
           "(roughly %d steps)" translation */
        printf(Q_("Bisecting: %d revision left to test after this %s\n",
                  "Bisecting: %d revisions left to test after this %s\n",
                  nr), nr, steps_msg);
+       free(steps_msg);
 
        return bisect_checkout(bisect_rev, no_checkout);
 }