init: Configure .git/info/attributes to use git-annex as a smudge filter.

Note that this changes the default behavior of git add in a newly
initialized repository; it will add files to the annex.

Don't like that this could break workflows, but it's necessary in order for
any pointer files in the repo to be handled by git-annex.
This commit is contained in:
Joey Hess 2015-12-04 17:57:15 -04:00
parent fb6ebdaae7
commit 2fe21d47c5
Failed to extract signature
6 changed files with 60 additions and 21 deletions

View file

@ -95,3 +95,16 @@ configureSmudgeFilter :: Annex ()
configureSmudgeFilter = do
setConfig (ConfigKey "filter.annex.smudge") "git-annex smudge %f"
setConfig (ConfigKey "filter.annex.clean") "git-annex smudge --clean %f"
lf <- Annex.fromRepo Git.attributesLocal
gf <- Annex.fromRepo Git.attributes
lfs <- readattr lf
gfs <- readattr gf
liftIO $ unless ("filter=annex" `isInfixOf` (lfs ++ gfs)) $ do
createDirectoryIfMissing True (takeDirectory lf)
writeFile lf (lfs ++ "\n" ++ stdattr)
where
readattr = liftIO . catchDefaultIO "" . readFileStrictAnyEncoding
stdattr = unlines
[ "* filter=annex"
, ".* !filter"
]