Re: [PATCH v2 4/6] refs: add REF_SKIP_REFNAME_VERIFICATION flag

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Han-Wen Nienhuys via GitGitGadget" <gitgitgadget@xxxxxxxxx> writes:

> From: Han-Wen Nienhuys <hanwen@xxxxxxxxxx>
>
> 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.



> Signed-off-by: Han-Wen Nienhuys <hanwen@xxxxxxxxxx>
> ---
>  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.

> @@ -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.



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux