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
This commit is contained in:
Joey Hess 2025-08-21 11:04:26 -04:00
commit 2686d2d7ea
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
6 changed files with 7 additions and 42 deletions

View file

@ -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

View file

@ -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 <id@joeyh.name> Wed, 30 Jul 2025 13:45:42 -0400

View file

@ -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

View file

@ -1,21 +0,0 @@
{- git build version
-
- Copyright 2011 Joey Hess <id@joeyh.name>
-
- 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

View file

@ -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

View file

@ -813,7 +813,6 @@ Executable git-annex
Git
Git.AutoCorrect
Git.Branch
Git.BuildVersion
Git.Bundle
Git.CatFile
Git.CheckAttr