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>
This commit is contained in:
parent
49e61479be
commit
ac2ed0d7d5
10
refs.c
10
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);
|
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) {
|
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))
|
if (type < 0 || !object_as_type(o, type, 0))
|
||||||
return PEEL_INVALID;
|
return PEEL_INVALID;
|
||||||
}
|
}
|
||||||
@ -269,7 +269,7 @@ enum peel_status peel_object(const unsigned char *name, unsigned char *sha1)
|
|||||||
if (!o)
|
if (!o)
|
||||||
return PEEL_INVALID;
|
return PEEL_INVALID;
|
||||||
|
|
||||||
hashcpy(sha1, o->oid.hash);
|
oidcpy(oid, &o->oid);
|
||||||
return PEEL_PEELED;
|
return PEEL_PEELED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1714,7 +1714,7 @@ 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, oid->hash);
|
return peel_object(&base, oid);
|
||||||
}
|
}
|
||||||
|
|
||||||
int peel_ref(const char *refname, struct object_id *oid)
|
int peel_ref(const char *refname, struct object_id *oid)
|
||||||
|
@ -880,7 +880,7 @@ static int packed_ref_iterator_peel(struct ref_iterator *ref_iterator,
|
|||||||
} else if ((iter->base.flags & (REF_ISBROKEN | REF_ISSYMREF))) {
|
} else if ((iter->base.flags & (REF_ISBROKEN | REF_ISSYMREF))) {
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} 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++;
|
i++;
|
||||||
} else {
|
} else {
|
||||||
struct object_id peeled;
|
struct object_id peeled;
|
||||||
int peel_error = peel_object(update->new_oid.hash,
|
int peel_error = peel_object(&update->new_oid,
|
||||||
peeled.hash);
|
&peeled);
|
||||||
|
|
||||||
if (write_packed_entry(out, update->refname,
|
if (write_packed_entry(out, update->refname,
|
||||||
update->new_oid.hash,
|
update->new_oid.hash,
|
||||||
|
@ -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,
|
static int cache_ref_iterator_peel(struct ref_iterator *ref_iterator,
|
||||||
struct object_id *peeled)
|
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)
|
static int cache_ref_iterator_abort(struct ref_iterator *ref_iterator)
|
||||||
|
@ -120,11 +120,11 @@ enum peel_status {
|
|||||||
/*
|
/*
|
||||||
* Peel the named object; i.e., if the object is a tag, resolve the
|
* 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
|
* 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,
|
* or is not valid, return PEEL_NON_TAG or PEEL_INVALID, respectively,
|
||||||
* and leave sha1 unchanged.
|
* 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
|
* Copy the reflog message msg to buf, which has been allocated sufficiently
|
||||||
|
Loading…
Reference in New Issue
Block a user