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 False) = incerr
account (Left err) = do
showErr err
toplevelWarning True (show err)
showEndFail
incerr
incerr = do

View file

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

View file

@ -19,7 +19,7 @@ module Messages (
showEndOk,
showEndFail,
showEndResult,
showErr,
toplevelWarning,
warning,
warningIO,
indent,
@ -117,15 +117,16 @@ showEndResult ok = handleMessage (JSON.end ok) $ putStrLn msg
| ok = "ok"
| otherwise = "failed"
showErr :: (Show a) => a -> Annex ()
showErr e = warning' $ "git-annex: " ++ show e
toplevelWarning :: Bool -> String -> Annex ()
toplevelWarning makeway s = warning' makeway ("git-annex: " ++ s)
warning :: String -> Annex ()
warning = warning' . indent
warning = warning' True . indent
warning' :: String -> Annex ()
warning' w = do
handleMessage q $ putStr "\n"
warning' :: Bool -> String -> Annex ()
warning' makeway w = do
when makeway $
handleMessage q $ putStr "\n"
liftIO $ do
hFlush stdout
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
--clean-duplicates mode, verify that enough copies of its content still
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