diff options
author | Joey Hess <joeyh@joeyh.name> | 2015-01-06 22:23:04 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2015-01-06 22:23:04 -0400 |
commit | 6d9eb8da566c410c7780e15625dfed3f76a3e8f8 (patch) | |
tree | 159edb98ccb910dcd0d407859e1cc874af509ba4 /Annex.hs | |
parent | 3e9ff821877b9f7a5b486bffe6dac2f31ac5887b (diff) |
handle sync's use of setCurrentDirectory to work with relative paths
I think this is the last problimatic setCurrentDirectory. I also audited
for extrnal commands that git-annex might run with cwd = foo, and did not
find any that were passed any FilePath that might be absolute.
Diffstat (limited to 'Annex.hs')
-rw-r--r-- | Annex.hs | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -31,6 +31,7 @@ module Annex ( changeGitRepo, getRemoteGitConfig, withCurrentState, + changeDirectory, ) where import Common @@ -300,3 +301,14 @@ withCurrentState :: Annex a -> Annex (IO a) withCurrentState a = do s <- getState id return $ eval s a + +{- It's not safe to use setCurrentDirectory in the Annex monad, + - because the git repo paths are stored relative. + - Instead, use this. + -} +changeDirectory :: FilePath -> Annex () +changeDirectory d = do + r <- liftIO . Git.adjustPath absPath =<< gitRepo + liftIO $ setCurrentDirectory d + r' <- liftIO $ Git.relPath r + changeState $ \s -> s { repo = r' } |