diff options
| author | Karthik Nayak <karthik.188@gmail.com> | 2025-09-17 17:25:13 +0200 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-09-17 09:19:08 -0700 |
| commit | 770f389b2d4b7a8f22d6350bed32effa74bd2253 (patch) | |
| tree | bfdffd59eb9e36b239f6eefef9fba9fa25914830 /t/t5510-fetch.sh | |
| parent | refs/files: use correct error type when lock exists (diff) | |
| download | git-770f389b2d4b7a8f22d6350bed32effa74bd2253.tar.gz git-770f389b2d4b7a8f22d6350bed32effa74bd2253.zip | |
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>
Diffstat (limited to '')
| -rwxr-xr-x | t/t5510-fetch.sh | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh index 6f8db0ace4..08dbea6503 100755 --- a/t/t5510-fetch.sh +++ b/t/t5510-fetch.sh @@ -53,6 +53,12 @@ test_expect_success "clone and setup child repos" ' cd case_sensitive && git branch branch1 && git branch bRanch1 + ) && + git clone --ref-format=reftable . case_sensitive_fd && + ( + cd case_sensitive_fd && + git branch foo/bar && + git branch Foo ) ' @@ -1572,6 +1578,20 @@ test_expect_success REFFILES 'existing reference lock in repo' ' ) ' +test_expect_success CASE_INSENSITIVE_FS,REFFILES 'F/D conflict on case insensitive filesystem' ' + test_when_finished rm -rf case_insensitive && + ( + git init --bare case_insensitive && + cd case_insensitive && + git remote add origin -- ../case_sensitive_fd && + test_must_fail git fetch -f origin "refs/heads/*:refs/heads/*" 2>err && + test_grep "failed: refname conflict" err && + git rev-parse refs/heads/main >expect && + git rev-parse refs/heads/foo/bar >actual && + test_cmp expect actual + ) +' + . "$TEST_DIRECTORY"/lib-httpd.sh start_httpd |
