fix for #26: strip "drive-folder" from path returned by git rev-parse#31
Open
supersonic-copycat wants to merge 2 commits intosnoyberg:masterfrom
Open
fix for #26: strip "drive-folder" from path returned by git rev-parse#31supersonic-copycat wants to merge 2 commits intosnoyberg:masterfrom
git rev-parse#31supersonic-copycat wants to merge 2 commits intosnoyberg:masterfrom
Conversation
if Git is installed in MSYS2, `git rev-parse --show-toplevel` returns path like '/c/path/to/repo'. First directory is not a real one, but a reference to drive. `normalise` converts this to '\\c\\path\\to\\repo', and running command will prepend current drive letter, and as result wrond path is to be searched -- 'C:\\c\\path\\to\\repo'! Quick solution is to strip drive reference from path. Since Windows allows '/' only as path separator and not in names, this should be pretty straightforward. BUT! 'Git for windows' returns path with correct reference to drive -- 'C:/path/to/repo'. So, we have to check not only platform (I did it with System.Info.os), but the first symbol of path, to make sure we are not corrupting path for folks using 'Git for windows'
actually, I forgot to do very essense of fix
This was referenced Aug 15, 2025
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.
Seems, like problems like #26 caused by different path handling.
Windows have two path separators,
\and/, former is preferred. Absolute path has drive letter prepended, but both separators can be used: bothC:\path\to\repo\andC:/path/to/repoare valid.Tools from MSYS2 uses Unix-style path, where drive letter prepended like an ordinary directory, so they generally consume (and emit!) path like this
/c/path/to/repo.If Git is installed in MSYS2,
git rev-parse --show-toplevelreturns path like/c/path/to/repo.normalisereplaces secondary separator with primary and makes path looks like\c\path\to\repo.readProcessimplicitly prepends (though I have no proofs!) current drive letter path to be searched becomesC:\c\path\to\repo, and most likely it doesn't exist! (I tried to create repo atC:/c/path/to/repo/, andgithashtook info from it, not fromC:/path/to/repo/!)Quick solution is to strip drive folder from path. Since Windows allows '/' only as path separator and not in names, this should be pretty straightforward. But since 'Git for windows' returns path with correct reference to drive (
C:/path/to/repo) we have to check not only platform we are running on (I did it withSystem.Info.os), but also the first symbol of path, to make sure we it's/and not drive letter already, so we won't corrupt path for folks whose git returns Windows-style path.Also, WSL have to be considered, but I have no machine with it, so cannot test there.