avoid empty commits
This commit is contained in:
parent
c977b6b1f3
commit
bbbe9858fe
4 changed files with 16 additions and 9 deletions
11
Annex.hs
11
Annex.hs
|
@ -8,7 +8,7 @@ module Annex (
|
||||||
backends,
|
backends,
|
||||||
backendsChange,
|
backendsChange,
|
||||||
flagIsSet,
|
flagIsSet,
|
||||||
flagsChange,
|
flagChange,
|
||||||
Flag(..)
|
Flag(..)
|
||||||
) where
|
) where
|
||||||
|
|
||||||
|
@ -60,8 +60,11 @@ flagIsSet :: Flag -> Annex Bool
|
||||||
flagIsSet flag = do
|
flagIsSet flag = do
|
||||||
state <- get
|
state <- get
|
||||||
return $ elem flag $ Backend.flags state
|
return $ elem flag $ Backend.flags state
|
||||||
flagsChange :: [Flag] -> Annex ()
|
flagChange :: Flag -> Bool -> Annex ()
|
||||||
flagsChange b = do
|
flagChange flag set = do
|
||||||
state <- get
|
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 ()
|
return ()
|
||||||
|
|
|
@ -10,7 +10,7 @@ import Data.String.Utils
|
||||||
import qualified GitRepo as Git
|
import qualified GitRepo as Git
|
||||||
|
|
||||||
-- command-line flags
|
-- command-line flags
|
||||||
data Flag = Force
|
data Flag = Force | NeedCommit
|
||||||
deriving (Eq, Read, Show)
|
deriving (Eq, Read, Show)
|
||||||
|
|
||||||
-- git-annex's runtime state type doesn't really belong here,
|
-- git-annex's runtime state type doesn't really belong here,
|
||||||
|
|
|
@ -178,7 +178,8 @@ logStatus key status = do
|
||||||
g <- Annex.gitRepo
|
g <- Annex.gitRepo
|
||||||
u <- getUUID g
|
u <- getUUID g
|
||||||
f <- liftIO $ logChange g key u status
|
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
|
inBackend file yes no = do
|
||||||
r <- liftIO $ Backend.lookupFile file
|
r <- liftIO $ Backend.lookupFile file
|
||||||
|
|
7
Core.hs
7
Core.hs
|
@ -14,7 +14,7 @@ import qualified Annex
|
||||||
{- Sets up a git repo for git-annex. -}
|
{- Sets up a git repo for git-annex. -}
|
||||||
startup :: [Flag] -> Annex ()
|
startup :: [Flag] -> Annex ()
|
||||||
startup flags = do
|
startup flags = do
|
||||||
Annex.flagsChange flags
|
mapM (\f -> Annex.flagChange f True) flags
|
||||||
g <- Annex.gitRepo
|
g <- Annex.gitRepo
|
||||||
liftIO $ gitAttributes g
|
liftIO $ gitAttributes g
|
||||||
prepUUID
|
prepUUID
|
||||||
|
@ -23,8 +23,11 @@ startup flags = do
|
||||||
shutdown :: Annex ()
|
shutdown :: Annex ()
|
||||||
shutdown = do
|
shutdown = do
|
||||||
g <- Annex.gitRepo
|
g <- Annex.gitRepo
|
||||||
liftIO $ Git.run g ["commit", "-m",
|
needcommit <- Annex.flagIsSet NeedCommit
|
||||||
|
if (needcommit)
|
||||||
|
then liftIO $ Git.run g ["commit", "-m",
|
||||||
"git-annex log update", ".git-annex"]
|
"git-annex log update", ".git-annex"]
|
||||||
|
else return ()
|
||||||
|
|
||||||
{- configure git to use union merge driver on state files, if it is not
|
{- configure git to use union merge driver on state files, if it is not
|
||||||
- already -}
|
- already -}
|
||||||
|
|
Loading…
Reference in a new issue