From 2e54251c18b1f13bfff0d5e42a39005c86919fad Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 29 Apr 2015 13:46:12 -0400 Subject: [PATCH] import: Check for gitignored files before moving them into the tree. (Needs git 1.8.4 or newer.) --- Command/Import.hs | 15 ++++++++++----- debian/changelog | 2 ++ .../git_annex_import:_ignored_names_fatal.mdwn | 3 +++ 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Command/Import.hs b/Command/Import.hs index 17cb49db16..060be6c65f 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)" diff --git a/debian/changelog b/debian/changelog index 4840490d42..527a09f416 100644 --- a/debian/changelog +++ b/debian/changelog @@ -11,6 +11,8 @@ git-annex (5.20150421) UNRELEASED; urgency=medium * S3: Fix incompatability with bucket names used by hS3; the aws library cannot handle upper-case bucket names. git-annex now converts them to lower case automatically. + * import: Check for gitignored files before moving them into the tree. + (Needs git 1.8.4 or newer.) -- Joey Hess Tue, 21 Apr 2015 15:54:10 -0400 diff --git a/doc/bugs/git_annex_import:_ignored_names_fatal.mdwn b/doc/bugs/git_annex_import:_ignored_names_fatal.mdwn index e96ca2acb7..8981cadd86 100644 --- a/doc/bugs/git_annex_import:_ignored_names_fatal.mdwn +++ b/doc/bugs/git_annex_import:_ignored_names_fatal.mdwn @@ -36,3 +36,6 @@ Can't the ignored files just be ignored? # End of transcript or log. """]] + +> Made git-annex import check for gitignored files before +> moving them into the work tree. [[done]] --[[Joey]]