diff options
author | Joey Hess <joey@kitenet.net> | 2013-05-11 19:14:30 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-05-11 19:14:30 -0400 |
commit | cbc98eee9d583f56d52a70fbff7abe171a1ecebe (patch) | |
tree | 90dacacdd69cbeb1770c48471d40fc3892c51217 | |
parent | 618af8b6772d25ab27336d240ecddae7ae207561 (diff) |
use setCurrentDirectory
On POSIX, this just calls changeWorkingDirectory.
-rw-r--r-- | Command/Assistant.hs | 3 | ||||
-rw-r--r-- | Command/WebApp.hs | 3 | ||||
-rwxr-xr-x | Git/CurrentRepo.hs | 8 | ||||
-rwxr-xr-x | Test.hs | 9 |
4 files changed, 7 insertions, 16 deletions
diff --git a/Command/Assistant.hs b/Command/Assistant.hs index 32c9c7a15..c40c9e5e9 100644 --- a/Command/Assistant.hs +++ b/Command/Assistant.hs @@ -15,7 +15,6 @@ import Init import Config.Files import System.Environment -import System.Posix.Directory def :: [Command] def = [noRepo checkAutoStart $ dontCheck repoExists $ @@ -64,5 +63,5 @@ autoStart = do ) where go program dir = do - changeWorkingDirectory dir + setCurrentDirectory dir boolSystem program [Param "assistant"] diff --git a/Command/WebApp.hs b/Command/WebApp.hs index 705ff6980..d15319078 100644 --- a/Command/WebApp.hs +++ b/Command/WebApp.hs @@ -28,7 +28,6 @@ import qualified Annex import Config.Files import qualified Option -import System.Posix.Directory import Control.Concurrent import Control.Concurrent.STM import System.Process (env, std_out, std_err) @@ -97,7 +96,7 @@ startNoRepo = do case dirs of [] -> firstRun listenhost (d:_) -> do - changeWorkingDirectory d + setCurrentDirectory d state <- Annex.new =<< Git.CurrentRepo.get void $ Annex.eval state $ doCommand $ start' False listenhost diff --git a/Git/CurrentRepo.hs b/Git/CurrentRepo.hs index 769956aee..2a8807488 100755 --- a/Git/CurrentRepo.hs +++ b/Git/CurrentRepo.hs @@ -9,10 +9,6 @@ module Git.CurrentRepo where -#ifndef __WINDOWS__ -import System.Posix.Directory (changeWorkingDirectory) -#endif - import Common import Git.Types import Git.Construct @@ -39,11 +35,9 @@ get = do case wt of Nothing -> return r Just d -> do -#ifndef __WINDOWS__ cwd <- getCurrentDirectory unless (d `dirContains` cwd) $ - changeWorkingDirectory d -#endif + setCurrentDirectory d return $ addworktree wt r where pathenv s = do @@ -11,7 +11,6 @@ import Test.HUnit import Test.QuickCheck import Test.QuickCheck.Test -import System.Posix.Directory (changeWorkingDirectory) import System.Posix.Files import Control.Exception.Extensible import qualified Data.Map as M @@ -199,7 +198,7 @@ test_add = "git-annex add" ~: TestList [basic, sha1dup, subdirs] git_annex "add" ["dir"] @? "add of subdir failed" createDirectory "dir2" writeFile "dir2/foo" $ content annexedfile - changeWorkingDirectory "dir" + setCurrentDirectory "dir" git_annex "add" ["../dir2"] @? "add of ../subdir failed" test_reinject :: Test @@ -814,7 +813,7 @@ indir dir a = do -- Assertion failures throw non-IO errors; catch -- any type of error and change back to cwd before -- rethrowing. - r <- bracket_ (changeToTmpDir dir) (changeWorkingDirectory cwd) + r <- bracket_ (changeToTmpDir dir) (setCurrentDirectory cwd) (try (a)::IO (Either SomeException ())) case r of Right () -> return () @@ -949,7 +948,7 @@ prepare = do cwd <- getCurrentDirectory p <- Utility.Env.getEnvDefault "PATH" "" void $ Utility.Env.setEnv "PATH" (cwd ++ ":" ++ p) True - void $Utility.Env.setEnv "TOPDIR" cwd True + void $ Utility.Env.setEnv "TOPDIR" cwd True -- Avoid git complaining if it cannot determine the user's email -- address, or exploding if it doesn't know the user's name. void $ Utility.Env.setEnv "GIT_AUTHOR_EMAIL" "test@example.com" True @@ -961,7 +960,7 @@ changeToTmpDir :: FilePath -> IO () changeToTmpDir t = do -- Hack alert. Threading state to here was too much bother. topdir <- Utility.Env.getEnvDefault "TOPDIR" "" - changeWorkingDirectory $ topdir ++ "/" ++ t + setCurrentDirectory $ topdir ++ "/" ++ t tmpdir :: String tmpdir = ".t" |