Re: [PATCH v4 04/12] refs: allow to skip creation of reflog entries

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

 



Patrick Steinhardt <ps@xxxxxx> writes:

[snip]

> diff --git a/refs/files-backend.c b/refs/files-backend.c
> index 73380d7e99..bd0d63bcba 100644
> --- a/refs/files-backend.c
> +++ b/refs/files-backend.c
> @@ -1750,6 +1750,9 @@ static int files_log_ref_write(struct files_ref_store *refs,
>  {
>  	int logfd, result;
>
> +	if (flags & REF_SKIP_CREATE_REFLOG)
> +		return 0;
> +
>  	if (log_all_ref_updates == LOG_REFS_UNSET)
>  		log_all_ref_updates = is_bare_repository() ? LOG_REFS_NONE : LOG_REFS_NORMAL;
>
> @@ -2251,6 +2254,7 @@ static int split_head_update(struct ref_update *update,
>  	struct ref_update *new_update;
>
>  	if ((update->flags & REF_LOG_ONLY) ||
> +	    (update->flags & REF_SKIP_CREATE_REFLOG) ||
>  	    (update->flags & REF_IS_PRUNING) ||
>  	    (update->flags & REF_UPDATE_VIA_HEAD))
>  		return 0;

So updates to refs which are pointed by HEAD usually trigger a reflog
entry for HEAD itself. Here we skip that since REF_SKIP_CREATE_REFLOG is
set. Nice, this is an edge case that could have been easy to miss.

> diff --git a/refs/reftable-backend.c b/refs/reftable-backend.c
> index f6edfdf5b3..bffed9257f 100644
> --- a/refs/reftable-backend.c
> +++ b/refs/reftable-backend.c
> @@ -1103,7 +1103,8 @@ static int write_transaction_table(struct reftable_writer *writer, void *cb_data
>
>  			if (ret)
>  				goto done;
> -		} else if (u->flags & REF_HAVE_NEW &&
> +		} else if (!(u->flags & REF_SKIP_CREATE_REFLOG) &&
> +			   (u->flags & REF_HAVE_NEW) &&
>  			   (u->flags & REF_FORCE_CREATE_REFLOG ||
>  			    should_write_log(&arg->refs->base, u->refname))) {
>  			struct reftable_log_record *log;
> diff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c
> index c9efd74c2b..ad24300170 100644
> --- a/t/helper/test-ref-store.c
> +++ b/t/helper/test-ref-store.c
> @@ -126,6 +126,7 @@ static struct flag_definition transaction_flags[] = {
>  	FLAG_DEF(REF_FORCE_CREATE_REFLOG),
>  	FLAG_DEF(REF_SKIP_OID_VERIFICATION),
>  	FLAG_DEF(REF_SKIP_REFNAME_VERIFICATION),
> +	FLAG_DEF(REF_SKIP_CREATE_REFLOG),
>  	{ NULL, 0 }
>  };
>
> --
> 2.45.1.410.g58bac47f8e.dirty

Attachment: signature.asc
Description: PGP signature


[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