From da9eea5dc0e86b4abb14064346eddc5689d94333 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 5 Nov 2013 15:31:37 -0400 Subject: automatically set and unset core.bare when switching to/from direct mode --- Annex.hs | 13 +++++++++---- Config.hs | 5 ++++- Git/Config.hs | 5 ++++- debian/changelog | 2 +- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/Annex.hs b/Annex.hs index 1fde4cd42..b634041db 100644 --- a/Annex.hs +++ b/Annex.hs @@ -45,6 +45,7 @@ import Git.CatFile import Git.CheckAttr import Git.CheckIgnore import Git.SharedRepository +import Git.Config import qualified Git.Queue import Types.Backend import Types.GitConfig @@ -254,8 +255,12 @@ withCurrentState a = do - 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@(Repo { location = Local { gitdir = d, worktree = Nothing } }) = + r + { location = Local { gitdir = d ".git", worktree = Just d } + , gitGlobalOpts = gitGlobalOpts r ++ + [ Param "-c" + , Param $ coreBare ++ "=" ++ boolConfig False + ] + } fixupDirect r = r diff --git a/Config.hs b/Config.hs index ac251983a..475cb83ec 100644 --- a/Config.hs +++ b/Config.hs @@ -73,8 +73,11 @@ isDirect = annexDirect <$> Annex.getGitConfig setDirect :: Bool -> Annex () setDirect b = do - setConfig (annexConfig "direct") (Git.Config.boolConfig b) + setConfig (annexConfig "direct") val + setConfig (ConfigKey Git.Config.coreBare) val Annex.changeGitConfig $ \c -> c { annexDirect = b } + where + val = Git.Config.boolConfig b crippledFileSystem :: Annex Bool crippledFileSystem = annexCrippledFileSystem <$> Annex.getGitConfig diff --git a/Git/Config.hs b/Git/Config.hs index a41712add..1919ecedf 100644 --- a/Git/Config.hs +++ b/Git/Config.hs @@ -153,7 +153,10 @@ boolConfig True = "true" boolConfig False = "false" isBare :: Repo -> Bool -isBare r = fromMaybe False $ isTrue =<< getMaybe "core.bare" r +isBare r = fromMaybe False $ isTrue =<< getMaybe coreBare r + +coreBare :: String +coreBare = "core.bare" {- Runs a command to get the configuration of a repo, - and returns a repo populated with the configuration, as well as the raw diff --git a/debian/changelog b/debian/changelog index aba80a344..3237e2bbf 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,6 @@ git-annex (4.20131102) UNRELEASED; urgency=low - * Direct mode repositories can now have core.bare=true set, to prevent + * Direct mode repositories 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. * The -c option now not only modifies the git configuration seen by -- cgit v1.2.3