notes-merge: convert verify_notes_filepair 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 4d77896eeba6727e9a9fac9d78a8d7695737b772
1 file changed +10 -10
notes-merge.c
+10 -10
@@ -22,21 +22,21 @@ void init_notes_merge_options(struct notes_merge_options *o)
22 o->verbosity = NOTES_MERGE_VERBOSITY_DEFAULT;
23 }
24
25 -static int path_to_sha1(const char *path, unsigned char *sha1)
25 +static int path_to_oid(const char *path, struct object_id *oid)
26 {
27 - char hex_sha1[40];
27 + char hex_oid[GIT_SHA1_HEXSZ];
28 int i = 0;
29 - while (*path && i < 40) {
29 + while (*path && i < GIT_SHA1_HEXSZ) {
30 if (*path != '/')
31 - hex_sha1[i++] = *path;
31 + hex_oid[i++] = *path;
32 path++;
33 }
34 - if (*path || i != 40)
34 + if (*path || i != GIT_SHA1_HEXSZ)
35 return -1;
36 - return get_sha1_hex(hex_sha1, sha1);
36 + return get_oid_hex(hex_oid, oid);
37 }
38
39 -static int verify_notes_filepair(struct diff_filepair *p, unsigned char *sha1)
39 +static int verify_notes_filepair(struct diff_filepair *p, struct object_id *oid)
40 {
41 switch (p->status) {
42 case DIFF_STATUS_MODIFIED:
@@ -54,7 +54,7 @@ static int verify_notes_filepair(struct diff_filepair *p, unsigned char *sha1)
54 return -1;
55 }
56 assert(!strcmp(p->one->path, p->two->path));
57 - return path_to_sha1(p->one->path, sha1);
57 + return path_to_oid(p->one->path, oid);
58 }
59
60 static struct notes_merge_pair *find_notes_merge_pair_pos(
@@ -140,7 +140,7 @@ static struct notes_merge_pair *diff_tree_remote(struct notes_merge_options *o,
140 int occupied;
141 struct object_id obj;
142
143 - if (verify_notes_filepair(p, obj.hash)) {
143 + if (verify_notes_filepair(p, &obj)) {
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),
@@ -201,7 +201,7 @@ static void diff_tree_local(struct notes_merge_options *o,
201 int match;
202 struct object_id obj;
203
204 - if (verify_notes_filepair(p, obj.hash)) {
204 + if (verify_notes_filepair(p, &obj)) {
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),