git-remote-annex: Require git version 2.31 or newer

Since old ones had a buggy git bundle command.

In particular, git 2.30.2 has a git bundle that supports --stdin, but does
not read from it, and so fails to create a bundle.

While not using --stdin would perhaps work, it limits the number of revs
that get included in the bundle to the command line length limit.

But the real kicker is that at the same time --stdin got fixed, a bug also
got fixed that made git bundle skip including refs when they had the same
sha as other refs it included. Which would lead to data loss. So best to
avoid that buggy thing.
This commit is contained in:
Joey Hess 2024-11-20 15:00:17 -04:00
parent e6a4ab5224
commit 31a38f8468
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 27 additions and 15 deletions

View file

@ -12,10 +12,16 @@ module Git.Bundle where
import Common
import Git
import Git.Command
import qualified Git.Version
import Data.Char (ord)
import qualified Data.ByteString.Char8 as S8
-- Older versions of git had a git bundle command that sometimes omitted
-- refs, and that did not properly support --stdin.
versionSupported :: IO Bool
versionSupported = not <$> Git.Version.older "2.31"
listHeads :: FilePath -> Repo -> IO [(Sha, Ref)]
listHeads bundle repo = map gen . S8.lines <$>
pipeReadStrict [Param "bundle", Param "list-heads", File bundle] repo