summaryrefslogtreecommitdiff
path: root/Config.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-12-04 17:57:15 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-12-04 17:57:15 -0400
commitcf9af38cf75618e2953c5b537d8f7c1fe353aa63 (patch)
treeb5945e5f46eab01366ab3ddbe96662f9b8d96aa3 /Config.hs
parent93eaf6d6d018fe9df5b985e47300f549e4b04709 (diff)
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.
Diffstat (limited to 'Config.hs')
-rw-r--r--Config.hs13
1 files changed, 13 insertions, 0 deletions
diff --git a/Config.hs b/Config.hs
index bddb8abe3..f3833b17e 100644
--- a/Config.hs
+++ b/Config.hs
@@ -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"
+ ]