Install new git hooks in this version.

This does beg the question of what to do if git later gets eg a
post-smudge hook, that could run git-annex smudge --update. I think the
thing to do in that case would be to make git-annex smudge --update
install the new hooks. That way, as the user uses git-annex, the hook
would be created pretty quickly and without needing any extra syscalls
except for when git-annex smudge --update is called.

I considered doing something like that for installation of the
post-checkout and post-merge hooks, which would have avoided the need
for v7. But the only place it was cheap to do it would be in git-annex smudge
which could cheaply notice that smudge.log didn't exist yet and so know
the hooks needed to be installed. But since smudge used to populate pointer
files, it would be quite surprising if a single git checkout/merge failed
to update the work tree, and so that idea didn't work out.

The other reason for v7 is psychological -- users don't need to worry
about whether they might be running an old version of git-annex that
doesn't support their v7 repository very well. And bug reports about
"v6" have gotten a bit of a bad association in my head since they often
hit one of the known limitations and didn't realize it was experimental.

newtyped RepoVersion Int to avoid needing 2 comparisons in
versionSupportsUnlockedPointers etc. Also it's just nicer.

This commit was sponsored by John Pellman on Patreon.
This commit is contained in:
Joey Hess 2018-10-25 17:23:53 -04:00
parent 6ceeb4bae7
commit 234842a347
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
18 changed files with 160 additions and 108 deletions

View file

@ -17,6 +17,7 @@ import Types.Test
import qualified Annex
import qualified Annex.UUID
import qualified Annex.Version
import qualified Types.RepoVersion
import qualified Backend
import qualified Git.CurrentRepo
import qualified Git.Construct
@ -198,7 +199,7 @@ clonerepo old new cfg = do
ver <- annexVersion <$> getTestMode
if ver == Annex.Version.defaultVersion
then git_annex "init" ["-q", new] @? "git annex init failed"
else git_annex "init" ["-q", new, "--version", ver] @? "git annex init failed"
else git_annex "init" ["-q", new, "--version", show (Types.RepoVersion.fromRepoVersion ver)] @? "git annex init failed"
unless (bareClone cfg) $
indir new $
setupTestMode
@ -387,11 +388,11 @@ add_annex f = ifM (unlockedFiles <$> getTestMode)
data TestMode = TestMode
{ forceDirect :: Bool
, unlockedFiles :: Bool
, annexVersion :: Annex.Version.Version
, annexVersion :: Types.RepoVersion.RepoVersion
, keepFailures :: Bool
} deriving (Read, Show)
testMode :: TestOptions -> Annex.Version.Version -> TestMode
testMode :: TestOptions -> Types.RepoVersion.RepoVersion -> TestMode
testMode opts v = TestMode
{ forceDirect = False
, unlockedFiles = False