summaryrefslogtreecommitdiff
path: root/Command/Import.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-05-11 12:57:47 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-05-11 12:57:47 -0400
commit0b0b0ca095dfe50e81fc32781142ef2e18baeb41 (patch)
tree081079327a16916914dcd3c355f44601a8ea5275 /Command/Import.hs
parent560301841e5f29243b72faadc44138e860fa0490 (diff)
import: Refuse to import files that are within the work tree, as that does not make sense and could cause data loss.
Diffstat (limited to 'Command/Import.hs')
-rw-r--r--Command/Import.hs5
1 files changed, 5 insertions, 0 deletions
diff --git a/Command/Import.hs b/Command/Import.hs
index eb21faea2..fffa301ec 100644
--- a/Command/Import.hs
+++ b/Command/Import.hs
@@ -9,6 +9,7 @@ module Command.Import where
import Common.Annex
import Command
+import qualified Git
import qualified Annex
import qualified Command.Add
import Utility.CopyFile
@@ -62,6 +63,10 @@ getDuplicateMode = go . catMaybes <$> mapM getflag [minBound..maxBound]
seek :: CommandSeek
seek ps = do
mode <- getDuplicateMode
+ repopath <- liftIO . absPath =<< fromRepo Git.repoPath
+ inrepops <- liftIO $ filter (dirContains repopath) <$> mapM absPath ps
+ unless (null inrepops) $ do
+ error $ "cannot import files from inside the working tree (use git annex add instead): " ++ unwords inrepops
withPathContents (start mode) ps
start :: DuplicateMode -> (FilePath, FilePath) -> CommandStart