travis-ci: printf $STATUS as string
[gitweb.git] / bisect.c
index ebaf7b05bad1b8496c224ea3a308614720874135..03af06c66cebcbc0699b8a074f9ef120da09248a 100644 (file)
--- a/bisect.c
+++ b/bisect.c
@@ -12,8 +12,8 @@
 #include "sha1-array.h"
 #include "argv-array.h"
 
-static struct sha1_array good_revs;
-static struct sha1_array skipped_revs;
+static struct oid_array good_revs;
+static struct oid_array skipped_revs;
 
 static struct object_id *current_bad_oid;
 
@@ -200,6 +200,7 @@ static struct commit_list *best_bisection_sorted(struct commit_list *list, int n
 {
        struct commit_list *p;
        struct commit_dist *array = xcalloc(nr, sizeof(*array));
+       struct strbuf buf = STRBUF_INIT;
        int cnt, i;
 
        for (p = list, cnt = 0; p; p = p->next) {
@@ -217,17 +218,18 @@ static struct commit_list *best_bisection_sorted(struct commit_list *list, int n
        }
        QSORT(array, cnt, compare_commit_dist);
        for (p = list, i = 0; i < cnt; i++) {
-               char buf[100]; /* enough for dist=%d */
                struct object *obj = &(array[i].commit->object);
 
-               snprintf(buf, sizeof(buf), "dist=%d", array[i].distance);
-               add_name_decoration(DECORATION_NONE, buf, obj);
+               strbuf_reset(&buf);
+               strbuf_addf(&buf, "dist=%d", array[i].distance);
+               add_name_decoration(DECORATION_NONE, buf.buf, obj);
 
                p->item = array[i].commit;
                p = p->next;
        }
        if (p)
                p->next = NULL;
+       strbuf_release(&buf);
        free(array);
        return list;
 }
@@ -413,9 +415,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);
+               oid_array_append(&good_revs, oid);
        } else if (starts_with(refname, "skip-")) {
-               sha1_array_append(&skipped_revs, oid->hash);
+               oid_array_append(&skipped_revs, oid);
        }
 
        strbuf_release(&good_prefix);
@@ -451,7 +453,7 @@ static void read_bisect_paths(struct argv_array *array)
        fclose(fp);
 }
 
-static char *join_sha1_array_hex(struct sha1_array *array, char delim)
+static char *join_sha1_array_hex(struct oid_array *array, char delim)
 {
        struct strbuf joined_hexs = STRBUF_INIT;
        int i;
@@ -499,8 +501,7 @@ struct commit_list *filter_skipped(struct commit_list *list,
        while (list) {
                struct commit_list *next = list->next;
                list->next = NULL;
-               if (0 <= sha1_array_lookup(&skipped_revs,
-                                          list->item->object.oid.hash)) {
+               if (0 <= oid_array_lookup(&skipped_revs, &list->item->object.oid)) {
                        if (skipped_first && !*skipped_first)
                                *skipped_first = 1;
                        /* Move current to tried list */
@@ -754,9 +755,9 @@ static void handle_bad_merge_base(void)
        exit(1);
 }
 
-static void handle_skipped_merge_base(const unsigned char *mb)
+static void handle_skipped_merge_base(const struct object_id *mb)
 {
-       char *mb_hex = sha1_to_hex(mb);
+       char *mb_hex = oid_to_hex(mb);
        char *bad_hex = oid_to_hex(current_bad_oid);
        char *good_hex = join_sha1_array_hex(&good_revs, ' ');
 
@@ -787,16 +788,16 @@ static void check_merge_bases(int no_checkout)
        result = get_merge_bases_many(rev[0], rev_nr - 1, rev + 1);
 
        for (; result; result = result->next) {
-               const unsigned char *mb = result->item->object.oid.hash;
-               if (!hashcmp(mb, current_bad_oid->hash)) {
+               const struct object_id *mb = &result->item->object.oid;
+               if (!oidcmp(mb, current_bad_oid)) {
                        handle_bad_merge_base();
-               } else if (0 <= sha1_array_lookup(&good_revs, mb)) {
+               } else if (0 <= oid_array_lookup(&good_revs, mb)) {
                        continue;
-               } else if (0 <= sha1_array_lookup(&skipped_revs, mb)) {
+               } else if (0 <= oid_array_lookup(&skipped_revs, mb)) {
                        handle_skipped_merge_base(mb);
                } else {
                        printf(_("Bisecting: a merge base must be tested\n"));
-                       exit(bisect_checkout(mb, no_checkout));
+                       exit(bisect_checkout(mb->hash, no_checkout));
                }
        }