diff options
author | Joey Hess <joeyh@joeyh.name> | 2015-04-14 14:07:55 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2015-04-14 14:16:44 -0400 |
commit | 8645fc2235eb663e8b050a4790c69e1be1640c09 (patch) | |
tree | 7d65d6c325199d17f4030bc02507bd103b4c99f2 /Utility/Path.hs | |
parent | fcd94707427b5bc8ec635ef378ff90d8772a1443 (diff) |
fix relPathDirToFileAbs on windows with different drive letters
Since we started using this for git repos, when a remote was on another
drive, it resulted in a bogus relative path to it being used by git-annex,
which didn't work.
Diffstat (limited to 'Utility/Path.hs')
-rw-r--r-- | Utility/Path.hs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Utility/Path.hs b/Utility/Path.hs index 2675aa0f9..72d43784f 100644 --- a/Utility/Path.hs +++ b/Utility/Path.hs @@ -138,9 +138,15 @@ relPathDirToFile from to = relPathDirToFileAbs <$> absPath from <*> absPath to {- This requires the first path to be absolute, and the - second path cannot contain ../ or ./ + - + - On Windows, if the paths are on different drives, + - a relative path is not possible and the path is simply + - returned as-is. -} relPathDirToFileAbs :: FilePath -> FilePath -> FilePath -relPathDirToFileAbs from to = join s $ dotdots ++ uncommon +relPathDirToFileAbs from to + | takeDrive from /= takeDrive to = to + | otherwise = join s $ dotdots ++ uncommon where s = [pathSeparator] pfrom = split s from |