Improve behavior when a git-annex command is told to operate on a file that doesn't exist. It will now continue to other files specified after that on the command line, and only error out at the end.

This commit is contained in:
Joey Hess 2015-04-30 15:28:17 -04:00
parent 461b967966
commit efb37e7c78
5 changed files with 20 additions and 11 deletions

View file

@ -43,7 +43,7 @@ commandAction a = account =<< tryIO go
account (Right True) = return True account (Right True) = return True
account (Right False) = incerr account (Right False) = incerr
account (Left err) = do account (Left err) = do
showErr err toplevelWarning True (show err)
showEndFail showEndFail
incerr incerr
incerr = do incerr = do

View file

@ -218,8 +218,9 @@ seekHelper a params = do
ll <- inRepo $ \g -> concat <$> forM (segmentXargsOrdered params) ll <- inRepo $ \g -> concat <$> forM (segmentXargsOrdered params)
(runSegmentPaths (\fs -> Git.Command.leaveZombie <$> a fs g)) (runSegmentPaths (\fs -> Git.Command.leaveZombie <$> a fs g))
forM_ (map fst $ filter (null . snd) $ zip params ll) $ \p -> forM_ (map fst $ filter (null . snd) $ zip params ll) $ \p ->
unlessM (isJust <$> liftIO (catchMaybeIO $ getSymbolicLinkStatus p)) $ unlessM (isJust <$> liftIO (catchMaybeIO $ getSymbolicLinkStatus p)) $ do
error $ p ++ " not found" toplevelWarning False (p ++ " not found")
Annex.incError
return $ concat ll return $ concat ll
notSymlink :: FilePath -> IO Bool notSymlink :: FilePath -> IO Bool

View file

@ -116,7 +116,10 @@ start file = ifAnnexed file addpresent add
- Lockdown can fail if a file gets deleted, and Nothing will be returned. - Lockdown can fail if a file gets deleted, and Nothing will be returned.
-} -}
lockDown :: FilePath -> Annex (Maybe KeySource) lockDown :: FilePath -> Annex (Maybe KeySource)
lockDown = either (\e -> showErr e >> return Nothing) (return . Just) <=< lockDown' lockDown = either
(\e -> warning (show e) >> return Nothing)
(return . Just)
<=< lockDown'
lockDown' :: FilePath -> Annex (Either IOException KeySource) lockDown' :: FilePath -> Annex (Either IOException KeySource)
lockDown' file = ifM crippledFileSystem lockDown' file = ifM crippledFileSystem

View file

@ -19,7 +19,7 @@ module Messages (
showEndOk, showEndOk,
showEndFail, showEndFail,
showEndResult, showEndResult,
showErr, toplevelWarning,
warning, warning,
warningIO, warningIO,
indent, indent,
@ -117,15 +117,16 @@ showEndResult ok = handleMessage (JSON.end ok) $ putStrLn msg
| ok = "ok" | ok = "ok"
| otherwise = "failed" | otherwise = "failed"
showErr :: (Show a) => a -> Annex () toplevelWarning :: Bool -> String -> Annex ()
showErr e = warning' $ "git-annex: " ++ show e toplevelWarning makeway s = warning' makeway ("git-annex: " ++ s)
warning :: String -> Annex () warning :: String -> Annex ()
warning = warning' . indent warning = warning' True . indent
warning' :: String -> Annex () warning' :: Bool -> String -> Annex ()
warning' w = do warning' makeway w = do
handleMessage q $ putStr "\n" when makeway $
handleMessage q $ putStr "\n"
liftIO $ do liftIO $ do
hFlush stdout hFlush stdout
hPutStrLn stderr w hPutStrLn stderr w

4
debian/changelog vendored
View file

@ -21,6 +21,10 @@ git-annex (5.20150421) UNRELEASED; urgency=medium
* import: Before removing a duplicate file in --deduplicate or * import: Before removing a duplicate file in --deduplicate or
--clean-duplicates mode, verify that enough copies of its content still --clean-duplicates mode, verify that enough copies of its content still
exist. exist.
* Improve behavior when a git-annex command is told to operate
on a file that doesn't exist. It will now continue to other
files specified after that on the command line, and only error out at
the end.
-- Joey Hess <id@joeyh.name> Tue, 21 Apr 2015 15:54:10 -0400 -- Joey Hess <id@joeyh.name> Tue, 21 Apr 2015 15:54:10 -0400