Re: [PATCH v2 4/6] refs: add REF_SKIP_REFNAME_VERIFICATION flag
From: Junio C Hamano <hidden>
Date: 2021-11-29 23:22:27
"Han-Wen Nienhuys via GitGitGadget" [off-list ref] writes:
From: Han-Wen Nienhuys <redacted> 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.
quoted hunk
Signed-off-by: Han-Wen Nienhuys <redacted> --- 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.
quoted hunk
@@ -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.