From: Karthik Nayak Date: Thu, 30 Apr 2026 09:52:16 GMT Subject: Re: [PATCH v3 6/9] update-ref: handle rejections while adding updates Message-ID: In-Reply-To: <87v7dagdjk.fsf@toon--20250203-5JQV3.mail-host-address-is-not-set> Toon Claes writes: > Karthik Nayak writes: > >> @@ -289,22 +300,35 @@ static void parse_cmd_update(struct ref_transaction *transaction, >> if (*next != line_termination) >> die("update %s: extra input: %s", refname, next); >> >> - if (ref_transaction_update(transaction, refname, >> - &new_oid, have_old ? &old_oid : NULL, >> - NULL, NULL, >> - update_flags | create_reflog_flag, >> - msg, &err)) >> + tx_err = ref_transaction_update(transaction, refname, >> + &new_oid, have_old ? &old_oid : NULL, >> + NULL, NULL, >> + update_flags | create_reflog_flag, >> + msg, &err); >> + >> + /* >> + * Generic errors are non-recoverable, so we cannot skip the update >> + * or mark it as rejected. >> + */ >> + if (tx_err == REF_TRANSACTION_ERROR_GENERIC) >> die("%s", err.buf); >> >> + if (tx_err && opts->allow_update_failures) >> + print_rejected_refs(refname, have_old ? &old_oid : NULL, >> + &new_oid, NULL, NULL, tx_err, err.buf, >> + NULL); > > I realize I've made this suggestion, but I think I've made a mistake. > When opts->allow_update_failures is falsey and tx_err is truthy we > should die also. Don't we? > Nice. I didn't think of that either. > I'm not sure what the nicest way is to write this, but maybe: > > if (tx_err) { > if (tx_err == REF_TRANSACTION_ERROR_GENERIC || !opts->allow_update_failures) > die("%s", err.buf); > > print_rejected_refs(refname, have_old ? &old_oid : NULL, > &new_oid, NULL, NULL, tx_err, err.buf, > NULL); > } > > How did test coverage not find this? > Because: 1. The function only returns `REF_TRANSACTION_ERROR_GENERIC` as of this commit. 2. We only seem to be testing this scenario for batched updates. 3. I'll fix this and add some tests. > -- > Cheers, > Toon