Re: [PATCH v2 4/6] refs: add REF_SKIP_REFNAME_VERIFICATION flag
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Nov 29, 2021, 23:22 UTC
- Message-ID
- <xmqqk0gq4keo.fsf@gitster.g>
- In-Reply-To
- <0a297f0c3e884c2d4cfb24a6d3b9f1973fc83125.1638211786.git.gitgitgadget@gmail.com>
"Han-Wen Nienhuys via GitGitGadget" <gitgitgadget@gmail.com> writes:
> From: Han-Wen Nienhuys <hanwen@google.com> > > Use this flag with the test-helper in t1430, to avoid direct writes to the ref > database.
OK, this is similar to 3/6 where invalid object names are allowed. This is about allowing invalid refnames. Makes sense.
Show 22 quoted lines
> Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
> ---
> refs.c | 7 ++---
> refs.h | 10 +++++--
> t/t1430-bad-ref-name.sh | 59 ++++++++++++++++++++++-------------------
> 3 files changed, 44 insertions(+), 32 deletions(-)
>
> diff --git a/refs.c b/refs.c
> index d7cc0a23a3b..086b1341d2a 100644
> --- a/refs.c
> +++ b/refs.c
> @@ -1078,9 +1078,10 @@ int ref_transaction_update(struct ref_transaction *transaction,
> {
> assert(err);
>
> - if ((new_oid && !is_null_oid(new_oid)) ?
> - check_refname_format(refname, REFNAME_ALLOW_ONELEVEL) :
> - !refname_is_safe(refname)) {
> + if (!(flags & REF_SKIP_REFNAME_VERIFICATION) &&
> + ((new_oid && !is_null_oid(new_oid)) ?
> + check_refname_format(refname, REFNAME_ALLOW_ONELEVEL) :
> + !refname_is_safe(refname))) {OK. Initially my eyes went "Huh?", but it was just re-indentation that fooled them.
Show 8 quoted lines
> @@ -617,12 +617,18 @@ struct ref_transaction *ref_transaction_begin(struct strbuf *err); > */ > #define REF_SKIP_OID_VERIFICATION (1 << 10) > > +/* > + * Skip verifying refname. This is useful for testing data corruption scenarios. > + */ > +#define REF_SKIP_REFNAME_VERIFICATION (1 << 11)
OK.