summaryrefslogtreecommitdiff
path: root/Annex.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-11-05 14:24:28 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-11-05 14:24:28 -0400
commit83c6fbde28cb25f377bd37d0eedde52c87874052 (patch)
tree5227c2e22bcf95dd6ca97833772ae1e8df042930 /Annex.hs
parente96c613c026c2d0bd6cce7210b058533d3ce972c (diff)
support direct mode repositories with core.bare=true (not yet default)
Direct mode repositories can now have core.bare=true set, to prevent accidentally running git commands that try to operate on the work tree, and so do the wrong thing. This is not yet the default, and it causes known problems for git-annex sync due to receive.denyCurrentBranch not working in bare repositories. This commit was sponsored by Richard Hartmann.
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