From 8ac4cd6904ca80a6d115f3ce2ade66495a77a45f Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 22 Apr 2016 12:29:32 -0400 Subject: adjusted branches need git 2.2.0 or newer When git-annex is used with a git version older than 2.2.0, disable support for adjusted branches, since GIT_COMMON_DIR is needed to update them and was first added in that version of git. --- Annex/AdjustedBranch.hs | 16 ++++++++++++++++ Annex/GitOverlay.hs | 5 ++++- 2 files changed, 20 insertions(+), 1 deletion(-) (limited to 'Annex') diff --git a/Annex/AdjustedBranch.hs b/Annex/AdjustedBranch.hs index e9e6ab461..26a24d8e6 100644 --- a/Annex/AdjustedBranch.hs +++ b/Annex/AdjustedBranch.hs @@ -21,6 +21,8 @@ module Annex.AdjustedBranch ( updateAdjustedBranch, propigateAdjustedCommits, checkAdjustedClone, + isGitVersionSupported, + checkVersionSupported, ) where import Annex.Common @@ -39,6 +41,8 @@ import Git.Env import Git.Index import Git.FilePath import qualified Git.LockFile +import qualified Git.Version +import Annex.Version import Annex.CatFile import Annex.Link import Annex.AutoMerge @@ -507,3 +511,15 @@ checkAdjustedClone = go =<< inRepo Git.Branch.current setBasisBranch basis remotebranch unlessM (inRepo $ Git.Ref.exists origbranch) $ inRepo $ Git.Branch.update' origbranch remotebranch + +-- git 2.2.0 needed for GIT_COMMON_DIR which is needed +-- by updateAdjustedBranch to use withWorkTreeRelated. +isGitVersionSupported :: IO Bool +isGitVersionSupported = not <$> Git.Version.older "2.2.0" + +checkVersionSupported :: Annex () +checkVersionSupported = do + unlessM versionSupportsAdjustedBranch $ + error "Adjusted branches are only supported in v6 or newer repositories." + unlessM (liftIO isGitVersionSupported) $ + error "Your version of git is too old; upgrade it to 2.2.0 or newer to use adjusted branches." diff --git a/Annex/GitOverlay.hs b/Annex/GitOverlay.hs index 7e18d225b..e33d8a83c 100644 --- a/Annex/GitOverlay.hs +++ b/Annex/GitOverlay.hs @@ -40,7 +40,10 @@ withWorkTree d = withAltRepo - files that are related to the work tree coming from an overlay - directory other than the usual. This is done by pointing - GIT_COMMON_DIR at the regular git directory, and GIT_DIR at the - - overlay directory. -} + - overlay directory. + - + - Needs git 2.2.0 or newer. + -} withWorkTreeRelated :: FilePath -> Annex a -> Annex a withWorkTreeRelated d = withAltRepo modrepo unmodrepo where -- cgit v1.2.3