Re: [PATCH 3/6] refs/files: remove duplicate duplicates check
On Fri, Feb 07, 2025 at 08:34:38AM +0100, Karthik Nayak wrote:
Show 12 quoted lines
> Within the files reference backend's transaction's 'finish' phase, a
> verification step is currently performed wherein the refnames list is
> sorted and examined for multiple updates targeting the same refname.
>
> It has been observed that this verification is redundant, as an
> identical check is already executed during the transaction's 'prepare'
> stage. Since the refnames list remains unmodified following the
> 'prepare' stage, this secondary verification can be safely eliminated.
>
> The duplicate check has been removed accordingly, and the
> `ref_update_reject_duplicates()` function has been marked as static, as
> its usage is now confined to 'refs.c'.
Nice, I had been wondering about this code in the preceding commit.
Show 20 quoted lines
> diff --git a/refs.c b/refs.c
> index 4c9b706461977995be1d55e7667f7fb708fbbb76..b420a120102b3793168598b885bba68e4f5f5f03 100644
> --- a/refs.c
> +++ b/refs.c
> @@ -2295,8 +2295,13 @@ int refs_update_symref_extended(struct ref_store *refs, const char *ref,
> return ret;
> }
>
> -int ref_update_reject_duplicates(struct string_list *refnames,
> - struct strbuf *err)
> +/*
> + * Write an error to `err` and return a nonzero value iff the same
> + * refname appears multiple times in `refnames`. `refnames` must be
> + * sorted on entry to this function.
> + */
> +static int ref_update_reject_duplicates(struct string_list *refnames,
> + struct strbuf *err)
> {
> size_t i, n = refnames->nr;
> Doubly nice that this can now be static.
Patrick