aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-04-30 15:28:17 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-04-30 15:28:17 -0400
commit508920bf728cfb5e4568b68a2943bd33efac26bc (patch)
treed04529a6b2529e771a65ac3c724c33067b9ccb2d
parent4cd5738bb29278498b06b4f4d3edd4962c7a0eea (diff)
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.
-rw-r--r--CmdLine/Action.hs2
-rw-r--r--CmdLine/Seek.hs5
-rw-r--r--Command/Add.hs5
-rw-r--r--Messages.hs15
-rw-r--r--debian/changelog4
5 files changed, 20 insertions, 11 deletions
diff --git a/CmdLine/Action.hs b/CmdLine/Action.hs
index a32abbbee..b566621bb 100644
--- a/CmdLine/Action.hs
+++ b/CmdLine/Action.hs
@@ -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
diff --git a/CmdLine/Seek.hs b/CmdLine/Seek.hs
index 1db075ec3..96076261f 100644
--- a/CmdLine/Seek.hs
+++ b/CmdLine/Seek.hs
@@ -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
diff --git a/Command/Add.hs b/Command/Add.hs
index c461c4d56..d53ba91ad 100644
--- a/Command/Add.hs
+++ b/Command/Add.hs
@@ -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
diff --git a/Messages.hs b/Messages.hs
index 0e83a7243..5dffbd8de 100644
--- a/Messages.hs
+++ b/Messages.hs
@@ -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
diff --git a/debian/changelog b/debian/changelog
index ec53afd4f..38db4ee67 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -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