diff options
author | Joey Hess <joeyh@joeyh.name> | 2015-01-06 14:50:15 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2015-01-06 14:50:15 -0400 |
commit | be7a95c7bcb4e78d267f56385ad0995c08395f3f (patch) | |
tree | 348d153d7a8ab54810fdbd9101cebeabf17f6ef6 | |
parent | 27195fc7ecb70e185e9a78f8bd3d758bfe262a22 (diff) |
try to avoid Windows MAX_PATH limit, by using \\?\ prefix on git repo path
-rw-r--r-- | Annex.hs | 2 | ||||
-rw-r--r-- | Git.hs | 24 |
2 files changed, 25 insertions, 1 deletions
@@ -187,7 +187,7 @@ newState c r = AnnexState - Ensures the config is read, if it was not already. -} new :: Git.Repo -> IO AnnexState new r = do - r' <- Git.Config.read r + r' <- Git.adjustPath <$> Git.Config.read r let c = extractGitConfig r' newState c <$> if annexDirect c then fixupDirect r' else return r' @@ -30,6 +30,7 @@ module Git ( attributes, hookPath, assertLocal, + adjustPath, ) where import Network.URI (uriPath, uriScheme, unEscapeString) @@ -139,3 +140,26 @@ hookPath script repo = do #else isexecutable f = isExecutable . fileMode <$> getFileStatus f #endif + +{- Adusts the path to a local Repo. + - + - On windows, prefixing a path with \\?\ makes it be processed as a raw + - path (/ is not converted to \). The benefit is that such a path does + - avoids Windows's 260 byte limitation on the entire path. -} +adjustPath :: Repo -> Repo +adjustPath r@(Repo { location = l@(Local { gitdir = d, worktree = w }) }) = r + { location = l + { gitdir = adjustPath' d + , worktree = fmap adjustPath' w + } + } +adjustPath r@(Repo { location = LocalUnknown d }) = + r { location = LocalUnknown (adjustPath' d) } +adjustPath r = r + +adjustPath' :: FilePath -> FilePath +#if mingw32_HOST_OS +adjustPath' d = "\\\\?\\" ++ d +#else +adjustPath' = id +#endif |