aboutsummaryrefslogtreecommitdiffstats
path: root/refs.c
diff options
context:
space:
mode:
authorKarthik Nayak <karthik.188@gmail.com>2025-04-08 10:51:07 +0200
committerJunio C Hamano <gitster@pobox.com>2025-04-08 07:57:19 -0700
commit4dfcf18089be03d70dd4a0437bb40af156062738 (patch)
tree9ddfaaf3f2f64bb9808bfcd54f73582352395070 /refs.c
parentrefs: move duplicate refname update check to generic layer (diff)
downloadgit-4dfcf18089be03d70dd4a0437bb40af156062738.tar.gz
git-4dfcf18089be03d70dd4a0437bb40af156062738.zip
refs/files: remove duplicate duplicates check
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'. Signed-off-by: Karthik Nayak <karthik.188@gmail.com> Acked-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/refs.c b/refs.c
index 22000798c7..b34969c792 100644
--- a/refs.c
+++ b/refs.c
@@ -2303,8 +2303,13 @@ cleanup:
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;