Skip to content

Commit 4dfcf18

Browse files
KarthikNayakgitster
authored andcommitted
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 <[email protected]> Acked-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c3baddf commit 4dfcf18

File tree

3 files changed

+7
-16
lines changed

3 files changed

+7
-16
lines changed

refs.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2303,8 +2303,13 @@ int refs_update_symref_extended(struct ref_store *refs, const char *ref,
23032303
return ret;
23042304
}
23052305

2306-
int ref_update_reject_duplicates(struct string_list *refnames,
2307-
struct strbuf *err)
2306+
/*
2307+
* Write an error to `err` and return a nonzero value iff the same
2308+
* refname appears multiple times in `refnames`. `refnames` must be
2309+
* sorted on entry to this function.
2310+
*/
2311+
static int ref_update_reject_duplicates(struct string_list *refnames,
2312+
struct strbuf *err)
23082313
{
23092314
size_t i, n = refnames->nr;
23102315

refs/files-backend.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3016,12 +3016,6 @@ static int files_transaction_finish_initial(struct files_ref_store *refs,
30163016
if (transaction->state != REF_TRANSACTION_PREPARED)
30173017
BUG("commit called for transaction that is not prepared");
30183018

3019-
string_list_sort(&transaction->refnames);
3020-
if (ref_update_reject_duplicates(&transaction->refnames, err)) {
3021-
ret = TRANSACTION_GENERIC_ERROR;
3022-
goto cleanup;
3023-
}
3024-
30253019
/*
30263020
* It's really undefined to call this function in an active
30273021
* repository or when there are existing references: we are

refs/refs-internal.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,6 @@ int refs_read_raw_ref(struct ref_store *ref_store, const char *refname,
142142
struct object_id *oid, struct strbuf *referent,
143143
unsigned int *type, int *failure_errno);
144144

145-
/*
146-
* Write an error to `err` and return a nonzero value iff the same
147-
* refname appears multiple times in `refnames`. `refnames` must be
148-
* sorted on entry to this function.
149-
*/
150-
int ref_update_reject_duplicates(struct string_list *refnames,
151-
struct strbuf *err);
152-
153145
/*
154146
* Add a ref_update with the specified properties to transaction, and
155147
* return a pointer to the new object. This function does not verify

0 commit comments

Comments
 (0)