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

@ -21,6 +21,8 @@ git-annex (10.20241032) UNRELEASED; urgency=medium
uses the same hostname as remote.name.url, which is itself a http(s)
url, they are assumed to share a username and password. This avoids
unnecessary duplicate password prompts.
* git-remote-annex: Require git version 2.31 or newer, since old
ones had a buggy git bundle command.
-- Joey Hess <id@joeyh.name> Mon, 11 Nov 2024 12:26:00 -0400

View file

@ -70,6 +70,8 @@ import qualified Data.Set as S
run :: [String] -> IO ()
run (remotename:url:[]) = do
unlessM Git.Bundle.versionSupported $
giveup "git-remote-annex needs a newer version of git"
repo <- getRepo
state <- Annex.new repo
Annex.eval state $

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

32
Test.hs
View file

@ -37,6 +37,7 @@ import qualified Git.Types
import qualified Git.Ref
import qualified Git.LsTree
import qualified Git.FilePath
import qualified Git.Bundle
import qualified Annex.Locations
#ifndef mingw32_HOST_OS
import qualified Types.GitConfig
@ -427,29 +428,30 @@ test_git_remote_annex :: Bool -> Assertion
test_git_remote_annex exporttree
#ifndef mingw32_HOST_OS
| exporttree =
testspecialremote ["importtree=yes", "exporttree=yes"] $
runtest ["importtree=yes", "exporttree=yes"] $
git_annex "export" ["master", "--to=foo"] "export"
| otherwise =
testspecialremote [] $
runtest [] $
git_annex "copy" ["--to=foo"] "copy"
#else
-- git-remote-annex is not currently installed on Windows
return ()
#endif
where
testspecialremote cfg populate = intmpclonerepo $ do
let cfg' = ["type=directory", "encryption=none", "directory=dir"] ++ cfg
createDirectory "dir"
git_annex "initremote" ("foo":("uuid=" ++ diruuid):cfg') "initremote"
git_annex "get" [] "get failed"
() <- populate
git "config" ["remote.foo.url", "annex::"] "git config"
git "push" ["foo", "master"] "git push"
git "push" ["foo", "git-annex"] "git push"
git "clone" ["annex::"++diruuid++"?"++intercalate "&" cfg', "clonedir"]
"git clone from special remote"
inpath "clonedir" $
git_annex "get" [annexedfile] "get from origin special remote"
runtest cfg populate = whenM Git.Bundle.versionSupported $
intmpclonerepo $ do
let cfg' = ["type=directory", "encryption=none", "directory=dir"] ++ cfg
createDirectory "dir"
git_annex "initremote" ("foo":("uuid=" ++ diruuid):cfg') "initremote"
git_annex "get" [] "get failed"
() <- populate
git "config" ["remote.foo.url", "annex::"] "git config"
git "push" ["foo", "master"] "git push"
git "push" ["foo", "git-annex"] "git push"
git "clone" ["annex::"++diruuid++"?"++intercalate "&" cfg', "clonedir"]
"git clone from special remote"
inpath "clonedir" $
git_annex "get" [annexedfile] "get from origin special remote"
diruuid="89ddefa4-a04c-11ef-87b5-e880882a4f98"
test_add_moved :: Assertion