log-tree: convert to struct object_id

Convert the remaining functions to take pointers to struct object_id instead of pointers to unsigned char, and update the internals of these functions as well. Among these functions is a caller of lookup_tag, which we will convert shortly. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

brian m. carlson committed May 6, 2017 at 22:10 UTC a92ea68fefe2b7ce61363da3f5e0ae09dd6edba4
1 file changed +9 -9
log-tree.c
+9 -9
@@ -184,7 +184,7 @@ static const struct name_decoration *current_pointed_by_HEAD(const struct name_d
184 {
185 const struct name_decoration *list, *head = NULL;
186 const char *branch_name = NULL;
187 - unsigned char unused[20];
187 + struct object_id unused;
188 int rru_flags;
189
190 /* First find HEAD */
@@ -197,7 +197,7 @@ static const struct name_decoration *current_pointed_by_HEAD(const struct name_d
197 return NULL;
198
199 /* Now resolve and find the matching current branch */
200 - branch_name = resolve_ref_unsafe("HEAD", 0, unused, &rru_flags);
200 + branch_name = resolve_ref_unsafe("HEAD", 0, unused.hash, &rru_flags);
201 if (!(rru_flags & REF_ISSYMREF))
202 return NULL;
203
@@ -456,13 +456,13 @@ static void show_signature(struct rev_info *opt, struct commit *commit)
456 strbuf_release(&signature);
457 }
458
459 -static int which_parent(const unsigned char *sha1, const struct commit *commit)
459 +static int which_parent(const struct object_id *oid, const struct commit *commit)
460 {
461 int nth;
462 const struct commit_list *parent;
463
464 for (nth = 0, parent = commit->parents; parent; parent = parent->next) {
465 - if (!hashcmp(parent->item->object.oid.hash, sha1))
465 + if (!oidcmp(&parent->item->object.oid, oid))
466 return nth;
467 nth++;
468 }
@@ -481,14 +481,14 @@ static void show_one_mergetag(struct commit *commit,
481 void *data)
482 {
483 struct rev_info *opt = (struct rev_info *)data;
484 - unsigned char sha1[20];
484 + struct object_id oid;
485 struct tag *tag;
486 struct strbuf verify_message;
487 int status, nth;
488 size_t payload_size, gpg_message_offset;
489
490 - hash_sha1_file(extra->value, extra->len, typename(OBJ_TAG), sha1);
491 - tag = lookup_tag(sha1);
490 + hash_sha1_file(extra->value, extra->len, typename(OBJ_TAG), oid.hash);
491 + tag = lookup_tag(oid.hash);
492 if (!tag)
493 return; /* error message already given */
494
@@ -500,7 +500,7 @@ static void show_one_mergetag(struct commit *commit,
500 &commit->parents->next->item->object.oid))
501 strbuf_addf(&verify_message,
502 "merged tag '%s'\n", tag->tag);
503 - else if ((nth = which_parent(tag->tagged->oid.hash, commit)) < 0)
503 + else if ((nth = which_parent(&tag->tagged->oid, commit)) < 0)
504 strbuf_addf(&verify_message, "tag %s names a non-parent %s\n",
505 tag->tag, tag->tagged->oid.hash);
506 else
@@ -536,7 +536,7 @@ void show_log(struct rev_info *opt)
536 struct strbuf msgbuf = STRBUF_INIT;
537 struct log_info *log = opt->loginfo;
538 struct commit *commit = log->commit, *parent = log->parent;
539 - int abbrev_commit = opt->abbrev_commit ? opt->abbrev : 40;
539 + int abbrev_commit = opt->abbrev_commit ? opt->abbrev : GIT_SHA1_HEXSZ;
540 const char *extra_headers = opt->extra_headers;
541 struct pretty_print_context ctx = {0};
542