From d8ad1d55030392969b0ea82b8e11333ca7e53345 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 29 Apr 2015 13:56:41 -0400 Subject: [PATCH] import: Don't stop entire import when one file fails due to being gitignored or conflicting with something in the work tree. --- Command/Import.hs | 38 +++++++++++++++++++++++--------------- debian/changelog | 2 ++ 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/Command/Import.hs b/Command/Import.hs index 060be6c65f..261bd7b8ef 100644 --- a/Command/Import.hs +++ b/Command/Import.hs @@ -79,24 +79,32 @@ start mode (srcfile, destfile) = liftIO $ removeFile srcfile next $ return True importfile = do - handleexisting =<< liftIO (catchMaybeIO $ getSymbolicLinkStatus destfile) ignored <- not <$> Annex.getState Annex.force <&&> checkIgnored destfile if ignored - then error $ "not importing " ++ destfile ++ " which is .gitignored (use --force to override)" + then do + warning $ "not importing " ++ destfile ++ " which is .gitignored (use --force to override)" + stop 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)" - | otherwise = ifM (Annex.getState Annex.force) - ( liftIO $ nukeFile destfile - , notoverwriting "(use --force to override, or a duplication option such as --deduplicate to clean up)" - ) - notoverwriting why = error $ "not overwriting existing " ++ destfile ++ " " ++ why + existing <- liftIO (catchMaybeIO $ getSymbolicLinkStatus destfile) + case existing of + Nothing -> importfilechecked + (Just s) + | isDirectory s -> notoverwriting "(is a directory)" + | otherwise -> ifM (Annex.getState Annex.force) + ( do + liftIO $ nukeFile destfile + importfilechecked + , notoverwriting "(use --force to override, or a duplication option such as --deduplicate to clean up)" + ) + importfilechecked = 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 + notoverwriting why = do + warning $ "not overwriting existing " ++ destfile ++ " " ++ why + stop checkdup dupa notdupa = do backend <- chooseBackend destfile let ks = KeySource srcfile srcfile Nothing diff --git a/debian/changelog b/debian/changelog index 527a09f416..ac96777acb 100644 --- a/debian/changelog +++ b/debian/changelog @@ -13,6 +13,8 @@ git-annex (5.20150421) UNRELEASED; urgency=medium lower case automatically. * import: Check for gitignored files before moving them into the tree. (Needs git 1.8.4 or newer.) + * import: Don't stop entire import when one file fails due to being + gitignored or conflicting with something in the work tree. -- Joey Hess Tue, 21 Apr 2015 15:54:10 -0400