notes-merge: convert find_notes_merge_pair_ps 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:31 UTC
d7a7c708dac5e93b715d1d1f5897be2b0c9bcf7d
1 file changed
+12
-12
notes-merge.c
+12
-12
@@ -58,7 +58,7 @@ static int verify_notes_filepair(struct diff_filepair *p, unsigned char *sha1)
58
}
59
60
static struct notes_merge_pair *find_notes_merge_pair_pos(
61
- struct notes_merge_pair *list, int len, unsigned char *obj,
61
+ struct notes_merge_pair *list, int len, struct object_id *obj,
62
int insert_new, int *occupied)
63
{
64
/*
@@ -75,7 +75,7 @@ static struct notes_merge_pair *find_notes_merge_pair_pos(
75
int i = last_index < len ? last_index : len - 1;
76
int prev_cmp = 0, cmp = -1;
77
while (i >= 0 && i < len) {
78
- cmp = hashcmp(obj, list[i].obj.hash);
78
+ cmp = oidcmp(obj, &list[i].obj);
79
if (!cmp) /* obj belongs @ i */
80
break;
81
else if (cmp < 0 && prev_cmp <= 0) /* obj belongs < i */
@@ -138,19 +138,19 @@ static struct notes_merge_pair *diff_tree_remote(struct notes_merge_options *o,
138
struct diff_filepair *p = diff_queued_diff.queue[i];
139
struct notes_merge_pair *mp;
140
int occupied;
141
- unsigned char obj[20];
141
+ struct object_id obj;
142
143
- if (verify_notes_filepair(p, obj)) {
143
+ if (verify_notes_filepair(p, obj.hash)) {
144
trace_printf("\t\tCannot merge entry '%s' (%c): "
145
"%.7s -> %.7s. Skipping!\n", p->one->path,
146
p->status, oid_to_hex(&p->one->oid),
147
oid_to_hex(&p->two->oid));
148
continue;
149
}
150
- mp = find_notes_merge_pair_pos(changes, len, obj, 1, &occupied);
150
+ mp = find_notes_merge_pair_pos(changes, len, &obj, 1, &occupied);
151
if (occupied) {
152
/* We've found an addition/deletion pair */
153
- assert(!hashcmp(mp->obj.hash, obj));
153
+ assert(!oidcmp(&mp->obj, &obj));
154
if (is_null_oid(&p->one->oid)) { /* addition */
155
assert(is_null_oid(&mp->remote));
156
oidcpy(&mp->remote, &p->two->oid);
@@ -160,7 +160,7 @@ static struct notes_merge_pair *diff_tree_remote(struct notes_merge_options *o,
160
} else
161
assert(!"Invalid existing change recorded");
162
} else {
163
- hashcpy(mp->obj.hash, obj);
163
+ oidcpy(&mp->obj, &obj);
164
oidcpy(&mp->base, &p->one->oid);
165
oidcpy(&mp->local, &uninitialized);
166
oidcpy(&mp->remote, &p->two->oid);
@@ -199,25 +199,25 @@ static void diff_tree_local(struct notes_merge_options *o,
199
struct diff_filepair *p = diff_queued_diff.queue[i];
200
struct notes_merge_pair *mp;
201
int match;
202
- unsigned char obj[20];
202
+ struct object_id obj;
203
204
- if (verify_notes_filepair(p, obj)) {
204
+ if (verify_notes_filepair(p, obj.hash)) {
205
trace_printf("\t\tCannot merge entry '%s' (%c): "
206
"%.7s -> %.7s. Skipping!\n", p->one->path,
207
p->status, oid_to_hex(&p->one->oid),
208
oid_to_hex(&p->two->oid));
209
continue;
210
}
211
- mp = find_notes_merge_pair_pos(changes, len, obj, 0, &match);
211
+ mp = find_notes_merge_pair_pos(changes, len, &obj, 0, &match);
212
if (!match) {
213
trace_printf("\t\tIgnoring local-only change for %s: "
214
- "%.7s -> %.7s\n", sha1_to_hex(obj),
214
+ "%.7s -> %.7s\n", oid_to_hex(&obj),
215
oid_to_hex(&p->one->oid),
216
oid_to_hex(&p->two->oid));
217
continue;
218
}
219
220
- assert(!hashcmp(mp->obj.hash, obj));
220
+ assert(!oidcmp(&mp->obj, &obj));
221
if (is_null_oid(&p->two->oid)) { /* deletion */
222
/*
223
* Either this is a true deletion (1), or it is part