summaryrefslogtreecommitdiff
path: root/Command
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-03-16 11:53:46 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-03-16 11:53:46 -0400
commit5eb76d2b033436973e0732215fa9d0227a2187bf (patch)
tree8df6807f474224d3635229f460ef7ec43fde98c6 /Command
parent744638197f51811fca13a37c7bbc51dfb626793b (diff)
improve upgrade
Diffstat (limited to 'Command')
-rw-r--r--Command/Init.hs17
-rw-r--r--Command/Uninit.hs2
2 files changed, 12 insertions, 7 deletions
diff --git a/Command/Init.hs b/Command/Init.hs
index 661835169..d9ea394a3 100644
--- a/Command/Init.hs
+++ b/Command/Init.hs
@@ -8,7 +8,7 @@
module Command.Init where
import Control.Monad.State (liftIO)
-import Control.Monad (when)
+import Control.Monad (when, unless)
import System.Directory
import System.FilePath
@@ -74,12 +74,14 @@ gitAttributesWrite repo = do
exists <- doesFileExist attributes
if not exists
then do
- safeWriteFile attributes $ attrLine ++ "\n"
+ safeWriteFile attributes $ unlines attrLines
commit
else do
content <- readFile attributes
- when (all (/= attrLine) (lines content)) $ do
- appendFile attributes $ attrLine ++ "\n"
+ let present = lines content
+ let missing = filter (\l -> not $ l `elem` present) attrLines
+ unless (null missing) $ do
+ appendFile attributes $ unlines missing
commit
where
attributes = Git.attributes repo
@@ -91,8 +93,11 @@ gitAttributesWrite repo = do
, Param attributes
]
-attrLine :: String
-attrLine = stateDir </> "*.log merge=union"
+attrLines :: [String]
+attrLines =
+ [ stateDir </> "*.log merge=union"
+ , stateDir </> "*/*/*.log merge=union"
+ ]
{- set up a git pre-commit hook, if one is not already present -}
gitPreCommitHookWrite :: Git.Repo -> Annex ()
diff --git a/Command/Uninit.hs b/Command/Uninit.hs
index e9406ce3a..e8ac1bbd5 100644
--- a/Command/Uninit.hs
+++ b/Command/Uninit.hs
@@ -60,4 +60,4 @@ gitAttributesUnWrite repo = do
when attrexists $ do
c <- readFileStrict attributes
safeWriteFile attributes $ unlines $
- filter (/= Command.Init.attrLine) $ lines c
+ filter (\l -> not $ l `elem` Command.Init.attrLines) $ lines c