aboutsummaryrefslogtreecommitdiff
path: root/Command
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-02-20 13:37:46 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-02-20 13:37:46 -0400
commit49147d538b142ce2e206cdd9d19d7438bd47e3b3 (patch)
tree4a0fe12d468d480517ba0e65bea24f53aca310a6 /Command
parentba91ab000a10cfad5d58d80d309cadaf40c3d0bd (diff)
Direct mode: Fix support for adding a modified file.
Adding a file that is already annexed, but has been modified, was broken in direct mode. This fix makes the new content be added. It does have the problem that re-running `git annex add` will checksum and re-add the content repeatedly, until it's committed. This happens because the key associated with the file does not change until the new one gets committed, so it keeps thinking the file has changed.
Diffstat (limited to 'Command')
-rw-r--r--Command/Add.hs10
1 files changed, 7 insertions, 3 deletions
diff --git a/Command/Add.hs b/Command/Add.hs
index 7ebf979cd..33adc8efc 100644
--- a/Command/Add.hs
+++ b/Command/Add.hs
@@ -35,14 +35,14 @@ def = [notBareRepo $ command "add" paramPaths seek "add files to annex"]
seek :: [CommandSeek]
seek =
[ withFilesNotInGit start
- , whenNotDirect $ withFilesUnlocked start
+ , withFilesUnlocked start
]
{- The add subcommand annexes a file, generating a key for it using a
- backend, and then moving it into the annex directory and setting up
- the symlink pointing to its content. -}
start :: FilePath -> CommandStart
-start file = ifAnnexed file fixup add
+start file = ifAnnexed file addpresent add
where
add = do
s <- liftIO $ getSymbolicLinkStatus file
@@ -51,7 +51,11 @@ start file = ifAnnexed file fixup add
else do
showStart "add" file
next $ perform file
- fixup (key, _) = do
+ addpresent (key, _) = ifM isDirect
+ ( ifM (goodContent key file) ( stop , add )
+ , fixup key
+ )
+ fixup key = do
-- fixup from an interrupted add; the symlink
-- is present but not yet added to git
showStart "add" file