From 53da7f1cf823efe7e445e894b1cf607096482362 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 8 Oct 2019 14:34:00 -0400 Subject: [PATCH] update uninit to handle all the v7 stuff * uninit: Remove several git hooks that git-annex init sets up. * uninit: Remove the smudge and clean filters that git-annex init sets up. --- Annex/Hook.hs | 18 ++++++++++--- Annex/Init.hs | 4 +-- CHANGELOG | 2 ++ Config/Smudge.hs | 27 ++++++++++++++----- ...uninit_breaks_the_underlying_git_repo.mdwn | 2 ++ 5 files changed, 41 insertions(+), 12 deletions(-) diff --git a/Annex/Hook.hs b/Annex/Hook.hs index b56b3bf6cc..69dca860b2 100644 --- a/Annex/Hook.hs +++ b/Annex/Hook.hs @@ -1,10 +1,10 @@ {- git-annex git hooks - - - Note that it's important that the scripts installed by git-annex - - not change, otherwise removing old hooks using an old version of - - the script would fail. + - Note that it's important that the content of scripts installed by + - git-annex not change, otherwise removing old hooks using an old + - version of the script would fail. - - - Copyright 2013-2018 Joey Hess + - Copyright 2013-2019 Joey Hess - - Licensed under the GNU AGPL version 3 or higher. -} @@ -18,6 +18,16 @@ import Utility.Shell import qualified Data.Map as M +-- Remove all hooks. +unHook :: Annex () +unHook = do + hookUnWrite preCommitHook + hookUnWrite postReceiveHook + hookUnWrite postCheckoutHook + hookUnWrite postMergeHook + hookUnWrite preCommitAnnexHook + hookUnWrite postUpdateAnnexHook + preCommitHook :: Git.Hook preCommitHook = Git.Hook "pre-commit" (mkHookScript "git annex pre-commit .") [] diff --git a/Annex/Init.hs b/Annex/Init.hs index bcfe017757..e590620cb5 100644 --- a/Annex/Init.hs +++ b/Annex/Init.hs @@ -128,8 +128,8 @@ initialize' mversion = checkCanInitialize $ do uninitialize :: Annex () uninitialize = do - hookUnWrite preCommitHook - hookUnWrite postReceiveHook + unHook + deconfigureSmudgeFilter removeRepoUUID removeVersion diff --git a/CHANGELOG b/CHANGELOG index 71762eb076..3475fb903b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -21,6 +21,8 @@ git-annex (7.20190913) UNRELEASED; urgency=medium Thanks to Peter Simons for help with analysis of this bug. * When dropping an unlocked file, preserve its mtime, which avoids git status unncessarily running the clean filter on the file. + * uninit: Remove several git hooks that git-annex init sets up. + * uninit: Remove the smudge and clean filters that git-annex init sets up. -- Joey Hess Thu, 19 Sep 2019 11:11:19 -0400 diff --git a/Config/Smudge.hs b/Config/Smudge.hs index f1d7bc4916..b81db28139 100644 --- a/Config/Smudge.hs +++ b/Config/Smudge.hs @@ -1,6 +1,6 @@ {- Git smudge filter configuration - - - Copyright 2011-2018 Joey Hess + - Copyright 2011-2019 Joey Hess - - Licensed under the GNU AGPL version 3 or higher. -} @@ -32,10 +32,25 @@ configureSmudgeFilter = unlessM (fromRepo Git.repoIsLocalBare) $ do gfs <- readattr gf liftIO $ unless ("filter=annex" `isInfixOf` (lfs ++ gfs)) $ do createDirectoryIfMissing True (takeDirectory lf) - writeFile lf (lfs ++ "\n" ++ stdattr) + writeFile lf (lfs ++ "\n" ++ unlines stdattr) where readattr = liftIO . catchDefaultIO "" . readFileStrict - stdattr = unlines - [ "* filter=annex" - , ".* !filter" - ] + +stdattr :: [String] +stdattr = + [ "* filter=annex" + , ".* !filter" + ] + +-- Note that this removes the local git attributes for filtering, +-- which is what git-annex installed, but it does not change anything +-- that may have been committed to a .gitattributes in the repository. +-- git-annex does not commit that. +deconfigureSmudgeFilter :: Annex () +deconfigureSmudgeFilter = do + lf <- Annex.fromRepo Git.attributesLocal + ls <- liftIO $ catchDefaultIO [] $ lines <$> readFileStrict lf + liftIO $ writeFile lf $ unlines $ + filter (\l -> l `notElem` stdattr && not (null l)) ls + unsetConfig (ConfigKey "filter.annex.smudge") + unsetConfig (ConfigKey "filter.annex.clean") diff --git a/doc/bugs/git_annex_uninit_breaks_the_underlying_git_repo.mdwn b/doc/bugs/git_annex_uninit_breaks_the_underlying_git_repo.mdwn index fb11a94885..db9d855dc8 100644 --- a/doc/bugs/git_annex_uninit_breaks_the_underlying_git_repo.mdwn +++ b/doc/bugs/git_annex_uninit_breaks_the_underlying_git_repo.mdwn @@ -47,3 +47,5 @@ I accidentally discovered this after a system upgrade that included the latest v ### Have you had any luck using git-annex before? (Sometimes we get tired of reading bug reports all day and a lil' positive end note does wonders) I love git-annex (a brilliantly designed piece of software in my view) and have been using it a lot for years! + +> Thanks for pointing out this oversight. [[fixed|done]] --[[Joey]]