summaryrefslogtreecommitdiff
path: root/Command/Add.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-04-11 13:35:52 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-04-11 13:35:52 -0400
commite15223eba22e27f934c366b17a62c80f676360e8 (patch)
treeb0a86335757bf247b6ae956db3ca902086ba7997 /Command/Add.hs
parent321bae61104bd64126aedb3b03093ff6e4daf35a (diff)
addurl: Bugfix: Did not properly add file in direct mode.
Diffstat (limited to 'Command/Add.hs')
-rw-r--r--Command/Add.hs37
1 files changed, 18 insertions, 19 deletions
diff --git a/Command/Add.hs b/Command/Add.hs
index a5dfc1d1c..2453e6842 100644
--- a/Command/Add.hs
+++ b/Command/Add.hs
@@ -188,19 +188,29 @@ link file key hascontent = handle (undo file key) $ do
return l
-{- Note: Several other commands call this, and expect it to
- - create the link and add it.
- -
- - In direct mode, when we have the content of the file, it's left as-is,
- - and we just stage a symlink to git.
- -
- - Otherwise, as long as the filesystem supports symlinks, we use
+{- Creates the symlink to the annexed content, and stages it in git.
+ -
+ - As long as the filesystem supports symlinks, we use
- git add, rather than directly staging the symlink to git.
- Using git add is best because it allows the queuing to work
- and is faster (staging the symlink runs hash-object commands each time).
- Also, using git add allows it to skip gitignored files, unless forced
- to include them.
-}
+addLink :: FilePath -> Key -> Bool -> Annex ()
+addLink file key hascontent = ifM (coreSymlinks <$> Annex.getGitConfig)
+ ( do
+ _ <- link file key hascontent
+ params <- ifM (Annex.getState Annex.force)
+ ( return [Param "-f"]
+ , return []
+ )
+ Annex.Queue.addCommand "add" (params++[Param "--"]) [file]
+ , do
+ l <- link file key hascontent
+ addAnnexLink l file
+ )
+
cleanup :: FilePath -> Key -> Bool -> CommandCleanup
cleanup file key hascontent = do
when hascontent $
@@ -209,17 +219,6 @@ cleanup file key hascontent = do
( do
l <- inRepo $ gitAnnexLink file key
stageSymlink file =<< hashSymlink l
- , ifM (coreSymlinks <$> Annex.getGitConfig)
- ( do
- _ <- link file key hascontent
- params <- ifM (Annex.getState Annex.force)
- ( return [Param "-f"]
- , return []
- )
- Annex.Queue.addCommand "add" (params++[Param "--"]) [file]
- , do
- l <- link file key hascontent
- addAnnexLink l file
- )
+ , addLink file key hascontent
)
return True