aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Annex.hs11
-rw-r--r--BackendTypes.hs2
-rw-r--r--Commands.hs3
-rw-r--r--Core.hs9
4 files changed, 16 insertions, 9 deletions
diff --git a/Annex.hs b/Annex.hs
index 9e76b9b04..08607cafa 100644
--- a/Annex.hs
+++ b/Annex.hs
@@ -8,7 +8,7 @@ module Annex (
backends,
backendsChange,
flagIsSet,
- flagsChange,
+ flagChange,
Flag(..)
) where
@@ -60,8 +60,11 @@ flagIsSet :: Flag -> Annex Bool
flagIsSet flag = do
state <- get
return $ elem flag $ Backend.flags state
-flagsChange :: [Flag] -> Annex ()
-flagsChange b = do
+flagChange :: Flag -> Bool -> Annex ()
+flagChange flag set = do
state <- get
- put state { Backend.flags = b }
+ let f = filter (/= flag) $ Backend.flags state
+ if (set)
+ then put state { Backend.flags = (flag:f) }
+ else put state { Backend.flags = f }
return ()
diff --git a/BackendTypes.hs b/BackendTypes.hs
index 1b67ef584..13ffde7f8 100644
--- a/BackendTypes.hs
+++ b/BackendTypes.hs
@@ -10,7 +10,7 @@ import Data.String.Utils
import qualified GitRepo as Git
-- command-line flags
-data Flag = Force
+data Flag = Force | NeedCommit
deriving (Eq, Read, Show)
-- git-annex's runtime state type doesn't really belong here,
diff --git a/Commands.hs b/Commands.hs
index 6c519c294..5b5bc269b 100644
--- a/Commands.hs
+++ b/Commands.hs
@@ -178,7 +178,8 @@ logStatus key status = do
g <- Annex.gitRepo
u <- getUUID g
f <- liftIO $ logChange g key u status
- liftIO $ Git.run g ["add", f] -- committed at shutdown
+ liftIO $ Git.run g ["add", f]
+ Annex.flagChange NeedCommit True
inBackend file yes no = do
r <- liftIO $ Backend.lookupFile file
diff --git a/Core.hs b/Core.hs
index 765b1e6a7..8f1c9cc80 100644
--- a/Core.hs
+++ b/Core.hs
@@ -14,7 +14,7 @@ import qualified Annex
{- Sets up a git repo for git-annex. -}
startup :: [Flag] -> Annex ()
startup flags = do
- Annex.flagsChange flags
+ mapM (\f -> Annex.flagChange f True) flags
g <- Annex.gitRepo
liftIO $ gitAttributes g
prepUUID
@@ -23,8 +23,11 @@ startup flags = do
shutdown :: Annex ()
shutdown = do
g <- Annex.gitRepo
- liftIO $ Git.run g ["commit", "-m",
- "git-annex log update", ".git-annex"]
+ needcommit <- Annex.flagIsSet NeedCommit
+ if (needcommit)
+ then liftIO $ Git.run g ["commit", "-m",
+ "git-annex log update", ".git-annex"]
+ else return ()
{- configure git to use union merge driver on state files, if it is not
- already -}