summaryrefslogtreecommitdiff
path: root/Git/FilePath.hs
diff options
context:
space:
mode:
authorJoey Hess <joey@kitenet.net>2013-12-10 15:46:51 -0400
committerJoey Hess <joey@kitenet.net>2013-12-10 15:48:18 -0400
commit444a4dad77289265296d1fa76e060c46497ec6c8 (patch)
tree8195b01fd8f0058d738660430038da23b57ee082 /Git/FilePath.hs
parenta0aab76ae762614041720dd55d63ed3e0b7c1c94 (diff)
downloadgit-repair-444a4dad77289265296d1fa76e060c46497ec6c8.tar.gz
merge from git-annex
Diffstat (limited to 'Git/FilePath.hs')
-rw-r--r--Git/FilePath.hs15
1 files changed, 12 insertions, 3 deletions
diff --git a/Git/FilePath.hs b/Git/FilePath.hs
index 37d740f..4189244 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