proxy: Made it work when run in a new repository before initial commit.
This commit is contained in:
parent
7a68b1978d
commit
d5a25bd567
2 changed files with 11 additions and 7 deletions
|
@ -15,6 +15,7 @@ import Utility.Env
|
|||
import Annex.Direct
|
||||
import qualified Git.Sha
|
||||
import qualified Git.Ref
|
||||
import qualified Git.Branch
|
||||
|
||||
cmd :: [Command]
|
||||
cmd = [notBareRepo $
|
||||
|
@ -28,19 +29,20 @@ start :: [String] -> CommandStart
|
|||
start [] = error "Did not specify command to run."
|
||||
start (c:ps) = liftIO . exitWith =<< ifM isDirect
|
||||
( do
|
||||
g <- gitRepo
|
||||
withTmpDirIn (gitAnnexTmpMiscDir g) "proxy" go
|
||||
tmp <- gitAnnexTmpMiscDir <$> gitRepo
|
||||
withTmpDirIn tmp "proxy" go
|
||||
, liftIO $ safeSystem c (map Param ps)
|
||||
)
|
||||
where
|
||||
go tmp = do
|
||||
oldref <- fromMaybe Git.Sha.emptyTree
|
||||
<$> inRepo Git.Ref.headSha
|
||||
exitcode <- liftIO $ proxy tmp
|
||||
exitcode <- proxy tmp
|
||||
mergeDirectCleanup tmp oldref
|
||||
return exitcode
|
||||
proxy tmp = do
|
||||
usetmp <- Just . addEntry "GIT_WORK_TREE" tmp <$> getEnvironment
|
||||
unlessM (boolSystemEnv "git" [Param "checkout", Param "--", Param "."] usetmp) $
|
||||
error "Failed to set up proxy work tree."
|
||||
safeSystemEnv c (map Param ps) usetmp
|
||||
usetmp <- liftIO $ Just . addEntry "GIT_WORK_TREE" tmp <$> getEnvironment
|
||||
unlessM (isNothing <$> inRepo Git.Branch.current) $
|
||||
unlessM (liftIO $ boolSystemEnv "git" [Param "checkout", Param "--", Param "."] usetmp) $
|
||||
error "Failed to set up proxy work tree."
|
||||
liftIO $ safeSystemEnv c (map Param ps) usetmp
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue