Skip to content

Commit a92ea68

Browse files
bk2204gitster
authored andcommitted
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>
1 parent 740ee05 commit a92ea68

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

log-tree.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ static const struct name_decoration *current_pointed_by_HEAD(const struct name_d
184184
{
185185
const struct name_decoration *list, *head = NULL;
186186
const char *branch_name = NULL;
187-
unsigned char unused[20];
187+
struct object_id unused;
188188
int rru_flags;
189189

190190
/* First find HEAD */
@@ -197,7 +197,7 @@ static const struct name_decoration *current_pointed_by_HEAD(const struct name_d
197197
return NULL;
198198

199199
/* 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);
201201
if (!(rru_flags & REF_ISSYMREF))
202202
return NULL;
203203

@@ -456,13 +456,13 @@ static void show_signature(struct rev_info *opt, struct commit *commit)
456456
strbuf_release(&signature);
457457
}
458458

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)
460460
{
461461
int nth;
462462
const struct commit_list *parent;
463463

464464
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))
466466
return nth;
467467
nth++;
468468
}
@@ -481,14 +481,14 @@ static void show_one_mergetag(struct commit *commit,
481481
void *data)
482482
{
483483
struct rev_info *opt = (struct rev_info *)data;
484-
unsigned char sha1[20];
484+
struct object_id oid;
485485
struct tag *tag;
486486
struct strbuf verify_message;
487487
int status, nth;
488488
size_t payload_size, gpg_message_offset;
489489

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);
492492
if (!tag)
493493
return; /* error message already given */
494494

@@ -500,7 +500,7 @@ static void show_one_mergetag(struct commit *commit,
500500
&commit->parents->next->item->object.oid))
501501
strbuf_addf(&verify_message,
502502
"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)
504504
strbuf_addf(&verify_message, "tag %s names a non-parent %s\n",
505505
tag->tag, tag->tagged->oid.hash);
506506
else
@@ -536,7 +536,7 @@ void show_log(struct rev_info *opt)
536536
struct strbuf msgbuf = STRBUF_INIT;
537537
struct log_info *log = opt->loginfo;
538538
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;
540540
const char *extra_headers = opt->extra_headers;
541541
struct pretty_print_context ctx = {0};
542542

0 commit comments

Comments
 (0)