refs: convert peel_object to struct object_id

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

brian m. carlson committed Oct 15, 2017 at 22:07 UTC ac2ed0d7d51e5c0b402797ecf01f38e9bfc82e0e
4 files changed +11 -11
refs.c
+5 -5
@@ -252,12 +252,12 @@ static int filter_refs(const char *refname, const struct object_id *oid,
252 return filter->fn(refname, oid, flags, filter->cb_data);
253 }
254
255 -enum peel_status peel_object(const unsigned char *name, unsigned char *sha1)
255 +enum peel_status peel_object(const struct object_id *name, struct object_id *oid)
256 {
257 - struct object *o = lookup_unknown_object(name);
257 + struct object *o = lookup_unknown_object(name->hash);
258
259 if (o->type == OBJ_NONE) {
260 - int type = sha1_object_info(name, NULL);
260 + int type = sha1_object_info(name->hash, NULL);
261 if (type < 0 || !object_as_type(o, type, 0))
262 return PEEL_INVALID;
263 }
@@ -269,7 +269,7 @@ enum peel_status peel_object(const unsigned char *name, unsigned char *sha1)
269 if (!o)
270 return PEEL_INVALID;
271
272 - hashcpy(sha1, o->oid.hash);
272 + oidcpy(oid, &o->oid);
273 return PEEL_PEELED;
274 }
275
@@ -1714,7 +1714,7 @@ int refs_peel_ref(struct ref_store *refs, const char *refname,
1714 RESOLVE_REF_READING, &base, &flag))
1715 return -1;
1716
1717 - return peel_object(base.hash, oid->hash);
1717 + return peel_object(&base, oid);
1718 }
1719
1720 int peel_ref(const char *refname, struct object_id *oid)
refs/packed-backend.c
+3 -3
@@ -880,7 +880,7 @@ static int packed_ref_iterator_peel(struct ref_iterator *ref_iterator,
880 } else if ((iter->base.flags & (REF_ISBROKEN | REF_ISSYMREF))) {
881 return -1;
882 } else {
883 - return !!peel_object(iter->oid.hash, peeled->hash);
883 + return !!peel_object(&iter->oid, peeled);
884 }
885 }
886
@@ -1220,8 +1220,8 @@ static int write_with_updates(struct packed_ref_store *refs,
1220 i++;
1221 } else {
1222 struct object_id peeled;
1223 - int peel_error = peel_object(update->new_oid.hash,
1224 - peeled.hash);
1223 + int peel_error = peel_object(&update->new_oid,
1224 + &peeled);
1225
1226 if (write_packed_entry(out, update->refname,
1227 update->new_oid.hash,
refs/ref-cache.c
+1 -1
@@ -493,7 +493,7 @@ static int cache_ref_iterator_advance(struct ref_iterator *ref_iterator)
493 static int cache_ref_iterator_peel(struct ref_iterator *ref_iterator,
494 struct object_id *peeled)
495 {
496 - return peel_object(ref_iterator->oid->hash, peeled->hash);
496 + return peel_object(ref_iterator->oid, peeled);
497 }
498
499 static int cache_ref_iterator_abort(struct ref_iterator *ref_iterator)
refs/refs-internal.h
+2 -2
@@ -120,11 +120,11 @@ enum peel_status {
120 /*
121 * Peel the named object; i.e., if the object is a tag, resolve the
122 * tag recursively until a non-tag is found. If successful, store the
123 - * result to sha1 and return PEEL_PEELED. If the object is not a tag
123 + * result to oid and return PEEL_PEELED. If the object is not a tag
124 * or is not valid, return PEEL_NON_TAG or PEEL_INVALID, respectively,
125 * and leave sha1 unchanged.
126 */
127 -enum peel_status peel_object(const unsigned char *name, unsigned char *sha1);
127 +enum peel_status peel_object(const struct object_id *name, struct object_id *oid);
128
129 /*
130 * Copy the reflog message msg to buf, which has been allocated sufficiently