]> git.ipfire.org Git - thirdparty/git.git/blobdiff - bisect.c
fast-export: when using paths, avoid corrupt stream with non-existent mark
[thirdparty/git.git] / bisect.c
index a579b50884f8e6f8ce8390308d39b2664d050583..487675c67249a3164294aae71c1c2a650f3c4947 100644 (file)
--- a/bisect.c
+++ b/bisect.c
@@ -12,6 +12,9 @@
 #include "bisect.h"
 #include "sha1-array.h"
 #include "argv-array.h"
+#include "commit-slab.h"
+#include "commit-reach.h"
+#include "object-store.h"
 
 static struct oid_array good_revs;
 static struct oid_array skipped_revs;
@@ -70,16 +73,19 @@ static void clear_distance(struct commit_list *list)
        }
 }
 
+define_commit_slab(commit_weight, int *);
+static struct commit_weight commit_weight;
+
 #define DEBUG_BISECT 0
 
 static inline int weight(struct commit_list *elem)
 {
-       return *((int*)(elem->item->util));
+       return **commit_weight_at(&commit_weight, elem->item);
 }
 
 static inline void weight_set(struct commit_list *elem, int weight)
 {
-       *((int*)(elem->item->util)) = weight;
+       **commit_weight_at(&commit_weight, elem->item) = weight;
 }
 
 static int count_interesting_parents(struct commit *commit)
@@ -116,14 +122,14 @@ static inline int halfway(struct commit_list *p, int nr)
        }
 }
 
-#if !DEBUG_BISECT
-#define show_list(a,b,c,d) do { ; } while (0)
-#else
 static void show_list(const char *debug, int counted, int nr,
                      struct commit_list *list)
 {
        struct commit_list *p;
 
+       if (!DEBUG_BISECT)
+               return;
+
        fprintf(stderr, "%s (%d/%d)\n", debug, counted, nr);
 
        for (p = list; p; p = p->next) {
@@ -141,7 +147,7 @@ static void show_list(const char *debug, int counted, int nr,
                        (flags & TREESAME) ? ' ' : 'T',
                        (flags & UNINTERESTING) ? 'U' : ' ',
                        (flags & COUNTED) ? 'C' : ' ');
-               if (commit->util)
+               if (*commit_weight_at(&commit_weight, p->item))
                        fprintf(stderr, "%3d", weight(p));
                else
                        fprintf(stderr, "---");
@@ -156,7 +162,6 @@ static void show_list(const char *debug, int counted, int nr,
                fprintf(stderr, "\n");
        }
 }
-#endif /* DEBUG_BISECT */
 
 static struct commit_list *best_bisection(struct commit_list *list, int nr)
 {
@@ -265,7 +270,7 @@ static struct commit_list *do_find_bisection(struct commit_list *list,
                struct commit *commit = p->item;
                unsigned flags = commit->object.flags;
 
-               p->item->util = &weights[n++];
+               *commit_weight_at(&commit_weight, p->item) = &weights[n++];
                switch (count_interesting_parents(commit)) {
                case 0:
                        if (!(flags & TREESAME)) {
@@ -372,6 +377,7 @@ void find_bisection(struct commit_list **commit_list, int *reaches,
        int *weights;
 
        show_list("bisection 2 entry", 0, 0, *commit_list);
+       init_commit_weight(&commit_weight);
 
        /*
         * Count the number of total and tree-changing items on the
@@ -412,6 +418,7 @@ void find_bisection(struct commit_list **commit_list, int *reaches,
        }
        free(weights);
        *commit_list = best;
+       clear_commit_weight(&commit_weight);
 }
 
 static int register_ref(const char *refname, const struct object_id *oid,
@@ -589,7 +596,7 @@ static struct commit_list *skip_away(struct commit_list *list, int count)
 
        for (i = 0; cur; cur = cur->next, i++) {
                if (i == index) {
-                       if (oidcmp(&cur->item->object.oid, current_bad_oid))
+                       if (!oideq(&cur->item->object.oid, current_bad_oid))
                                return cur;
                        if (previous)
                                return previous;
@@ -626,7 +633,7 @@ static void bisect_rev_setup(struct rev_info *revs, const char *prefix,
        struct argv_array rev_argv = ARGV_ARRAY_INIT;
        int i;
 
-       init_revisions(revs, prefix);
+       repo_init_revisions(the_repository, revs, prefix);
        revs->abbrev = 0;
        revs->commit_format = CMIT_FMT_UNSPECIFIED;
 
@@ -718,7 +725,7 @@ static int bisect_checkout(const struct object_id *bisect_rev, int no_checkout)
 
 static struct commit *get_commit_reference(const struct object_id *oid)
 {
-       struct commit *r = lookup_commit_reference(oid);
+       struct commit *r = lookup_commit_reference(the_repository, oid);
        if (!r)
                die(_("Not a valid commit name %s"), oid_to_hex(oid));
        return r;
@@ -801,7 +808,7 @@ static void check_merge_bases(int rev_nr, struct commit **rev, int no_checkout)
 
        for (; result; result = result->next) {
                const struct object_id *mb = &result->item->object.oid;
-               if (!oidcmp(mb, current_bad_oid)) {
+               if (oideq(mb, current_bad_oid)) {
                        handle_bad_merge_base();
                } else if (0 <= oid_array_lookup(&good_revs, mb)) {
                        continue;
@@ -883,7 +890,7 @@ static void show_diff_tree(const char *prefix, struct commit *commit)
        struct rev_info opt;
 
        /* diff-tree init */
-       init_revisions(&opt, prefix);
+       repo_init_revisions(the_repository, &opt, prefix);
        git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
        opt.abbrev = 0;
        opt.diff = 1;
@@ -982,7 +989,7 @@ int bisect_next_all(const char *prefix, int no_checkout)
 
        bisect_rev = &revs.commits->item->object.oid;
 
-       if (!oidcmp(bisect_rev, current_bad_oid)) {
+       if (oideq(bisect_rev, current_bad_oid)) {
                exit_if_skipped_commits(tried, current_bad_oid);
                printf("%s is the first %s commit\n", oid_to_hex(bisect_rev),
                        term_bad);