Attempt to uniformly handle Windows-style paths. #549
Merged
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.
Passing a Windows path with backslashes to a git2 API that expects a repo path is always wrong. This attempts to consolidate the translation of backslashes, and I tried to cover every method that takes a repo path or pathspec.
This also checks if the path is absolute on all platforms. git2 repo paths are never absolute (AFAIK). The intent is to avoid footguns like #164 where passing filesystem-like paths with leading non-normal components never works (except for maybe
is_path_ignored
).I flip-flopped a lot on how to approach this, and I'm not entirely happy with it (though I can't pinpoint why). I generally wanted to avoid changing any public APIs.
Closes #340