提交 b420d909 编写于 作者: B brian m. carlson 提交者: Junio C Hamano

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: Nbrian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 188960b4
...@@ -181,7 +181,7 @@ static int get_name(const char *path, const struct object_id *oid, int flag, voi ...@@ -181,7 +181,7 @@ static int get_name(const char *path, const struct object_id *oid, int flag, voi
} }
/* Is it annotated? */ /* Is it annotated? */
if (!peel_ref(path, peeled.hash)) { if (!peel_ref(path, &peeled)) {
is_annotated = !!oidcmp(oid, &peeled); is_annotated = !!oidcmp(oid, &peeled);
} else { } else {
oidcpy(&peeled, oid); oidcpy(&peeled, oid);
......
...@@ -562,7 +562,7 @@ static int mark_tagged(const char *path, const struct object_id *oid, int flag, ...@@ -562,7 +562,7 @@ static int mark_tagged(const char *path, const struct object_id *oid, int flag,
if (entry) if (entry)
entry->tagged = 1; entry->tagged = 1;
if (!peel_ref(path, peeled.hash)) { if (!peel_ref(path, &peeled)) {
entry = packlist_find(&to_pack, peeled.hash, NULL); entry = packlist_find(&to_pack, peeled.hash, NULL);
if (entry) if (entry)
entry->tagged = 1; entry->tagged = 1;
...@@ -2371,7 +2371,7 @@ static int add_ref_tag(const char *path, const struct object_id *oid, int flag, ...@@ -2371,7 +2371,7 @@ static int add_ref_tag(const char *path, const struct object_id *oid, int flag,
struct object_id peeled; struct object_id peeled;
if (starts_with(path, "refs/tags/") && /* is a tag? */ if (starts_with(path, "refs/tags/") && /* is a tag? */
!peel_ref(path, peeled.hash) && /* peelable? */ !peel_ref(path, &peeled) && /* peelable? */
packlist_find(&to_pack, peeled.hash, NULL)) /* object packed? */ packlist_find(&to_pack, peeled.hash, NULL)) /* object packed? */
add_tag_chain(oid); add_tag_chain(oid);
return 0; return 0;
......
...@@ -38,7 +38,7 @@ static void show_one(const char *refname, const struct object_id *oid) ...@@ -38,7 +38,7 @@ static void show_one(const char *refname, const struct object_id *oid)
if (!deref_tags) if (!deref_tags)
return; return;
if (!peel_ref(refname, peeled.hash)) { if (!peel_ref(refname, &peeled)) {
hex = find_unique_abbrev(peeled.hash, abbrev); hex = find_unique_abbrev(peeled.hash, abbrev);
printf("%s %s^{}\n", hex, refname); printf("%s %s^{}\n", hex, refname);
} }
......
...@@ -1697,7 +1697,7 @@ int refs_pack_refs(struct ref_store *refs, unsigned int flags) ...@@ -1697,7 +1697,7 @@ int refs_pack_refs(struct ref_store *refs, unsigned int flags)
} }
int refs_peel_ref(struct ref_store *refs, const char *refname, int refs_peel_ref(struct ref_store *refs, const char *refname,
unsigned char *sha1) struct object_id *oid)
{ {
int flag; int flag;
struct object_id base; struct object_id base;
...@@ -1707,7 +1707,7 @@ int refs_peel_ref(struct ref_store *refs, const char *refname, ...@@ -1707,7 +1707,7 @@ int refs_peel_ref(struct ref_store *refs, const char *refname,
if (ref_iterator_peel(current_ref_iter, &peeled)) if (ref_iterator_peel(current_ref_iter, &peeled))
return -1; return -1;
hashcpy(sha1, peeled.hash); oidcpy(oid, &peeled);
return 0; return 0;
} }
...@@ -1715,12 +1715,12 @@ int refs_peel_ref(struct ref_store *refs, const char *refname, ...@@ -1715,12 +1715,12 @@ int refs_peel_ref(struct ref_store *refs, const char *refname,
RESOLVE_REF_READING, &base, &flag)) RESOLVE_REF_READING, &base, &flag))
return -1; return -1;
return peel_object(base.hash, sha1); return peel_object(base.hash, oid->hash);
} }
int peel_ref(const char *refname, unsigned char *sha1) int peel_ref(const char *refname, struct object_id *oid)
{ {
return refs_peel_ref(get_main_ref_store(), refname, sha1); return refs_peel_ref(get_main_ref_store(), refname, oid);
} }
int refs_create_symref(struct ref_store *refs, int refs_create_symref(struct ref_store *refs,
......
...@@ -114,14 +114,14 @@ extern int refs_init_db(struct strbuf *err); ...@@ -114,14 +114,14 @@ extern int refs_init_db(struct strbuf *err);
/* /*
* If refname is a non-symbolic reference that refers to a tag object, * If refname is a non-symbolic reference that refers to a tag object,
* and the tag can be (recursively) dereferenced to a non-tag object, * and the tag can be (recursively) dereferenced to a non-tag object,
* store the SHA1 of the referred-to object to sha1 and return 0. If * store the object ID of the referred-to object to oid and return 0.
* any of these conditions are not met, return a non-zero value. * If any of these conditions are not met, return a non-zero value.
* Symbolic references are considered unpeelable, even if they * Symbolic references are considered unpeelable, even if they
* ultimately resolve to a peelable tag. * ultimately resolve to a peelable tag.
*/ */
int refs_peel_ref(struct ref_store *refs, const char *refname, int refs_peel_ref(struct ref_store *refs, const char *refname,
unsigned char *sha1); struct object_id *oid);
int peel_ref(const char *refname, unsigned char *sha1); int peel_ref(const char *refname, struct object_id *oid);
/** /**
* Resolve refname in the nested "gitlink" repository in the specified * Resolve refname in the nested "gitlink" repository in the specified
......
...@@ -72,12 +72,12 @@ static int cmd_pack_refs(struct ref_store *refs, const char **argv) ...@@ -72,12 +72,12 @@ static int cmd_pack_refs(struct ref_store *refs, const char **argv)
static int cmd_peel_ref(struct ref_store *refs, const char **argv) static int cmd_peel_ref(struct ref_store *refs, const char **argv)
{ {
const char *refname = notnull(*argv++, "refname"); const char *refname = notnull(*argv++, "refname");
unsigned char sha1[20]; struct object_id oid;
int ret; int ret;
ret = refs_peel_ref(refs, refname, sha1); ret = refs_peel_ref(refs, refname, &oid);
if (!ret) if (!ret)
puts(sha1_to_hex(sha1)); puts(oid_to_hex(&oid));
return ret; return ret;
} }
......
...@@ -955,7 +955,7 @@ static int send_ref(const char *refname, const struct object_id *oid, ...@@ -955,7 +955,7 @@ static int send_ref(const char *refname, const struct object_id *oid,
packet_write_fmt(1, "%s %s\n", oid_to_hex(oid), refname_nons); packet_write_fmt(1, "%s %s\n", oid_to_hex(oid), refname_nons);
} }
capabilities = NULL; capabilities = NULL;
if (!peel_ref(refname, peeled.hash)) if (!peel_ref(refname, &peeled))
packet_write_fmt(1, "%s %s^{}\n", oid_to_hex(&peeled), refname_nons); packet_write_fmt(1, "%s %s^{}\n", oid_to_hex(&peeled), refname_nons);
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册