Windows: Fix handling of absolute unix-style git repository paths.
Note that on Windows a remote with a path like /home/foo/bar is interpreted by git as being some screwy relative path (relative to what exactly seems ill-defined -- it seemed relative to C:\Program Files\Git\ in my tests!) So no attempt has been made to handle such a path sanely, just not to crash when encountering it. Note that "C:\\foo" </> "/home/foo/bar" yields /home/foo/bar even though that is not absolute! I don't know what to make of all this, except that I will be very happy when this crock of **** vanishes from the face of the earth.
This commit is contained in:
parent
f068f4e579
commit
c95d0cf7a8
6 changed files with 28 additions and 5 deletions
|
@ -20,12 +20,15 @@ module Git.FilePath (
|
|||
asTopFilePath,
|
||||
InternalGitPath,
|
||||
toInternalGitPath,
|
||||
fromInternalGitPath
|
||||
fromInternalGitPath,
|
||||
absoluteGitPath
|
||||
) where
|
||||
|
||||
import Common
|
||||
import Git
|
||||
|
||||
import qualified System.FilePath.Posix
|
||||
|
||||
{- A FilePath, relative to the top of the git repository. -}
|
||||
newtype TopFilePath = TopFilePath { getTopFilePath :: FilePath }
|
||||
deriving (Show)
|
||||
|
@ -66,3 +69,10 @@ fromInternalGitPath = id
|
|||
#else
|
||||
fromInternalGitPath = replace "/" "\\"
|
||||
#endif
|
||||
|
||||
{- isAbsolute on Windows does not think "/foo" or "\foo" is absolute,
|
||||
- so try posix paths.
|
||||
-}
|
||||
absoluteGitPath :: FilePath -> Bool
|
||||
absoluteGitPath p = isAbsolute p ||
|
||||
System.FilePath.Posix.isAbsolute (toInternalGitPath p)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue