git/refs
Karthik Nayak 770f389b2d refs/files: handle F/D conflicts in case-insensitive FS
When using the files-backend on case-insensitive filesystems, there is
possibility of hitting F/D conflicts when creating references within a
single transaction, such as:

  - 'refs/heads/foo'
  - 'refs/heads/Foo/bar'

Ideally such conflicts are caught in `refs_verify_refnames_available()`
which is responsible for checking F/D conflicts within a given
transaction. This utility function is shared across the reference
backends. As such, it doesn't consider the issues of using a
case-insensitive file system, which only affects the files-backend.

While one solution would be to make the function aware of such issues,
this feels like leaking implementation details of file-backend specific
issues into the utility function. So opt for the more simpler option, of
lowercasing all references sent to this function when on a
case-insensitive filesystem and operating on the files-backend.

To do this, simply use a `struct strbuf` to convert the refname to
lowercase and append it to the list of refnames to be checked. Since we
use a `struct strbuf` and the memory is cleared right after, make sure
that the string list duplicates all provided string.

Without this change, the user would simply be left with a repository
with '.lock' files which were created in the 'prepare' phase of the
transaction, as the 'commit' phase would simply abort and not do the
necessary cleanup.

Reported-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-09-17 09:19:08 -07:00
..
debug.c refs: selectively set prefix in the seek functions 2025-07-15 11:54:20 -07:00
files-backend.c refs/files: handle F/D conflicts in case-insensitive FS 2025-09-17 09:19:08 -07:00
iterator.c refs: selectively set prefix in the seek functions 2025-07-15 11:54:20 -07:00
packed-backend.c Merge branch 'ps/config-wo-the-repository' 2025-08-04 08:10:33 -07:00
packed-backend.h refs/files: use heuristic to decide whether to repack with `--auto` 2024-09-04 08:03:24 -07:00
ref-cache.c ref-cache: use 'size_t' instead of int for length 2025-07-28 14:16:36 -07:00
ref-cache.h ref-cache: remove unused function 'find_ref_entry()' 2025-07-15 11:54:19 -07:00
refs-internal.h refs: selectively set prefix in the seek functions 2025-07-15 11:54:20 -07:00
reftable-backend.c Merge branch 'ps/config-wo-the-repository' 2025-08-04 08:10:33 -07:00