summaryrefslogtreecommitdiff
path: root/Annex.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Annex.hs')
-rw-r--r--Annex.hs20
1 files changed, 16 insertions, 4 deletions
diff --git a/Annex.hs b/Annex.hs
index ae56ec5ad..1fde4cd42 100644
--- a/Annex.hs
+++ b/Annex.hs
@@ -12,7 +12,6 @@ module Annex (
AnnexState(..),
PreferredContentMap,
new,
- newState,
run,
eval,
getState,
@@ -41,6 +40,7 @@ import Control.Concurrent
import Common
import qualified Git
import qualified Git.Config
+import Git.Types hiding (remotes)
import Git.CatFile
import Git.CheckAttr
import Git.CheckIgnore
@@ -112,9 +112,9 @@ data AnnexState = AnnexState
}
newState :: Git.Repo -> AnnexState
-newState gitrepo = AnnexState
- { repo = gitrepo
- , gitconfig = extractGitConfig gitrepo
+newState r = AnnexState
+ { repo = if annexDirect c then fixupDirect r else r
+ , gitconfig = c
, backends = []
, remotes = []
, output = defaultMessageState
@@ -144,6 +144,8 @@ newState gitrepo = AnnexState
, inodeschanged = Nothing
, useragent = Nothing
}
+ where
+ c = extractGitConfig r
{- Makes an Annex state object for the specified git repo.
- Ensures the config is read, if it was not already. -}
@@ -247,3 +249,13 @@ withCurrentState :: Annex a -> Annex (IO a)
withCurrentState a = do
s <- getState id
return $ eval s a
+
+{- Direct mode repos have core.bare=true, but are not really bare.
+ - Fix up the Repo to be a non-bare repo, and arrange for git commands
+ - run by git-annex to be passed parameters that override this setting. -}
+fixupDirect :: Git.Repo -> Git.Repo
+fixupDirect r@(Repo { location = Local { gitdir = d, worktree = Nothing } }) = r
+ { location = Local { gitdir = d </> ".git", worktree = Just d }
+ , gitGlobalOpts = gitGlobalOpts r ++ [Param "-c", Param "core.bare=false"]
+ }
+fixupDirect r = r