summaryrefslogtreecommitdiff
path: root/Git
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-12-04 23:49:18 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-12-04 23:49:18 -0400
commitb5392d98b569d89da788213b594de870a3feff8c (patch)
tree8322e42ee38596b5c45c90e67870e7e54ee9d288 /Git
parent38480793489981910d3e53c8dc978c97ee7abd4c (diff)
work around msysgit very strange behavior on ./ or .\ at start of path
Seems that verify_path() rejects such a path on Windows, but I cannot see why. Git bug?
Diffstat (limited to 'Git')
-rw-r--r--Git/FilePath.hs15
1 files changed, 12 insertions, 3 deletions
diff --git a/Git/FilePath.hs b/Git/FilePath.hs
index 37d740f25..4189244fc 100644
--- a/Git/FilePath.hs
+++ b/Git/FilePath.hs
@@ -45,15 +45,24 @@ asTopFilePath :: FilePath -> TopFilePath
asTopFilePath file = TopFilePath file
{- Git may use a different representation of a path when storing
- - it internally. For example, on Windows, git uses '/' to separate paths
- - stored in the repository, despite Windows using '\' -}
+ - it internally.
+ -
+ - On Windows, git uses '/' to separate paths stored in the repository,
+ - despite Windows using '\'. Also, git on windows dislikes paths starting
+ - with "./" or ".\".
+ -
+ -}
type InternalGitPath = String
toInternalGitPath :: FilePath -> InternalGitPath
#ifndef mingw32_HOST_OS
toInternalGitPath = id
#else
-toInternalGitPath = replace "\\" "/"
+toInternalGitPath p =
+ let p' = replace "\\" "/" p
+ in if "./" `isPrefixOf` p'
+ then dropWhile (== '/') (drop 1 p')
+ else p'
#endif
fromInternalGitPath :: InternalGitPath -> FilePath