summaryrefslogtreecommitdiff
path: root/Command
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-04-29 13:46:12 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-04-29 13:46:12 -0400
commita3c475831fa99555c0263c979856eb51862468c3 (patch)
tree26355d1b0253bda0c814aae6d2c2593287bb85af /Command
parent0e4fbf76b8c00dc89dc3cf67b2ac8e3bfd20b332 (diff)
import: Check for gitignored files before moving them into the tree. (Needs git 1.8.4 or newer.)
Diffstat (limited to 'Command')
-rw-r--r--Command/Import.hs15
1 files changed, 10 insertions, 5 deletions
diff --git a/Command/Import.hs b/Command/Import.hs
index 17cb49db1..060be6c65 100644
--- a/Command/Import.hs
+++ b/Command/Import.hs
@@ -16,6 +16,7 @@ import Backend
import Remote
import Types.KeySource
import Types.Key
+import Annex.CheckIgnore
cmd :: [Command]
cmd = [withOptions opts $ notBareRepo $ command "import" paramPaths seek
@@ -79,11 +80,15 @@ start mode (srcfile, destfile) =
next $ return True
importfile = do
handleexisting =<< liftIO (catchMaybeIO $ getSymbolicLinkStatus destfile)
- liftIO $ createDirectoryIfMissing True (parentDir destfile)
- liftIO $ if mode == Duplicate || mode == SkipDuplicates
- then void $ copyFileExternal CopyAllMetaData srcfile destfile
- else moveFile srcfile destfile
- Command.Add.perform destfile
+ ignored <- not <$> Annex.getState Annex.force <&&> checkIgnored destfile
+ if ignored
+ then error $ "not importing " ++ destfile ++ " which is .gitignored (use --force to override)"
+ else do
+ liftIO $ createDirectoryIfMissing True (parentDir destfile)
+ liftIO $ if mode == Duplicate || mode == SkipDuplicates
+ then void $ copyFileExternal CopyAllMetaData srcfile destfile
+ else moveFile srcfile destfile
+ Command.Add.perform destfile
handleexisting Nothing = noop
handleexisting (Just s)
| isDirectory s = notoverwriting "(is a directory)"