work around git "defense in depth" breakage with git clone checking for hooks
This git bug also broke git-lfs, and I am confident it will be reverted in the next release. For now, cloning from an annex:: url wastes some bandwidth on the next pull by not caching bundles locally. If git doesn't fix this in the next version, I'd be tempted to rethink whether bundle objects need to be cached locally. It would be possible to instead remember which bundles have been seen and their heads, and respond to the list command with the heads, and avoid unbundling them agian in fetch. This might even be a useful performance improvement in the latter case. It would be quite a complication to a currently simple implementation though.
This commit is contained in:
parent
6ccd09298b
commit
04a256a0f8
3 changed files with 21 additions and 9 deletions
|
@ -20,6 +20,7 @@ import qualified Git.Branch
|
|||
import qualified Git.Bundle
|
||||
import qualified Git.Remote
|
||||
import qualified Git.Remote.Remove
|
||||
import qualified Git.Version
|
||||
import qualified Annex.SpecialRemote as SpecialRemote
|
||||
import qualified Annex.Branch
|
||||
import qualified Annex.BranchState
|
||||
|
@ -1010,6 +1011,12 @@ specialRemoteFromUrl sab a = withTmpDir "journal" $ \tmpdir -> do
|
|||
-- When there is now a sibling git-annex branch, this handles
|
||||
-- initialization. When the initialized git-annex branch has Differences,
|
||||
-- the git bundle objects are in the wrong place, so have to be deleted.
|
||||
--
|
||||
-- Unfortunately, git 2.45.1 and related releases added a
|
||||
-- "defense in depth" check that a freshly cloned repository
|
||||
-- does not contain any hooks. Since initialization installs
|
||||
-- hooks, have to work around that by not initializing, and
|
||||
-- delete the git bundle objects.
|
||||
cleanupInitialization :: StartAnnexBranch -> Annex ()
|
||||
cleanupInitialization sab = do
|
||||
case sab of
|
||||
|
@ -1019,7 +1026,7 @@ cleanupInitialization sab = do
|
|||
inRepo $ Git.Branch.delete Annex.Branch.fullname
|
||||
indexfile <- fromRepo gitAnnexIndex
|
||||
liftIO $ removeWhenExistsWith R.removeLink indexfile
|
||||
ifM Annex.Branch.hasSibling
|
||||
ifM (Annex.Branch.hasSibling <&&> nonbuggygitversion)
|
||||
( do
|
||||
autoInitialize' (pure True) remoteList
|
||||
differences <- allDifferences <$> recordedDifferences
|
||||
|
@ -1035,3 +1042,15 @@ cleanupInitialization sab = do
|
|||
GitBundleKey -> lockContentForRemoval k noop removeAnnex
|
||||
_ -> noop
|
||||
void $ liftIO $ tryIO $ removeDirectory (decodeBS annexobjectdir)
|
||||
|
||||
nonbuggygitversion = liftIO $
|
||||
flip notElem buggygitversions <$> Git.Version.installed
|
||||
buggygitversions = map Git.Version.normalize
|
||||
[ "2.45.1"
|
||||
, "2.44.1"
|
||||
, "2.43.4"
|
||||
, "2.42.2"
|
||||
, "2.41.1"
|
||||
, "2.40.2"
|
||||
, "2.39.4"
|
||||
]
|
||||
|
|
|
@ -29,4 +29,4 @@ installed = normalize . extract <$> readProcess "git" ["--version"]
|
|||
older :: String -> IO Bool
|
||||
older n = do
|
||||
v <- installed
|
||||
return $ v < normalize n
|
||||
return $ v < normalize n
|
||||
|
|
|
@ -40,10 +40,3 @@ If git-annex wanted to also avoid this breakage, it could set:
|
|||
git config fsck.symlinkTargetLength ignore
|
||||
git config receive.fsck.symlinkTargetLength ignore
|
||||
git config fetch.fsck.symlinkTargetLength ignore
|
||||
|
||||
----
|
||||
|
||||
Also this version of git added checks for hooks created at clone
|
||||
time, which breaks git clone using git-remote-annex when the special
|
||||
remote contains a git-annex branch. This is similar to how it broke git-lfs
|
||||
and I'm sure this part of the breakage will be reverted.
|
||||
|
|
Loading…
Add table
Reference in a new issue