Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FetchCommand fails if 2 branches have the same name but differ only in case #86

Open
sokai116 opened this issue Aug 23, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@sokai116
Copy link

Version

6.10.0.202406032230-r

Operating System

Windows

Bug description

FetchCommand fails when fetching all branches in Windows OS if any 2 branches have the same name but differ only in case.
This is because it can't create a new file to lock e.g. "feature/branch-A" after another "feature/branch-a" has already been made, so lockLooseRefs(pending); in PackedBatchRefUpdate will return null, and then the fetch silently fails.

Special handling may be needed for Windows, as locking a lower(or upper) case branch is guaranteed to lock all branches differently in case, no need to lock again for any other "synonyms" branches.

Actual behavior

The fetch silently fails, and the FetchCommand shows success but nothing is updated. Try to fetch again will always be the same until one of those branches is deleted in remote.

Expected behavior

The repository remote index is updated.

Relevant log output

No response

Other information

No response

@msohn msohn added the bug Something isn't working label Aug 29, 2024
@MarkEWaite
Copy link

Microsoft recommends to avoid this situation by not using refs that differ only in case.

@msohn
Copy link
Member

msohn commented Sep 16, 2024

PackedBatchRefUpdate checks for name conflicts [1] but doesn't yet consider to compare refs case-insensitive if the filesystem is case-insensitive [2]. The packed-refs format could store multiple refs which only differ in case, though, if the filesystem is case-insensitive, I guess it's better to raise an error early in such cases since the case-insensitive filesystem couldn't handle multiple loose refs which are only different in case.

[1] https://github.com/eclipse-jgit/jgit/blob/master/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackedBatchRefUpdate.java#L137
[2] https://github.com/eclipse-jgit/jgit/blob/master/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackedBatchRefUpdate.java#L213

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants