use setCurrentDirectory

On POSIX, this just calls changeWorkingDirectory.
This commit is contained in:
Joey Hess 2013-05-11 19:14:30 -04:00
parent 18bdff3fae
commit 1e2ddcb68a
5 changed files with 8 additions and 18 deletions

View file

@ -38,7 +38,6 @@ import Config
import qualified Data.Text as T
import qualified Data.Map as M
import Data.Char
import System.Posix.Directory
data RepositoryPath = RepositoryPath Text
deriving Show
@ -320,7 +319,7 @@ startFullAssistant path repogroup = do
u <- initRepo isnew True path Nothing
inDir path $ setStandardGroup u repogroup
addAutoStartFile path
changeWorkingDirectory path
setCurrentDirectory path
fromJust $ postFirstRun webapp
redirect $ T.pack url

View file

@ -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"]

View file

@ -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

View file

@ -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

View file

@ -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 ()
@ -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"