From: Karthik Nayak Date: Mon, 27 Apr 2026 09:32:15 GMT Subject: Re: [PATCH v2 7/9] refs: move object parsing to the generic layer Message-ID: In-Reply-To: <87zf2sd0lb.fsf@toon--20250203-5JQV3.mail-host-address-is-not-set> Toon Claes writes: [snip] >> diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c >> index 878aa7f0ed..0fb3d57de8 100644 >> --- a/builtin/receive-pack.c >> +++ b/builtin/receive-pack.c >> @@ -1641,8 +1641,8 @@ static const char *update(struct command *cmd, struct shallow_info *si) >> ret = NULL; /* good */ >> } >> strbuf_release(&err); >> - } >> - else { >> + } else { >> + enum ref_transaction_error err_type; > > Shall we also use `tx_err` like in builtin/update-ref.c? > Makes sense, let's do that. >> diff --git a/refs.c b/refs.c >> index efa16b739d..662a9e6f9e 100644 >> --- a/refs.c >> +++ b/refs.c >> @@ -1416,6 +1416,24 @@ enum ref_transaction_error ref_transaction_update(struct ref_transaction *transa >> flags |= (new_oid ? REF_HAVE_NEW : 0) | (old_oid ? REF_HAVE_OLD : 0); >> flags |= (new_target ? REF_HAVE_NEW : 0) | (old_target ? REF_HAVE_OLD : 0); >> >> + if ((flags & REF_HAVE_NEW) && !new_target && !is_null_oid(new_oid) && >> + !(flags & REF_SKIP_OID_VERIFICATION) && !(flags & REF_LOG_ONLY)) { > > Compared to the version we used to have in refs/reftable-backend.c, > you've added `!new_target`. Why is that? If I understand correctly, that > only happens when `new_oid` is set. Wouldn't `!is_null_oid(new_oid)` > guard for that? > Since `new_oid` is a pointer here, we don't know if it's NULL or not. `is_null_oid()` doesn't validate NULL values, so the check must come before it. If `REF_HAVE_NEW` is set, it either means that either `new_target` is set or `new_oid` is set. So we check that `new_target` is NULL. The reftable check worked as there we operate on top of `struct ref_update`, which contains `struct object_id new_oid;`, since it is not a pointer, the value is 0 when `new_target` is set. This works with the `is_null_oid()` check. > -- > Cheers, > Toon