From 2686d2d7ea44d9b5d8243da6fc9f2df1d2441a71 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 21 Aug 2025 11:04:26 -0400 Subject: [PATCH] Removed support for git versions older than 2.5. This entirely removes Git.BuildVersion, which avoids the possibility that git-annex will behave differently based on the version of git it was built with, rather than the version it's used with. Debian oldoldstable is the oldest version of git that git-annex needs to support, since it's used in the amd64ancient build. cabal configure will fail if the git version is too old. Sponsored-by: Nicholas Golder-Manning --- Build/Configure.hs | 2 +- CHANGELOG | 1 + Command/Smudge.hs | 11 +---------- Git/BuildVersion.hs | 21 --------------------- Git/CatFile.hs | 13 ++++--------- git-annex.cabal | 1 - 6 files changed, 7 insertions(+), 42 deletions(-) delete mode 100644 Git/BuildVersion.hs diff --git a/Build/Configure.hs b/Build/Configure.hs index 2c848ce965..c8bebaaba6 100644 --- a/Build/Configure.hs +++ b/Build/Configure.hs @@ -81,7 +81,7 @@ getGitVersion = go =<< getEnv "FORCE_GIT_VERSION" go (Just s) = return $ Config "gitversion" $ StringConfig s go Nothing = do v <- Git.Version.installed - let oldestallowed = Git.Version.normalize "2.1" + let oldestallowed = Git.Version.normalize "2.5" when (v < oldestallowed) $ error $ "installed git version " ++ show v ++ " is too old! (Need " ++ show oldestallowed ++ " or newer)" return $ Config "gitversion" $ StringConfig $ show v diff --git a/CHANGELOG b/CHANGELOG index b7ce9fc91f..7717641e64 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -26,6 +26,7 @@ git-annex (10.20250722) UNRELEASED; urgency=medium for exporttree=yes/importtree=yes remotes. * Bump aws build dependency to 0.24.1. * stack.yaml: Update to lts-24.2. + * Removed support for git versions older than 2.5. -- Joey Hess Wed, 30 Jul 2025 13:45:42 -0400 diff --git a/Command/Smudge.hs b/Command/Smudge.hs index dc3854a661..c381c0aa5a 100644 --- a/Command/Smudge.hs +++ b/Command/Smudge.hs @@ -19,7 +19,6 @@ import Annex.WorkTree import Logs.Smudge import Logs.Location import qualified Database.Keys -import qualified Git.BuildVersion import Git.FilePath import Git.Types import Git.HashObject @@ -97,15 +96,7 @@ clean file = do Annex.BranchState.disableUpdate -- optimisation b <- liftIO $ L.hGetContents stdin let passthrough = liftIO $ L.hPut stdout b - -- Before git 2.5, failing to consume all stdin here would - -- cause a SIGPIPE and crash it. - -- Newer git catches the signal and stops sending, which is - -- much faster. (Also, git seems to forget to free memory - -- when sending the file, so the less we let it send, the - -- less memory it will waste.) - let discardreststdin = if Git.BuildVersion.older "2.5" - then L.length b `seq` return () - else liftIO $ hClose stdin + let discardreststdin = liftIO $ hClose stdin let emitpointer = liftIO . S.hPut stdout . formatPointer clean' file (parseLinkTargetOrPointerLazy' b) passthrough diff --git a/Git/BuildVersion.hs b/Git/BuildVersion.hs deleted file mode 100644 index f94a892015..0000000000 --- a/Git/BuildVersion.hs +++ /dev/null @@ -1,21 +0,0 @@ -{- git build version - - - - Copyright 2011 Joey Hess - - - - Licensed under the GNU AGPL version 3 or higher. - -} - -module Git.BuildVersion where - -import Git.Version -import qualified BuildInfo - -{- Using the version it was configured for avoids running git to check its - - version, at the cost that upgrading git won't be noticed. - - This is only acceptable because it's rare that git's version influences - - code's behavior. -} -buildVersion :: GitVersion -buildVersion = normalize BuildInfo.gitversion - -older :: String -> Bool -older n = buildVersion < normalize n diff --git a/Git/CatFile.hs b/Git/CatFile.hs index 877186a1ae..a0ab796183 100644 --- a/Git/CatFile.hs +++ b/Git/CatFile.hs @@ -54,7 +54,6 @@ import Git.Types import Git.HashObject import qualified Git.LsTree as LsTree import qualified Utility.CoProcess as CoProcess -import qualified Git.BuildVersion as BuildVersion import Utility.Tuple data CatFileHandle = CatFileHandle @@ -403,14 +402,10 @@ withCatFileStream withCatFileStream check repo reader = assertLocal repo $ bracketIO start stop $ \(c, hin, hout, _) -> reader c hin hout where - params = catMaybes - [ Just $ Param "cat-file" - , Just $ Param ("--batch" ++ (if check then "-check" else "") ++ "=" ++ batchFormat) - -- This option makes it faster, but is not present in - -- older versions of git. - , if BuildVersion.older "2.4.3" - then Nothing - else Just $ Param "--buffer" + params = + [ Param "cat-file" + , Param ("--batch" ++ (if check then "-check" else "") ++ "=" ++ batchFormat) + , Param "--buffer" -- makes it faster ] start = do diff --git a/git-annex.cabal b/git-annex.cabal index bd678f1a5c..4fbf9f0f7f 100644 --- a/git-annex.cabal +++ b/git-annex.cabal @@ -813,7 +813,6 @@ Executable git-annex Git Git.AutoCorrect Git.Branch - Git.BuildVersion Git.Bundle Git.CatFile Git.CheckAttr