notes-merge: convert merge_from_diffs to struct object_id

Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Brandon Williams committed May 30, 2017 at 10:30 UTC 9d6babb2f9115892b7ddc58a9a3c44ae52da1712
1 file changed +16 -15
notes-merge.c
+16 -15
@@ -114,8 +114,8 @@ static struct object_id uninitialized = {
114 };
115
116 static struct notes_merge_pair *diff_tree_remote(struct notes_merge_options *o,
117 - const unsigned char *base,
118 - const unsigned char *remote,
117 + const struct object_id *base,
118 + const struct object_id *remote,
119 int *num_changes)
120 {
121 struct diff_options opt;
@@ -123,13 +123,13 @@ static struct notes_merge_pair *diff_tree_remote(struct notes_merge_options *o,
123 int i, len = 0;
124
125 trace_printf("\tdiff_tree_remote(base = %.7s, remote = %.7s)\n",
126 - sha1_to_hex(base), sha1_to_hex(remote));
126 + oid_to_hex(base), oid_to_hex(remote));
127
128 diff_setup(&opt);
129 DIFF_OPT_SET(&opt, RECURSIVE);
130 opt.output_format = DIFF_FORMAT_NO_OUTPUT;
131 diff_setup_done(&opt);
132 - diff_tree_sha1(base, remote, "", &opt);
132 + diff_tree_sha1(base->hash, remote->hash, "", &opt);
133 diffcore_std(&opt);
134
135 changes = xcalloc(diff_queued_diff.nr, sizeof(struct notes_merge_pair));
@@ -179,20 +179,20 @@ static struct notes_merge_pair *diff_tree_remote(struct notes_merge_options *o,
179
180 static void diff_tree_local(struct notes_merge_options *o,
181 struct notes_merge_pair *changes, int len,
182 - const unsigned char *base,
183 - const unsigned char *local)
182 + const struct object_id *base,
183 + const struct object_id *local)
184 {
185 struct diff_options opt;
186 int i;
187
188 trace_printf("\tdiff_tree_local(len = %i, base = %.7s, local = %.7s)\n",
189 - len, sha1_to_hex(base), sha1_to_hex(local));
189 + len, oid_to_hex(base), oid_to_hex(local));
190
191 diff_setup(&opt);
192 DIFF_OPT_SET(&opt, RECURSIVE);
193 opt.output_format = DIFF_FORMAT_NO_OUTPUT;
194 diff_setup_done(&opt);
195 - diff_tree_sha1(base, local, "", &opt);
195 + diff_tree_sha1(base->hash, local->hash, "", &opt);
196 diffcore_std(&opt);
197
198 for (i = 0; i < diff_queued_diff.nr; i++) {
@@ -505,16 +505,17 @@ static int merge_changes(struct notes_merge_options *o,
505 }
506
507 static int merge_from_diffs(struct notes_merge_options *o,
508 - const unsigned char *base,
509 - const unsigned char *local,
510 - const unsigned char *remote, struct notes_tree *t)
508 + const struct object_id *base,
509 + const struct object_id *local,
510 + const struct object_id *remote,
511 + struct notes_tree *t)
512 {
513 struct notes_merge_pair *changes;
514 int num_changes, conflicts;
515
516 trace_printf("\tmerge_from_diffs(base = %.7s, local = %.7s, "
516 - "remote = %.7s)\n", sha1_to_hex(base), sha1_to_hex(local),
517 - sha1_to_hex(remote));
517 + "remote = %.7s)\n", oid_to_hex(base), oid_to_hex(local),
518 + oid_to_hex(remote));
519
520 changes = diff_tree_remote(o, base, remote, &num_changes);
521 diff_tree_local(o, changes, num_changes, base, local);
@@ -636,8 +637,8 @@ int notes_merge(struct notes_merge_options *o,
637 goto found_result;
638 }
639
639 - result = merge_from_diffs(o, base_tree_oid->hash, local->tree->object.oid.hash,
640 - remote->tree->object.oid.hash, local_tree);
640 + result = merge_from_diffs(o, base_tree_oid, &local->tree->object.oid,
641 + &remote->tree->object.oid, local_tree);
642
643 if (result != 0) { /* non-trivial merge (with or without conflicts) */
644 /* Commit (partial) result */