summaryrefslogtreecommitdiff
path: root/Command/Add.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-05-17 15:59:37 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-05-17 15:59:37 -0400
commit4e74c0d7f33a66eb524ef020ef4401fa322db34c (patch)
treed0a239d6022339b3cb5afeced2d3f859aa4d02d3 /Command/Add.hs
parent963f2c5726ce0fe899038733d4318a234d355268 (diff)
test suite passes in direct mode
This fixes a bug with git annex add in direct mode. If some files already existed in the tree pointing at the same key as a file that was just added, and their content was not present, add neglected to copy the content to those files. I also changed the behavior of moveAnnex slightly: When content is moved into the annex in direct mode, it does not overwrite any content already present in direct mode files. That content may be modified after all.
Diffstat (limited to 'Command/Add.hs')
-rw-r--r--Command/Add.hs6
1 files changed, 6 insertions, 0 deletions
diff --git a/Command/Add.hs b/Command/Add.hs
index 95af72a6f..be7c6e75e 100644
--- a/Command/Add.hs
+++ b/Command/Add.hs
@@ -30,6 +30,7 @@ import Utility.FileMode
import Config
import Utility.InodeCache
import Annex.FileMatcher
+import Annex.ReplaceFile
def :: [Command]
def = [notBareRepo $ command "add" paramPaths seek SectionCommon
@@ -155,6 +156,11 @@ finishIngestDirect key source = do
when (contentLocation source /= keyFilename source) $
liftIO $ nukeFile $ contentLocation source
+ {- Copy to any other locations using the same key. -}
+ otherfs <- filter (/= keyFilename source) <$> associatedFiles key
+ forM_ otherfs $
+ addContentWhenNotPresent key (keyFilename source)
+
perform :: FilePath -> CommandPerform
perform file =
maybe stop (\key -> next $ cleanup file key True)