summaryrefslogtreecommitdiff
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
parent560301841e5f29243b72faadc44138e860fa0490 (diff)
import: Refuse to import files that are within the work tree, as that does not make sense and could cause data loss.
-rw-r--r--Command/Import.hs5
-rw-r--r--debian/changelog7
-rw-r--r--doc/bugs/Data_loss_when_doing___96__git_annex_import_--force__96__.mdwn3
3 files changed, 15 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
diff --git a/debian/changelog b/debian/changelog
index cd7ade7b7..58921d5a9 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+git-annex (5.20150508.2) UNRELEASED; urgency=medium
+
+ * import: Refuse to import files that are within the work tree, as that
+ does not make sense and could cause data loss.
+
+ -- Joey Hess <id@joeyh.name> Mon, 11 May 2015 12:45:06 -0400
+
git-annex (5.20150508.1) unstable; urgency=medium
* Now builds cleanly using ghc 7.10 (as well as ghc back to 7.6).
diff --git a/doc/bugs/Data_loss_when_doing___96__git_annex_import_--force__96__.mdwn b/doc/bugs/Data_loss_when_doing___96__git_annex_import_--force__96__.mdwn
index 8c61ba8d5..60e04fc14 100644
--- a/doc/bugs/Data_loss_when_doing___96__git_annex_import_--force__96__.mdwn
+++ b/doc/bugs/Data_loss_when_doing___96__git_annex_import_--force__96__.mdwn
@@ -57,3 +57,6 @@ drwx------ 55 jkt jkt 8.0K May 8 13:54 ..
drwxr-xr-x 8 jkt jkt 119 May 8 13:55 .git
"""]]
...and the file is gone :(.
+
+> You should use `git annex add` in this case, not import.
+> I've made import refuse to run in this case. [[done]] --[[Joey]]