check_everything_connected: use a struct with named options
[gitweb.git] / notes-merge.c
index 7b1099c9a23d9eee44a99e269ba07ac344eccba9..1b58a14ebc30d47d942b868af1afdc8cc3195148 100644 (file)
@@ -41,14 +41,14 @@ static int verify_notes_filepair(struct diff_filepair *p, unsigned char *sha1)
        switch (p->status) {
        case DIFF_STATUS_MODIFIED:
                assert(p->one->mode == p->two->mode);
-               assert(!is_null_sha1(p->one->sha1));
-               assert(!is_null_sha1(p->two->sha1));
+               assert(!is_null_oid(&p->one->oid));
+               assert(!is_null_oid(&p->two->oid));
                break;
        case DIFF_STATUS_ADDED:
-               assert(is_null_sha1(p->one->sha1));
+               assert(is_null_oid(&p->one->oid));
                break;
        case DIFF_STATUS_DELETED:
-               assert(is_null_sha1(p->two->sha1));
+               assert(is_null_oid(&p->two->oid));
                break;
        default:
                return -1;
@@ -142,27 +142,27 @@ static struct notes_merge_pair *diff_tree_remote(struct notes_merge_options *o,
                if (verify_notes_filepair(p, obj)) {
                        trace_printf("\t\tCannot merge entry '%s' (%c): "
                               "%.7s -> %.7s. Skipping!\n", p->one->path,
-                              p->status, sha1_to_hex(p->one->sha1),
-                              sha1_to_hex(p->two->sha1));
+                              p->status, oid_to_hex(&p->one->oid),
+                              oid_to_hex(&p->two->oid));
                        continue;
                }
                mp = find_notes_merge_pair_pos(changes, len, obj, 1, &occupied);
                if (occupied) {
                        /* We've found an addition/deletion pair */
                        assert(!hashcmp(mp->obj, obj));
-                       if (is_null_sha1(p->one->sha1)) { /* addition */
+                       if (is_null_oid(&p->one->oid)) { /* addition */
                                assert(is_null_sha1(mp->remote));
-                               hashcpy(mp->remote, p->two->sha1);
-                       } else if (is_null_sha1(p->two->sha1)) { /* deletion */
+                               hashcpy(mp->remote, p->two->oid.hash);
+                       } else if (is_null_oid(&p->two->oid)) { /* deletion */
                                assert(is_null_sha1(mp->base));
-                               hashcpy(mp->base, p->one->sha1);
+                               hashcpy(mp->base, p->one->oid.hash);
                        } else
                                assert(!"Invalid existing change recorded");
                } else {
                        hashcpy(mp->obj, obj);
-                       hashcpy(mp->base, p->one->sha1);
+                       hashcpy(mp->base, p->one->oid.hash);
                        hashcpy(mp->local, uninitialized);
-                       hashcpy(mp->remote, p->two->sha1);
+                       hashcpy(mp->remote, p->two->oid.hash);
                        len++;
                }
                trace_printf("\t\tStored remote change for %s: %.7s -> %.7s\n",
@@ -170,7 +170,7 @@ static struct notes_merge_pair *diff_tree_remote(struct notes_merge_options *o,
                       sha1_to_hex(mp->remote));
        }
        diff_flush(&opt);
-       free_pathspec(&opt.pathspec);
+       clear_pathspec(&opt.pathspec);
 
        *num_changes = len;
        return changes;
@@ -203,21 +203,21 @@ static void diff_tree_local(struct notes_merge_options *o,
                if (verify_notes_filepair(p, obj)) {
                        trace_printf("\t\tCannot merge entry '%s' (%c): "
                               "%.7s -> %.7s. Skipping!\n", p->one->path,
-                              p->status, sha1_to_hex(p->one->sha1),
-                              sha1_to_hex(p->two->sha1));
+                              p->status, oid_to_hex(&p->one->oid),
+                              oid_to_hex(&p->two->oid));
                        continue;
                }
                mp = find_notes_merge_pair_pos(changes, len, obj, 0, &match);
                if (!match) {
                        trace_printf("\t\tIgnoring local-only change for %s: "
                               "%.7s -> %.7s\n", sha1_to_hex(obj),
-                              sha1_to_hex(p->one->sha1),
-                              sha1_to_hex(p->two->sha1));
+                              oid_to_hex(&p->one->oid),
+                              oid_to_hex(&p->two->oid));
                        continue;
                }
 
                assert(!hashcmp(mp->obj, obj));
-               if (is_null_sha1(p->two->sha1)) { /* deletion */
+               if (is_null_oid(&p->two->oid)) { /* deletion */
                        /*
                         * Either this is a true deletion (1), or it is part
                         * of an A/D pair (2), or D/A pair (3):
@@ -229,7 +229,7 @@ static void diff_tree_local(struct notes_merge_options *o,
                         */
                        if (!hashcmp(mp->local, uninitialized))
                                hashclr(mp->local);
-               } else if (is_null_sha1(p->one->sha1)) { /* addition */
+               } else if (is_null_oid(&p->one->oid)) { /* addition */
                        /*
                         * Either this is a true addition (1), or it is part
                         * of an A/D pair (2), or D/A pair (3):
@@ -240,23 +240,23 @@ static void diff_tree_local(struct notes_merge_options *o,
                         */
                        assert(is_null_sha1(mp->local) ||
                               !hashcmp(mp->local, uninitialized));
-                       hashcpy(mp->local, p->two->sha1);
+                       hashcpy(mp->local, p->two->oid.hash);
                } else { /* modification */
                        /*
                         * This is a true modification. p->one->sha1 shall
                         * match mp->base, and mp->local shall be uninitialized.
                         * Set mp->local to p->two->sha1.
                         */
-                       assert(!hashcmp(p->one->sha1, mp->base));
+                       assert(!hashcmp(p->one->oid.hash, mp->base));
                        assert(!hashcmp(mp->local, uninitialized));
-                       hashcpy(mp->local, p->two->sha1);
+                       hashcpy(mp->local, p->two->oid.hash);
                }
                trace_printf("\t\tStored local change for %s: %.7s -> %.7s\n",
                       sha1_to_hex(mp->obj), sha1_to_hex(mp->base),
                       sha1_to_hex(mp->local));
        }
        diff_flush(&opt);
-       free_pathspec(&opt.pathspec);
+       clear_pathspec(&opt.pathspec);
 }
 
 static void check_notes_merge_worktree(struct notes_merge_options *o)
@@ -602,15 +602,15 @@ int notes_merge(struct notes_merge_options *o,
                if (o->verbosity >= 4)
                        printf("No merge base found; doing history-less merge\n");
        } else if (!bases->next) {
-               base_sha1 = get_object_hash(bases->item->object);
-               base_tree_sha1 = get_object_hash(bases->item->tree->object);
+               base_sha1 = bases->item->object.oid.hash;
+               base_tree_sha1 = bases->item->tree->object.oid.hash;
                if (o->verbosity >= 4)
                        printf("One merge base found (%.7s)\n",
                                sha1_to_hex(base_sha1));
        } else {
                /* TODO: How to handle multiple merge-bases? */
-               base_sha1 = get_object_hash(bases->item->object);
-               base_tree_sha1 = get_object_hash(bases->item->tree->object);
+               base_sha1 = bases->item->object.oid.hash;
+               base_tree_sha1 = bases->item->tree->object.oid.hash;
                if (o->verbosity >= 3)
                        printf("Multiple merge bases found. Using the first "
                                "(%.7s)\n", sha1_to_hex(base_sha1));
@@ -622,23 +622,23 @@ int notes_merge(struct notes_merge_options *o,
                        oid_to_hex(&local->object.oid),
                        sha1_to_hex(base_sha1));
 
-       if (!hashcmp(get_object_hash(remote->object), base_sha1)) {
+       if (!hashcmp(remote->object.oid.hash, base_sha1)) {
                /* Already merged; result == local commit */
                if (o->verbosity >= 2)
                        printf("Already up-to-date!\n");
-               hashcpy(result_sha1, get_object_hash(local->object));
+               hashcpy(result_sha1, local->object.oid.hash);
                goto found_result;
        }
-       if (!hashcmp(get_object_hash(local->object), base_sha1)) {
+       if (!hashcmp(local->object.oid.hash, base_sha1)) {
                /* Fast-forward; result == remote commit */
                if (o->verbosity >= 2)
                        printf("Fast-forward\n");
-               hashcpy(result_sha1, get_object_hash(remote->object));
+               hashcpy(result_sha1, remote->object.oid.hash);
                goto found_result;
        }
 
-       result = merge_from_diffs(o, base_tree_sha1, get_object_hash(local->tree->object),
-                                 get_object_hash(remote->tree->object), local_tree);
+       result = merge_from_diffs(o, base_tree_sha1, local->tree->object.oid.hash,
+                                 remote->tree->object.oid.hash, local_tree);
 
        if (result != 0) { /* non-trivial merge (with or without conflicts) */
                /* Commit (partial) result */