Repository navigation
Preserve Windows drive letters in Git URLs - #2248
Merged
Merged
Conversation
martindurant
approved these changes
Oct 8, 2026
| path = super()._strip_protocol(path).lstrip("/") | ||
| if ":" in path: | ||
| path = path.split(":", 1)[1] | ||
| path = path.rsplit(":", 1)[1] |
Member
There was a problem hiding this comment.
Some people have switched to using [r]partition. If we don't expect more colon characters, it should be fine.
Contributor
Author
There was a problem hiding this comment.
The existing URL grammar excludes : and @ from the file path, so the rightmost colon is the repository/file separator. Both parsing paths now use rsplit(":", 1), preserving the C: prefix while keeping that grammar. rpartition() would also work here; I kept the existing split structure. The regression cases cover URLs with and without refs, plus reads from a real temporary Git repository on Windows.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1125.
Split Git storage URLs at the final colon so Windows drive letters stay attached to the repository path. Cover explicit and default refs, POSIX, UNC and Windows paths, and real temporary repositories.
The original code fails ten cases; all 23 Git-backend tests pass after the fix. Related filesystem tests: 518 passed, 135 skipped, 12 expected failures. Changed-file checks and the documentation build pass.