Merge branch 'ps/ref-peeled-tags-fixes'

Another fix-up to "peeled-tags" topic.

* ps/ref-peeled-tags-fixes:
  object: fix performance regression when peeling tags
This commit is contained in:
Junio C Hamano
2025-11-19 10:55:40 -08:00
5 changed files with 11 additions and 11 deletions

View File

@@ -214,7 +214,7 @@ enum peel_status peel_object(struct repository *r,
{ {
struct object *o = lookup_unknown_object(r, name); struct object *o = lookup_unknown_object(r, name);
if (o->type == OBJ_NONE || flags & PEEL_OBJECT_VERIFY_OBJECT_TYPE) { if (o->type == OBJ_NONE) {
int type = odb_read_object_info(r->objects, name, NULL); int type = odb_read_object_info(r->objects, name, 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;
@@ -228,7 +228,7 @@ enum peel_status peel_object(struct repository *r,
if (o && o->type == OBJ_TAG && ((struct tag *)o)->tagged) { if (o && o->type == OBJ_TAG && ((struct tag *)o)->tagged) {
o = ((struct tag *)o)->tagged; o = ((struct tag *)o)->tagged;
if (flags & PEEL_OBJECT_VERIFY_OBJECT_TYPE) { if (flags & PEEL_OBJECT_VERIFY_TAGGED_OBJECT_TYPE) {
int type = odb_read_object_info(r->objects, &o->oid, NULL); int type = odb_read_object_info(r->objects, &o->oid, 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;

View File

@@ -290,13 +290,13 @@ enum peel_status {
enum peel_object_flags { enum peel_object_flags {
/* /*
* Always verify the object type, even in the case where the looked-up * Always verify the object type of the tagged object, even in the case
* object already has an object type. This can be useful when the * where the looked-up object already has an object type. This can be
* stored object type may be invalid. One such case is when looking up * useful when the tagged object type may be invalid. One such case is
* objects via tags, where we blindly trust the object type declared by * when looking up objects via tags, where we blindly trust the object
* the tag. * type declared by the tag.
*/ */
PEEL_OBJECT_VERIFY_OBJECT_TYPE = (1 << 0), PEEL_OBJECT_VERIFY_TAGGED_OBJECT_TYPE = (1 << 0),
}; };
/* /*

View File

@@ -2654,7 +2654,7 @@ static int populate_value(struct ref_array_item *ref, struct strbuf *err)
if (!is_null_oid(&ref->peeled_oid)) { if (!is_null_oid(&ref->peeled_oid)) {
oidcpy(&oi_deref.oid, &ref->peeled_oid); oidcpy(&oi_deref.oid, &ref->peeled_oid);
} else if (!peel_object(the_repository, &oi.oid, &oi_deref.oid, } else if (!peel_object(the_repository, &oi.oid, &oi_deref.oid,
PEEL_OBJECT_VERIFY_OBJECT_TYPE)) { PEEL_OBJECT_VERIFY_TAGGED_OBJECT_TYPE)) {
/* We managed to peel the object ourselves. */ /* We managed to peel the object ourselves. */
} else { } else {
die("bad tag"); die("bad tag");

View File

@@ -1528,7 +1528,7 @@ static enum ref_transaction_error write_with_updates(struct packed_ref_store *re
} else { } else {
struct object_id peeled; struct object_id peeled;
int peel_error = peel_object(refs->base.repo, &update->new_oid, int peel_error = peel_object(refs->base.repo, &update->new_oid,
&peeled, PEEL_OBJECT_VERIFY_OBJECT_TYPE); &peeled, PEEL_OBJECT_VERIFY_TAGGED_OBJECT_TYPE);
if (write_packed_entry(out, update->refname, if (write_packed_entry(out, update->refname,
&update->new_oid, &update->new_oid,

View File

@@ -1633,7 +1633,7 @@ static int write_transaction_table(struct reftable_writer *writer, void *cb_data
ref.update_index = ts; ref.update_index = ts;
peel_error = peel_object(arg->refs->base.repo, &u->new_oid, &peeled, peel_error = peel_object(arg->refs->base.repo, &u->new_oid, &peeled,
PEEL_OBJECT_VERIFY_OBJECT_TYPE); PEEL_OBJECT_VERIFY_TAGGED_OBJECT_TYPE);
if (!peel_error) { if (!peel_error) {
ref.value_type = REFTABLE_REF_VAL2; ref.value_type = REFTABLE_REF_VAL2;
memcpy(ref.value.val2.target_value, peeled.hash, GIT_MAX_RAWSZ); memcpy(ref.value.val2.target_value, peeled.hash, GIT_MAX_RAWSZ);