]> git.ipfire.org Git - thirdparty/git.git/commit
refs/files: remove redundant check in split_symref_update()
authorKarthik Nayak <karthik.188@gmail.com>
Tue, 8 Apr 2025 08:51:05 +0000 (10:51 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 8 Apr 2025 14:57:18 +0000 (07:57 -0700)
commit05a1834e429c619602a8507d8a2c9b81d467c24d
tree41eee26d3275cd36a9bed4ec068ac745820fe6c0
parent7c42ab2c92a54adf0573de36ea29e5bcb819c7da
refs/files: remove redundant check in split_symref_update()

In `split_symref_update()`, there were two checks for duplicate
refnames:

  - At the start, `string_list_has_string()` ensures the refname is not
    already in `affected_refnames`, preventing duplicates from being
    added.

  - After adding the refname, another check verifies whether the newly
    inserted item has a `util` value.

The second check is unnecessary because the first one guarantees that
`string_list_insert()` will never encounter a preexisting entry.

The `item->util` field is assigned to validate that a rename doesn't
already exist in the list. The validation is done after the first check.
As this check is removed, clean up the validation and the assignment of
this field in `split_head_update()` and `files_transaction_prepare()`.

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>
refs/files-backend.c