summaryrefslogtreecommitdiff
path: root/object.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2025-11-06 10:54:28 -0800
committerJunio C Hamano <gitster@pobox.com>2025-11-06 10:54:28 -0800
commit994869e2b5a6fa7c8cea2882ba4a396b4e95bf2c (patch)
treec5420efc063d19e503885e0f4b9b5eb5c4a413ed /object.c
parent77b7284ccab768981a2cd08b6b2f164d91201e18 (diff)
parent61ac8ba0f034b61d7353a799fecae9fe45137a72 (diff)
Merge branch 'ps/ref-peeled-tags' into ps/ref-peeled-tags-fixes
* ps/ref-peeled-tags: t7004: do not chdir around in the main process ref-filter: fix stale parsed objects ref-filter: parse objects on demand ref-filter: detect broken tags when dereferencing them refs: don't store peeled object IDs for invalid tags object: add flag to `peel_object()` to verify object type refs: drop infrastructure to peel via iterators refs: drop `current_ref_iter` hack builtin/show-ref: convert to use `reference_get_peeled_oid()` ref-filter: propagate peeled object ID upload-pack: convert to use `reference_get_peeled_oid()` refs: expose peeled object ID via the iterator refs: refactor reference status flags refs: fully reset `struct ref_iterator::ref` on iteration refs: introduce `.ref` field for the base iterator refs: introduce wrapper struct for `each_ref_fn`
Diffstat (limited to 'object.c')
-rw-r--r--object.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/object.c b/object.c
index 986114a6db..e72b0ed436 100644
--- a/object.c
+++ b/object.c
@@ -209,11 +209,12 @@ 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_id *oid,
+ unsigned flags)
{
struct object *o = lookup_unknown_object(r, name);
- if (o->type == OBJ_NONE) {
+ if (o->type == OBJ_NONE || flags & PEEL_OBJECT_VERIFY_OBJECT_TYPE) {
int type = odb_read_object_info(r->objects, name, NULL);
if (type < 0 || !object_as_type(o, type, 0))
return PEEL_INVALID;
@@ -222,7 +223,20 @@ enum peel_status peel_object(struct repository *r,
if (o->type != OBJ_TAG)
return PEEL_NON_TAG;
- o = deref_tag_noverify(r, o);
+ while (o && o->type == OBJ_TAG) {
+ o = parse_object(r, &o->oid);
+ if (o && o->type == OBJ_TAG && ((struct tag *)o)->tagged) {
+ o = ((struct tag *)o)->tagged;
+
+ if (flags & PEEL_OBJECT_VERIFY_OBJECT_TYPE) {
+ int type = odb_read_object_info(r->objects, &o->oid, NULL);
+ if (type < 0 || !object_as_type(o, type, 0))
+ return PEEL_INVALID;
+ }
+ } else {
+ o = NULL;
+ }
+ }
if (!o)
return PEEL_INVALID;