]> granicus.if.org Git - git/commitdiff
refs: convert peel_object to struct object_id
authorbrian m. carlson <sandals@crustytoothpaste.net>
Sun, 15 Oct 2017 22:07:10 +0000 (22:07 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 16 Oct 2017 02:05:52 +0000 (11:05 +0900)
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs.c
refs/packed-backend.c
refs/ref-cache.c
refs/refs-internal.h

diff --git a/refs.c b/refs.c
index 72c45a513b967799cbfb7a94bbf9c2c4eea72663..6546346b6ab90c58f1f92a2196d6f1c71055a75a 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -252,12 +252,12 @@ static int filter_refs(const char *refname, const struct object_id *oid,
        return filter->fn(refname, oid, flags, filter->cb_data);
 }
 
-enum peel_status peel_object(const unsigned char *name, unsigned char *sha1)
+enum peel_status peel_object(const struct object_id *name, struct object_id *oid)
 {
-       struct object *o = lookup_unknown_object(name);
+       struct object *o = lookup_unknown_object(name->hash);
 
        if (o->type == OBJ_NONE) {
-               int type = sha1_object_info(name, NULL);
+               int type = sha1_object_info(name->hash, NULL);
                if (type < 0 || !object_as_type(o, type, 0))
                        return PEEL_INVALID;
        }
@@ -269,7 +269,7 @@ enum peel_status peel_object(const unsigned char *name, unsigned char *sha1)
        if (!o)
                return PEEL_INVALID;
 
-       hashcpy(sha1, o->oid.hash);
+       oidcpy(oid, &o->oid);
        return PEEL_PEELED;
 }
 
@@ -1714,7 +1714,7 @@ int refs_peel_ref(struct ref_store *refs, const char *refname,
                               RESOLVE_REF_READING, &base, &flag))
                return -1;
 
-       return peel_object(base.hash, oid->hash);
+       return peel_object(&base, oid);
 }
 
 int peel_ref(const char *refname, struct object_id *oid)
index 4ec9fcacdd752302c8c289e77b26774378c96477..b7652738be6293e3c92b07cec3e7ed976d6cccd2 100644 (file)
@@ -880,7 +880,7 @@ static int packed_ref_iterator_peel(struct ref_iterator *ref_iterator,
        } else if ((iter->base.flags & (REF_ISBROKEN | REF_ISSYMREF))) {
                return -1;
        } else {
-               return !!peel_object(iter->oid.hash, peeled->hash);
+               return !!peel_object(&iter->oid, peeled);
        }
 }
 
@@ -1220,8 +1220,8 @@ static int write_with_updates(struct packed_ref_store *refs,
                        i++;
                } else {
                        struct object_id peeled;
-                       int peel_error = peel_object(update->new_oid.hash,
-                                                    peeled.hash);
+                       int peel_error = peel_object(&update->new_oid,
+                                                    &peeled);
 
                        if (write_packed_entry(out, update->refname,
                                               update->new_oid.hash,
index 4f850e1b5c9ed1fae746a804ceceee42e2f54b86..043eb83748739d9d3d78586c69005bb866554e7e 100644 (file)
@@ -493,7 +493,7 @@ static int cache_ref_iterator_advance(struct ref_iterator *ref_iterator)
 static int cache_ref_iterator_peel(struct ref_iterator *ref_iterator,
                                   struct object_id *peeled)
 {
-       return peel_object(ref_iterator->oid->hash, peeled->hash);
+       return peel_object(ref_iterator->oid, peeled);
 }
 
 static int cache_ref_iterator_abort(struct ref_iterator *ref_iterator)
index 3c4781eb875b4353dff943288a6eef73ec271ff2..54059c1daf30ffc4d39283de3c9e4c8e1fe6d371 100644 (file)
@@ -120,11 +120,11 @@ enum peel_status {
 /*
  * Peel the named object; i.e., if the object is a tag, resolve the
  * tag recursively until a non-tag is found.  If successful, store the
- * result to sha1 and return PEEL_PEELED.  If the object is not a tag
+ * result to oid and return PEEL_PEELED.  If the object is not a tag
  * or is not valid, return PEEL_NON_TAG or PEEL_INVALID, respectively,
  * and leave sha1 unchanged.
  */
-enum peel_status peel_object(const unsigned char *name, unsigned char *sha1);
+enum peel_status peel_object(const struct object_id *name, struct object_id *oid);
 
 /*
  * Copy the reflog message msg to buf, which has been allocated sufficiently