use setCurrentDirectory
On POSIX, this just calls changeWorkingDirectory.
This commit is contained in:
parent
18bdff3fae
commit
1e2ddcb68a
5 changed files with 8 additions and 18 deletions
|
@ -38,7 +38,6 @@ import Config
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
import Data.Char
|
import Data.Char
|
||||||
import System.Posix.Directory
|
|
||||||
|
|
||||||
data RepositoryPath = RepositoryPath Text
|
data RepositoryPath = RepositoryPath Text
|
||||||
deriving Show
|
deriving Show
|
||||||
|
@ -320,7 +319,7 @@ startFullAssistant path repogroup = do
|
||||||
u <- initRepo isnew True path Nothing
|
u <- initRepo isnew True path Nothing
|
||||||
inDir path $ setStandardGroup u repogroup
|
inDir path $ setStandardGroup u repogroup
|
||||||
addAutoStartFile path
|
addAutoStartFile path
|
||||||
changeWorkingDirectory path
|
setCurrentDirectory path
|
||||||
fromJust $ postFirstRun webapp
|
fromJust $ postFirstRun webapp
|
||||||
redirect $ T.pack url
|
redirect $ T.pack url
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,6 @@ import Init
|
||||||
import Config.Files
|
import Config.Files
|
||||||
|
|
||||||
import System.Environment
|
import System.Environment
|
||||||
import System.Posix.Directory
|
|
||||||
|
|
||||||
def :: [Command]
|
def :: [Command]
|
||||||
def = [noRepo checkAutoStart $ dontCheck repoExists $
|
def = [noRepo checkAutoStart $ dontCheck repoExists $
|
||||||
|
@ -64,5 +63,5 @@ autoStart = do
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
go program dir = do
|
go program dir = do
|
||||||
changeWorkingDirectory dir
|
setCurrentDirectory dir
|
||||||
boolSystem program [Param "assistant"]
|
boolSystem program [Param "assistant"]
|
||||||
|
|
|
@ -28,7 +28,6 @@ import qualified Annex
|
||||||
import Config.Files
|
import Config.Files
|
||||||
import qualified Option
|
import qualified Option
|
||||||
|
|
||||||
import System.Posix.Directory
|
|
||||||
import Control.Concurrent
|
import Control.Concurrent
|
||||||
import Control.Concurrent.STM
|
import Control.Concurrent.STM
|
||||||
import System.Process (env, std_out, std_err)
|
import System.Process (env, std_out, std_err)
|
||||||
|
@ -97,7 +96,7 @@ startNoRepo = do
|
||||||
case dirs of
|
case dirs of
|
||||||
[] -> firstRun listenhost
|
[] -> firstRun listenhost
|
||||||
(d:_) -> do
|
(d:_) -> do
|
||||||
changeWorkingDirectory d
|
setCurrentDirectory d
|
||||||
state <- Annex.new =<< Git.CurrentRepo.get
|
state <- Annex.new =<< Git.CurrentRepo.get
|
||||||
void $ Annex.eval state $ doCommand $
|
void $ Annex.eval state $ doCommand $
|
||||||
start' False listenhost
|
start' False listenhost
|
||||||
|
|
|
@ -9,10 +9,6 @@
|
||||||
|
|
||||||
module Git.CurrentRepo where
|
module Git.CurrentRepo where
|
||||||
|
|
||||||
#ifndef __WINDOWS__
|
|
||||||
import System.Posix.Directory (changeWorkingDirectory)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
import Common
|
import Common
|
||||||
import Git.Types
|
import Git.Types
|
||||||
import Git.Construct
|
import Git.Construct
|
||||||
|
@ -39,11 +35,9 @@ get = do
|
||||||
case wt of
|
case wt of
|
||||||
Nothing -> return r
|
Nothing -> return r
|
||||||
Just d -> do
|
Just d -> do
|
||||||
#ifndef __WINDOWS__
|
|
||||||
cwd <- getCurrentDirectory
|
cwd <- getCurrentDirectory
|
||||||
unless (d `dirContains` cwd) $
|
unless (d `dirContains` cwd) $
|
||||||
changeWorkingDirectory d
|
setCurrentDirectory d
|
||||||
#endif
|
|
||||||
return $ addworktree wt r
|
return $ addworktree wt r
|
||||||
where
|
where
|
||||||
pathenv s = do
|
pathenv s = do
|
||||||
|
|
9
Test.hs
9
Test.hs
|
@ -11,7 +11,6 @@ import Test.HUnit
|
||||||
import Test.QuickCheck
|
import Test.QuickCheck
|
||||||
import Test.QuickCheck.Test
|
import Test.QuickCheck.Test
|
||||||
|
|
||||||
import System.Posix.Directory (changeWorkingDirectory)
|
|
||||||
import System.Posix.Files
|
import System.Posix.Files
|
||||||
import Control.Exception.Extensible
|
import Control.Exception.Extensible
|
||||||
import qualified Data.Map as M
|
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"
|
git_annex "add" ["dir"] @? "add of subdir failed"
|
||||||
createDirectory "dir2"
|
createDirectory "dir2"
|
||||||
writeFile "dir2/foo" $ content annexedfile
|
writeFile "dir2/foo" $ content annexedfile
|
||||||
changeWorkingDirectory "dir"
|
setCurrentDirectory "dir"
|
||||||
git_annex "add" ["../dir2"] @? "add of ../subdir failed"
|
git_annex "add" ["../dir2"] @? "add of ../subdir failed"
|
||||||
|
|
||||||
test_reinject :: Test
|
test_reinject :: Test
|
||||||
|
@ -814,7 +813,7 @@ indir dir a = do
|
||||||
-- Assertion failures throw non-IO errors; catch
|
-- Assertion failures throw non-IO errors; catch
|
||||||
-- any type of error and change back to cwd before
|
-- any type of error and change back to cwd before
|
||||||
-- rethrowing.
|
-- rethrowing.
|
||||||
r <- bracket_ (changeToTmpDir dir) (changeWorkingDirectory cwd)
|
r <- bracket_ (changeToTmpDir dir) (setCurrentDirectory cwd)
|
||||||
(try (a)::IO (Either SomeException ()))
|
(try (a)::IO (Either SomeException ()))
|
||||||
case r of
|
case r of
|
||||||
Right () -> return ()
|
Right () -> return ()
|
||||||
|
@ -949,7 +948,7 @@ prepare = do
|
||||||
cwd <- getCurrentDirectory
|
cwd <- getCurrentDirectory
|
||||||
p <- Utility.Env.getEnvDefault "PATH" ""
|
p <- Utility.Env.getEnvDefault "PATH" ""
|
||||||
void $ Utility.Env.setEnv "PATH" (cwd ++ ":" ++ p) True
|
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
|
-- Avoid git complaining if it cannot determine the user's email
|
||||||
-- address, or exploding if it doesn't know the user's name.
|
-- address, or exploding if it doesn't know the user's name.
|
||||||
void $ Utility.Env.setEnv "GIT_AUTHOR_EMAIL" "test@example.com" True
|
void $ Utility.Env.setEnv "GIT_AUTHOR_EMAIL" "test@example.com" True
|
||||||
|
@ -961,7 +960,7 @@ changeToTmpDir :: FilePath -> IO ()
|
||||||
changeToTmpDir t = do
|
changeToTmpDir t = do
|
||||||
-- Hack alert. Threading state to here was too much bother.
|
-- Hack alert. Threading state to here was too much bother.
|
||||||
topdir <- Utility.Env.getEnvDefault "TOPDIR" ""
|
topdir <- Utility.Env.getEnvDefault "TOPDIR" ""
|
||||||
changeWorkingDirectory $ topdir ++ "/" ++ t
|
setCurrentDirectory $ topdir ++ "/" ++ t
|
||||||
|
|
||||||
tmpdir :: String
|
tmpdir :: String
|
||||||
tmpdir = ".t"
|
tmpdir = ".t"
|
||||||
|
|
Loading…
Reference in a new issue