]> git.ipfire.org Git - thirdparty/git.git/commit
refs: introduce function to batch refname availability checks
authorPatrick Steinhardt <ps@pks.im>
Wed, 12 Mar 2025 15:56:10 +0000 (16:56 +0100)
committerJunio C Hamano <gitster@pobox.com>
Wed, 12 Mar 2025 18:31:17 +0000 (11:31 -0700)
commit2ff58dec493ab5bebb6943b814461ba4e9937e15
tree67215a59c6d00d02daa8d89538cd9e1242033061
parent3c20bf0c850561482e3da79311d3de1fcfb36091
refs: introduce function to batch refname availability checks

The `refs_verify_refname_available()` functions checks whether a
reference update can be committed or whether it would conflict with
either a prefix or suffix thereof. This function needs to be called once
per reference that one wants to check, which requires us to redo a
couple of checks every time the function is called.

Introduce a new function `refs_verify_refnames_available()` that does
the same, but for a list of references. For now, the new function uses
the exact same implementation, except that we loop through all refnames
provided by the caller. This will be tuned in subsequent commits.

The existing `refs_verify_refname_available()` function is reimplemented
on top of the new function. As such, the diff is best viewed with the
`--ignore-space-change option`.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs.c
refs.h