import: Refuse to import files that are within the work tree, as that does not make sense and could cause data loss.

This commit is contained in:
Joey Hess 2015-05-11 12:57:47 -04:00
parent 6ebf615995
commit db5d831d07
3 changed files with 15 additions and 0 deletions

View file

@ -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