Skip to content

Commit c368dde

Browse files
bk2204gitster
authored andcommitted
coccinelle: apply object_id Coccinelle transformations
Apply the set of semantic patches from contrib/coccinelle to convert some leftover places using struct object_id's hash member to instead use the wrapper functions that take struct object_id natively. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent f449198 commit c368dde

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

bisect.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ static void handle_bad_merge_base(void)
754754
static void handle_skipped_merge_base(const unsigned char *mb)
755755
{
756756
char *mb_hex = sha1_to_hex(mb);
757-
char *bad_hex = sha1_to_hex(current_bad_oid->hash);
757+
char *bad_hex = oid_to_hex(current_bad_oid);
758758
char *good_hex = join_sha1_array_hex(&good_revs, ' ');
759759

760760
warning("the merge base between %s and [%s] "

builtin/merge.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ static void merge_name(const char *remote, struct strbuf *msg)
501501
if (ref_exists(truname.buf)) {
502502
strbuf_addf(msg,
503503
"%s\t\tbranch '%s'%s of .\n",
504-
sha1_to_hex(remote_head->object.oid.hash),
504+
oid_to_hex(&remote_head->object.oid),
505505
truname.buf + 11,
506506
(early ? " (early part)" : ""));
507507
strbuf_release(&truname);
@@ -515,15 +515,15 @@ static void merge_name(const char *remote, struct strbuf *msg)
515515
desc = merge_remote_util(remote_head);
516516
if (desc && desc->obj && desc->obj->type == OBJ_TAG) {
517517
strbuf_addf(msg, "%s\t\t%s '%s'\n",
518-
sha1_to_hex(desc->obj->oid.hash),
518+
oid_to_hex(&desc->obj->oid),
519519
typename(desc->obj->type),
520520
remote);
521521
goto cleanup;
522522
}
523523
}
524524

525525
strbuf_addf(msg, "%s\t\tcommit '%s'\n",
526-
sha1_to_hex(remote_head->object.oid.hash), remote);
526+
oid_to_hex(&remote_head->object.oid), remote);
527527
cleanup:
528528
strbuf_release(&buf);
529529
strbuf_release(&bname);
@@ -1366,7 +1366,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
13661366
for (p = remoteheads; p; p = p->next) {
13671367
struct commit *commit = p->item;
13681368
strbuf_addf(&buf, "GITHEAD_%s",
1369-
sha1_to_hex(commit->object.oid.hash));
1369+
oid_to_hex(&commit->object.oid));
13701370
setenv(buf.buf, merge_remote_util(commit)->name, 1);
13711371
strbuf_reset(&buf);
13721372
if (fast_forward != FF_ONLY &&
@@ -1425,7 +1425,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
14251425
goto done;
14261426
} else if (fast_forward != FF_NO && !remoteheads->next &&
14271427
!common->next &&
1428-
!hashcmp(common->item->object.oid.hash, head_commit->object.oid.hash)) {
1428+
!oidcmp(&common->item->object.oid, &head_commit->object.oid)) {
14291429
/* Again the most common case of merging one remote. */
14301430
struct strbuf msg = STRBUF_INIT;
14311431
struct commit *commit;
@@ -1499,8 +1499,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
14991499
* HEAD^^" would be missed.
15001500
*/
15011501
common_one = get_merge_bases(head_commit, j->item);
1502-
if (hashcmp(common_one->item->object.oid.hash,
1503-
j->item->object.oid.hash)) {
1502+
if (oidcmp(&common_one->item->object.oid, &j->item->object.oid)) {
15041503
up_to_date = 0;
15051504
break;
15061505
}

refs/files-backend.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1725,14 +1725,14 @@ static int verify_lock(struct ref_lock *lock,
17251725
errno = save_errno;
17261726
return -1;
17271727
} else {
1728-
hashclr(lock->old_oid.hash);
1728+
oidclr(&lock->old_oid);
17291729
return 0;
17301730
}
17311731
}
17321732
if (old_sha1 && hashcmp(lock->old_oid.hash, old_sha1)) {
17331733
strbuf_addf(err, "ref %s is at %s but expected %s",
17341734
lock->ref_name,
1735-
sha1_to_hex(lock->old_oid.hash),
1735+
oid_to_hex(&lock->old_oid),
17361736
sha1_to_hex(old_sha1));
17371737
errno = EBUSY;
17381738
return -1;

0 commit comments

Comments
 (0)