summaryrefslogtreecommitdiff
path: root/Branch.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Branch.hs')
-rw-r--r--Branch.hs16
1 files changed, 13 insertions, 3 deletions
diff --git a/Branch.hs b/Branch.hs
index e4caeece7..9340259c7 100644
--- a/Branch.hs
+++ b/Branch.hs
@@ -213,9 +213,19 @@ updateRef ref
liftIO $ Git.UnionMerge.merge g [ref]
return $ Just ref
-{- Records changed content of a file into the journal. -}
-change :: FilePath -> String -> Annex ()
-change file content = do
+{- Applies a function to modifiy the content of a file. -}
+change :: FilePath -> (String -> String) -> Annex ()
+change file a = do
+ lock
+ get file >>= return . a >>= set file
+ unlock
+ where
+ lock = return ()
+ unlock = return ()
+
+{- Records new content of a file into the journal. -}
+set :: FilePath -> String -> Annex ()
+set file content = do
setJournalFile file content
setCache file content