Skip to content

Commit b420d90

Browse files
bk2204gitster
authored andcommitted
refs: convert peel_ref to struct object_id
Convert peel_ref (and its corresponding backend) to struct object_id. This transformation was done with an update to the declaration, definition, comments, and test helper and the following semantic patch: @@ expression E1, E2; @@ - peel_ref(E1, E2.hash) + peel_ref(E1, &E2) @@ expression E1, E2; @@ - peel_ref(E1, E2->hash) + peel_ref(E1, E2) Signed-off-by: brian m. carlson <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 188960b commit b420d90

File tree

7 files changed

+17
-17
lines changed

7 files changed

+17
-17
lines changed

builtin/describe.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ static int get_name(const char *path, const struct object_id *oid, int flag, voi
181181
}
182182

183183
/* Is it annotated? */
184-
if (!peel_ref(path, peeled.hash)) {
184+
if (!peel_ref(path, &peeled)) {
185185
is_annotated = !!oidcmp(oid, &peeled);
186186
} else {
187187
oidcpy(&peeled, oid);

builtin/pack-objects.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ static int mark_tagged(const char *path, const struct object_id *oid, int flag,
562562

563563
if (entry)
564564
entry->tagged = 1;
565-
if (!peel_ref(path, peeled.hash)) {
565+
if (!peel_ref(path, &peeled)) {
566566
entry = packlist_find(&to_pack, peeled.hash, NULL);
567567
if (entry)
568568
entry->tagged = 1;
@@ -2371,7 +2371,7 @@ static int add_ref_tag(const char *path, const struct object_id *oid, int flag,
23712371
struct object_id peeled;
23722372

23732373
if (starts_with(path, "refs/tags/") && /* is a tag? */
2374-
!peel_ref(path, peeled.hash) && /* peelable? */
2374+
!peel_ref(path, &peeled) && /* peelable? */
23752375
packlist_find(&to_pack, peeled.hash, NULL)) /* object packed? */
23762376
add_tag_chain(oid);
23772377
return 0;

builtin/show-ref.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static void show_one(const char *refname, const struct object_id *oid)
3838
if (!deref_tags)
3939
return;
4040

41-
if (!peel_ref(refname, peeled.hash)) {
41+
if (!peel_ref(refname, &peeled)) {
4242
hex = find_unique_abbrev(peeled.hash, abbrev);
4343
printf("%s %s^{}\n", hex, refname);
4444
}

refs.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1697,7 +1697,7 @@ int refs_pack_refs(struct ref_store *refs, unsigned int flags)
16971697
}
16981698

16991699
int refs_peel_ref(struct ref_store *refs, const char *refname,
1700-
unsigned char *sha1)
1700+
struct object_id *oid)
17011701
{
17021702
int flag;
17031703
struct object_id base;
@@ -1707,20 +1707,20 @@ int refs_peel_ref(struct ref_store *refs, const char *refname,
17071707

17081708
if (ref_iterator_peel(current_ref_iter, &peeled))
17091709
return -1;
1710-
hashcpy(sha1, peeled.hash);
1710+
oidcpy(oid, &peeled);
17111711
return 0;
17121712
}
17131713

17141714
if (refs_read_ref_full(refs, refname,
17151715
RESOLVE_REF_READING, &base, &flag))
17161716
return -1;
17171717

1718-
return peel_object(base.hash, sha1);
1718+
return peel_object(base.hash, oid->hash);
17191719
}
17201720

1721-
int peel_ref(const char *refname, unsigned char *sha1)
1721+
int peel_ref(const char *refname, struct object_id *oid)
17221722
{
1723-
return refs_peel_ref(get_main_ref_store(), refname, sha1);
1723+
return refs_peel_ref(get_main_ref_store(), refname, oid);
17241724
}
17251725

17261726
int refs_create_symref(struct ref_store *refs,

refs.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,14 @@ extern int refs_init_db(struct strbuf *err);
114114
/*
115115
* If refname is a non-symbolic reference that refers to a tag object,
116116
* and the tag can be (recursively) dereferenced to a non-tag object,
117-
* store the SHA1 of the referred-to object to sha1 and return 0. If
118-
* any of these conditions are not met, return a non-zero value.
117+
* store the object ID of the referred-to object to oid and return 0.
118+
* If any of these conditions are not met, return a non-zero value.
119119
* Symbolic references are considered unpeelable, even if they
120120
* ultimately resolve to a peelable tag.
121121
*/
122122
int refs_peel_ref(struct ref_store *refs, const char *refname,
123-
unsigned char *sha1);
124-
int peel_ref(const char *refname, unsigned char *sha1);
123+
struct object_id *oid);
124+
int peel_ref(const char *refname, struct object_id *oid);
125125

126126
/**
127127
* Resolve refname in the nested "gitlink" repository in the specified

t/helper/test-ref-store.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@ static int cmd_pack_refs(struct ref_store *refs, const char **argv)
7272
static int cmd_peel_ref(struct ref_store *refs, const char **argv)
7373
{
7474
const char *refname = notnull(*argv++, "refname");
75-
unsigned char sha1[20];
75+
struct object_id oid;
7676
int ret;
7777

78-
ret = refs_peel_ref(refs, refname, sha1);
78+
ret = refs_peel_ref(refs, refname, &oid);
7979
if (!ret)
80-
puts(sha1_to_hex(sha1));
80+
puts(oid_to_hex(&oid));
8181
return ret;
8282
}
8383

upload-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,7 @@ static int send_ref(const char *refname, const struct object_id *oid,
955955
packet_write_fmt(1, "%s %s\n", oid_to_hex(oid), refname_nons);
956956
}
957957
capabilities = NULL;
958-
if (!peel_ref(refname, peeled.hash))
958+
if (!peel_ref(refname, &peeled))
959959
packet_write_fmt(1, "%s %s^{}\n", oid_to_hex(&peeled), refname_nons);
960960
return 0;
961961
}

0 commit comments

Comments
 (0)