import: Don't stop entire import when one file fails due to being gitignored or conflicting with something in the work tree.
This commit is contained in:
parent
548037223c
commit
d8ad1d5503
2 changed files with 25 additions and 15 deletions
|
@ -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
|
||||
|
|
2
debian/changelog
vendored
2
debian/changelog
vendored
|
@ -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 <id@joeyh.name> Tue, 21 Apr 2015 15:54:10 -0400
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue