summaryrefslogtreecommitdiffstats
path: root/object.h
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2024-05-17 10:18:59 +0200
committerJunio C Hamano <gitster@pobox.com>2024-05-17 19:33:39 +0200
commit19c76e8235747a61a703fe3bf7a5e40caf6fa3fa (patch)
tree846d0436f27f1c9e8c228bce9a8b323293558a7a /object.h
parentrefs: pass ref store when detecting dangling symrefs (diff)
downloadgit-19c76e8235747a61a703fe3bf7a5e40caf6fa3fa.tar.xz
git-19c76e8235747a61a703fe3bf7a5e40caf6fa3fa.zip
refs: move object peeling into "object.c"
Peeling an object has nothing to do with refs, but we still have the code in "refs.c". Move it over into "object.c", which is a more natural place to put it. Ideally, we'd also move `peel_iterated_oid()` over into "object.c". But this function is tied to the refs interfaces because it uses a global ref iterator variable to optimize peeling when the iterator already has the peeled object ID readily available. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'object.h')
-rw-r--r--object.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/object.h b/object.h
index 9293e703cc..31ccd1bb10 100644
--- a/object.h
+++ b/object.h
@@ -256,6 +256,40 @@ struct object *lookup_unknown_object(struct repository *r, const struct object_i
struct object *lookup_object_by_type(struct repository *r, const struct object_id *oid,
enum object_type type);
+enum peel_status {
+ /* object was peeled successfully: */
+ PEEL_PEELED = 0,
+
+ /*
+ * object cannot be peeled because the named object (or an
+ * object referred to by a tag in the peel chain), does not
+ * exist.
+ */
+ PEEL_INVALID = -1,
+
+ /* object cannot be peeled because it is not a tag: */
+ PEEL_NON_TAG = -2,
+
+ /* ref_entry contains no peeled value because it is a symref: */
+ PEEL_IS_SYMREF = -3,
+
+ /*
+ * ref_entry cannot be peeled because it is broken (i.e., the
+ * symbolic reference cannot even be resolved to an object
+ * name):
+ */
+ PEEL_BROKEN = -4
+};
+
+/*
+ * 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 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 oid unchanged.
+ */
+enum peel_status peel_object(const struct object_id *name, struct object_id *oid);
+
struct object_list *object_list_insert(struct object *item,
struct object_list **list_p);