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.
This commit is contained in:
parent
676ef32547
commit
44c9714fdf
2 changed files with 14 additions and 1 deletions
12
Annex.hs
12
Annex.hs
|
@ -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' }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue