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.
This commit is contained in:
parent
c2862d9585
commit
0e31234e8e
3 changed files with 48 additions and 26 deletions
20
Annex.hs
20
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue