summaryrefslogtreecommitdiff
path: root/Command/Unannex.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-07-04 16:06:28 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-07-04 16:06:28 -0400
commit22a4f5b348c72a07fac99786613f6efc2eeb3b17 (patch)
tree7869cbb571564f13d884c10f4778d818aae7daf0 /Command/Unannex.hs
parent5beb6bc76fb3edbc28c238eb9596fc828aa49bfc (diff)
unannex: In --fast mode, file content is left in the annex, and a hard link made to it.
Diffstat (limited to 'Command/Unannex.hs')
-rw-r--r--Command/Unannex.hs13
1 files changed, 11 insertions, 2 deletions
diff --git a/Command/Unannex.hs b/Command/Unannex.hs
index d30f8d20f..f0c1b27c6 100644
--- a/Command/Unannex.hs
+++ b/Command/Unannex.hs
@@ -10,6 +10,7 @@ module Command.Unannex where
import Control.Monad.State (liftIO)
import Control.Monad (unless)
import System.Directory
+import System.Posix.Files
import Command
import qualified Annex
@@ -22,6 +23,7 @@ import Content
import qualified Git
import qualified Git.LsFiles as LsFiles
import Messages
+import Locations
command :: [Command]
command = [repoCommand "unannex" paramPath seek "undo accidential add command"]
@@ -64,8 +66,15 @@ cleanup file key = do
-- git rm deletes empty directories; put them back
liftIO $ createDirectoryIfMissing True (parentDir file)
- fromAnnex key file
- logStatus key InfoMissing
+ fast <- Annex.getState Annex.fast
+ if fast
+ then liftIO $ do
+ -- fast mode: hard link to content in annex
+ createLink (gitAnnexLocation g key) file
+ allowWrite file
+ else do
+ fromAnnex key file
+ logStatus key InfoMissing
-- Commit staged changes at end to avoid confusing the
-- pre-commit hook if this file is later added back to