diff options
author | Joey Hess <joey@kitenet.net> | 2011-10-10 17:37:44 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-10-10 17:37:44 -0400 |
commit | 025ded4a2dfb58a6ec0cb47b9d625d593a4e1977 (patch) | |
tree | 861010583a8d2367cb27cdf3cb0773d8af5fea74 /Annex | |
parent | 10edaf6dc9c5a8f091487e8ba82ac8f54697bf0c (diff) |
tweaks
Diffstat (limited to 'Annex')
-rw-r--r-- | Annex/Branch.hs | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/Annex/Branch.hs b/Annex/Branch.hs index 0002befec..aea0d2bff 100644 --- a/Annex/Branch.hs +++ b/Annex/Branch.hs @@ -215,20 +215,16 @@ set file content = do - - Returns an empty string if the file doesn't exist yet. -} get :: FilePath -> Annex String -get file = do - cached <- getCache file - case cached of - Just content -> return content - Nothing -> do - j <- getJournalFile file - case j of - Just content -> do - setCache file content - return content - Nothing -> withIndexUpdate $ do - content <- catFile fullname file - setCache file content - return content +get 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 + cache content = do + setCache file content + return content {- Lists all files on the branch. There may be duplicates in the list. -} files :: Annex [FilePath] @@ -287,8 +283,7 @@ stageJournalFiles = do let paths = map (dir </>) fs -- inject all the journal files directly into git -- in one quick command - (pid, fromh, toh) <- hPipeBoth "git" $ toCommand $ - Git.gitCommandLine g [Param "hash-object", Param "-w", Param "--stdin-paths"] + (pid, fromh, toh) <- hPipeBoth "git" $ toCommand $ git_hash_object g _ <- forkProcess $ do hPutStr toh $ unlines paths hClose toh @@ -304,6 +299,9 @@ stageJournalFiles = do where index_lines shas = map genline . zip shas genline (sha, file) = Git.UnionMerge.update_index_line sha file + git_hash_object g = Git.gitCommandLine g + [Param "hash-object", Param "-w", Param "--stdin-paths"] + {- Checks if there are changes in the journal. -} journalDirty :: Annex Bool |