aboutsummaryrefslogtreecommitdiffstats
path: root/object.c
diff options
context:
space:
mode:
Diffstat (limited to 'object.c')
-rw-r--r--object.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/object.c b/object.c
index 51e384828e..93b5d97fdb 100644
--- a/object.c
+++ b/object.c
@@ -207,6 +207,29 @@ struct object *lookup_object_by_type(struct repository *r,
}
}
+enum peel_status peel_object(struct repository *r,
+ const struct object_id *name,
+ struct object_id *oid)
+{
+ struct object *o = lookup_unknown_object(r, name);
+
+ if (o->type == OBJ_NONE) {
+ int type = oid_object_info(r, name, NULL);
+ if (type < 0 || !object_as_type(o, type, 0))
+ return PEEL_INVALID;
+ }
+
+ if (o->type != OBJ_TAG)
+ return PEEL_NON_TAG;
+
+ o = deref_tag_noverify(r, o);
+ if (!o)
+ return PEEL_INVALID;
+
+ oidcpy(oid, &o->oid);
+ return PEEL_PEELED;
+}
+
struct object *parse_object_buffer(struct repository *r, const struct object_id *oid, enum object_type type, unsigned long size, void *buffer, int *eaten_p)
{
struct object *obj;