configure: Check if ssh connection caching is supported by the installed version of ssh and default annex.sshcaching accordingly.

This commit is contained in:
Joey Hess 2012-02-25 19:15:29 -04:00
parent c3fbe07d7a
commit 12b89a3eb8
8 changed files with 27 additions and 7 deletions

View file

@ -313,7 +313,8 @@ saveState :: Bool -> Annex ()
saveState oneshot = do
Annex.Queue.flush False
unless oneshot $ do
alwayscommit <- Git.configTrue <$> fromRepo (Git.Config.get "annex.alwayscommit" "true")
alwayscommit <- fromMaybe True . Git.configTrue
<$> fromRepo (Git.Config.get "annex.alwayscommit" "")
if alwayscommit
then Annex.Branch.commit "update"
else Annex.Branch.stage

View file

@ -16,6 +16,7 @@ import Common.Annex
import Annex.LockPool
import qualified Git
import qualified Git.Config
import qualified Build.SysConfig as SysConfig
{- Generates parameters to ssh to a given host (or user@host) on a given
- port, with connection caching. -}
@ -37,7 +38,8 @@ sshParams (host, port) opts = go =<< sshInfo (host, port)
sshInfo :: (String, Maybe Integer) -> Annex (Maybe FilePath, [CommandParam])
sshInfo (host, port) = do
caching <- Git.configTrue <$> fromRepo (Git.Config.get "annex.sshcaching" "true")
caching <- fromMaybe SysConfig.sshconnectioncaching . Git.configTrue
<$> fromRepo (Git.Config.get "annex.sshcaching" "")
if caching
then do
dir <- fromRepo gitAnnexSshDir

View file

@ -69,7 +69,7 @@ prop_cost_sane = False `notElem`
{- Checks if a repo should be ignored. -}
repoNotIgnored :: Git.Repo -> Annex Bool
repoNotIgnored r = not . Git.configTrue <$> getConfig r "ignore" "false"
repoNotIgnored r = not . fromMaybe False . Git.configTrue <$> getConfig r "ignore" ""
{- If a value is specified, it is used; otherwise the default is looked up
- in git config. forcenumcopies overrides everything. -}

12
Git.hs
View file

@ -85,7 +85,8 @@ assertLocal repo action =
else error $ "acting on non-local git repo " ++ repoDescribe repo ++
" not supported"
configBare :: Repo -> Bool
configBare repo = maybe unknown configTrue $ M.lookup "core.bare" $ config repo
configBare repo = maybe unknown (fromMaybe False . configTrue) $
M.lookup "core.bare" $ config repo
where
unknown = error $ "it is not known if git repo " ++
repoDescribe repo ++
@ -112,5 +113,10 @@ workTree Repo { location = Dir d } = d
workTree Repo { location = Unknown } = undefined
{- Checks if a string from git config is a true value. -}
configTrue :: String -> Bool
configTrue s = map toLower s == "true"
configTrue :: String -> Maybe Bool
configTrue s
| s' == "true" = Just True
| s' == "false" = Just False
| otherwise = Nothing
where
s' = map toLower s

View file

@ -4,9 +4,11 @@ import System.Directory
import Data.List
import Data.Maybe
import System.Cmd.Utils
import Control.Applicative
import Build.TestConfig
import Utility.StatFS
import Utility.SafeCommand
tests :: [TestCase]
tests =
@ -23,6 +25,7 @@ tests =
, TestCase "wget" $ testCmd "wget" "wget --version >/dev/null"
, TestCase "bup" $ testCmd "bup" "bup --version >/dev/null"
, TestCase "gpg" $ testCmd "gpg" "gpg --version >/dev/null"
, TestCase "ssh connection caching" getSshConnectionCaching
, TestCase "StatFS" testStatFS
] ++ shaTestCases [1, 256, 512, 224, 384]
@ -66,6 +69,10 @@ getGitVersion = do
let version = last $ words $ head $ lines s
return $ Config "gitversion" (StringConfig version)
getSshConnectionCaching :: Test
getSshConnectionCaching = Config "sshconnectioncaching" . BoolConfig <$>
boolSystem "sh" [Param "-c", Param "ssh -o ControlPersist=yes -V >/dev/null 2>/dev/null"]
testStatFS :: Test
testStatFS = do
s <- getFileSystemStats "."

2
debian/changelog vendored
View file

@ -34,6 +34,8 @@ git-annex (3.20120124) UNRELEASED; urgency=low
* To avoid commits of data to the git-annex branch after each command
is run, set annex.alwayscommit=false. Its data will then be committed
less frequently, when a merge or sync is done.
* configure: Check if ssh connection caching is supported by the installed
version of ssh and default annex.sshcaching accordingly.
-- Joey Hess <joeyh@debian.org> Tue, 24 Jan 2012 16:21:55 -0400

1
debian/control vendored
View file

@ -23,6 +23,7 @@ Build-Depends:
git,
uuid,
rsync,
openssh-client,
Maintainer: Joey Hess <joeyh@debian.org>
Standards-Version: 3.9.2
Vcs-Git: git://git.kitenet.net/git-annex

View file

@ -604,7 +604,8 @@ Here are all the supported configuration settings.
* `annex.sshcaching`
By default, git-annex caches ssh connections. To disable this, set to `false`.
By default, git-annex caches ssh connections
(if built using a new enough ssh). To disable this, set to `false`.
* `annex.alwayscommit`