]> git.ipfire.org Git - thirdparty/git.git/blobdiff - refs.c
refs: update some more docs to use "oid" rather than "sha1"
[thirdparty/git.git] / refs.c
diff --git a/refs.c b/refs.c
index 72c45a513b967799cbfb7a94bbf9c2c4eea72663..339d4318ee4500ffeb26426bdf9976979ecf739a 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;
 }
 
@@ -770,7 +770,7 @@ static int read_ref_at_ent(struct object_id *ooid, struct object_id *noid,
                if (cb->cutoff_cnt)
                        *cb->cutoff_cnt = cb->reccnt - 1;
                /*
-                * we have not yet updated cb->[n|o]sha1 so they still
+                * we have not yet updated cb->[n|o]oid so they still
                 * hold the values for the previous record.
                 */
                if (!is_null_oid(&cb->ooid)) {
@@ -906,9 +906,6 @@ struct ref_update *ref_transaction_add_update(
        if (transaction->state != REF_TRANSACTION_OPEN)
                die("BUG: update called for transaction that is not open");
 
-       if ((flags & REF_ISPRUNING) && !(flags & REF_NODEREF))
-               die("BUG: REF_ISPRUNING set without REF_NODEREF");
-
        FLEX_ALLOC_STR(update, refname, refname);
        ALLOC_GROW(transaction->updates, transaction->nr + 1, transaction->alloc);
        transaction->updates[transaction->nr++] = update;
@@ -940,7 +937,8 @@ int ref_transaction_update(struct ref_transaction *transaction,
                return -1;
        }
 
-       flags &= REF_TRANSACTION_UPDATE_ALLOWED_FLAGS;
+       if (flags & ~REF_TRANSACTION_UPDATE_ALLOWED_FLAGS)
+               BUG("illegal flags 0x%x passed to ref_transaction_update()", flags);
 
        flags |= (new_oid ? REF_HAVE_NEW : 0) | (old_oid ? REF_HAVE_OLD : 0);
 
@@ -1382,10 +1380,10 @@ int for_each_rawref(each_ref_fn fn, void *cb_data)
 }
 
 int refs_read_raw_ref(struct ref_store *ref_store,
-                     const char *refname, unsigned char *sha1,
+                     const char *refname, struct object_id *oid,
                      struct strbuf *referent, unsigned int *type)
 {
-       return ref_store->be->read_raw_ref(ref_store, refname, sha1, referent, type);
+       return ref_store->be->read_raw_ref(ref_store, refname, oid, referent, type);
 }
 
 /* This function needs to return a meaningful errno on failure */
@@ -1428,7 +1426,7 @@ const char *refs_resolve_ref_unsafe(struct ref_store *refs,
                unsigned int read_flags = 0;
 
                if (refs_read_raw_ref(refs, refname,
-                                     oid->hash, &sb_refname, &read_flags)) {
+                                     oid, &sb_refname, &read_flags)) {
                        *flags |= read_flags;
 
                        /* In reading mode, refs must eventually resolve */
@@ -1714,7 +1712,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)
@@ -1879,7 +1877,7 @@ int refs_verify_refname_available(struct ref_store *refs,
                if (skip && string_list_has_string(skip, dirname.buf))
                        continue;
 
-               if (!refs_read_raw_ref(refs, dirname.buf, oid.hash, &referent, &type)) {
+               if (!refs_read_raw_ref(refs, dirname.buf, &oid, &referent, &type)) {
                        strbuf_addf(err, "'%s' exists; cannot create '%s'",
                                    dirname.buf, refname);
                        goto cleanup;