run git status before enabling clean filter
Avoids annex.largefiles inconsitency and also avoids a lot of unneccessary calls to the clean filter when a large repo's clone is being initialized. This commit was supported by the NSF-funded DataLad project.
This commit is contained in:
parent
82b28a8487
commit
401a79675b
6 changed files with 65 additions and 18 deletions
41
Config/Smudge.hs
Normal file
41
Config/Smudge.hs
Normal file
|
@ -0,0 +1,41 @@
|
|||
{- Git smudge filter configuration
|
||||
-
|
||||
- Copyright 2011-2018 Joey Hess <id@joeyh.name>
|
||||
-
|
||||
- Licensed under the GNU GPL version 3 or higher.
|
||||
-}
|
||||
|
||||
module Config.Smudge where
|
||||
|
||||
import Annex.Common
|
||||
import qualified Annex
|
||||
import qualified Git
|
||||
import qualified Git.Command
|
||||
import Config
|
||||
|
||||
configureSmudgeFilter :: Annex ()
|
||||
configureSmudgeFilter = do
|
||||
-- If this is run in a newly cloned repository, git may not have
|
||||
-- cached file information in the index yet, and so after
|
||||
-- configuring the clean filter, the next git status would want to
|
||||
-- run it on every file. That is expensive and can also result in
|
||||
-- unexpected changes when the file is checked into git or annex
|
||||
-- counter to the annex.largefiles configuration.
|
||||
-- Avoid that problem by running git status now.
|
||||
inRepo $ Git.Command.runQuiet [Param "status", Param "--porcelain"]
|
||||
|
||||
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 "" . readFileStrict
|
||||
stdattr = unlines
|
||||
[ "* filter=annex"
|
||||
, ".* !filter"
|
||||
]
|
Loading…
Add table
Add a link
Reference in a new issue