diff --git a/Annex/Branch.hs b/Annex/Branch.hs index e86a3d7d18..fad818fb0a 100644 --- a/Annex/Branch.hs +++ b/Annex/Branch.hs @@ -244,9 +244,13 @@ siblingBranches = do pair l = (head l, last l) uref (a, _) (b, _) = a == b -{- Applies a function to modifiy the content of a file. -} +{- Applies a function to modifiy the content of a file. + - + - Note that this does not cause the branch to be merged, it only + - modifes the current content of the file on the branch. + -} change :: FilePath -> (String -> String) -> Annex () -change file a = lockJournal $ get file >>= return . a >>= set file +change file a = lockJournal $ getStale file >>= return . a >>= set file {- Records new content of a file into the journal. -} set :: FilePath -> String -> Annex () @@ -259,13 +263,24 @@ set file content = do - - Returns an empty string if the file doesn't exist yet. -} get :: FilePath -> Annex String -get file = fromcache =<< getCache file +get = get' False + +{- Like get, but does not merge the branch, so the info returned may not + - reflect changes in remotes. (Changing the value this returns, and then + - merging is always the same as using get, and then changing its value.) -} +getStale :: FilePath -> Annex String +getStale = get' True + +get' :: Bool -> FilePath -> Annex String +get' staleok file = fromcache =<< getCache file where fromcache (Just content) = return content fromcache Nothing = fromjournal =<< getJournalFile file fromjournal (Just content) = cache content - fromjournal Nothing = withIndexUpdate $ - cache =<< catFile fullname file + fromjournal Nothing + | staleok = withIndex frombranch + | otherwise = withIndexUpdate $ frombranch >>= cache + frombranch = catFile fullname file cache content = do setCache file content return content diff --git a/debian/changelog b/debian/changelog index ff735a79d3..76a29131db 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,9 @@ git-annex (3.20111112) UNRELEASED; urgency=low * merge: Improve commit messages to mention what was merged. + * Avoid doing auto-merging in commands that don't need fully current + information from the git-annex branch. In particular, git annex add + no longer needs to auto-merge. -- Joey Hess Sat, 12 Nov 2011 14:50:21 -0400 diff --git a/doc/todo/avoid_unnecessary_union_merges.mdwn b/doc/todo/avoid_unnecessary_union_merges.mdwn index 67aa285799..5cd4b64373 100644 --- a/doc/todo/avoid_unnecessary_union_merges.mdwn +++ b/doc/todo/avoid_unnecessary_union_merges.mdwn @@ -16,3 +16,5 @@ occurs before it has done anything, so ctrl-c should not be a problem there. This is a delicate change, I need to take care.. --[[Joey]] + +> [[done]] (assuming I didn't miss any cases where this is not safe!) --[[Joey]]