From c6503891188a09bc4ddc6cee353a0677faa61c79 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 24 Aug 2019 13:20:19 -0400 Subject: [PATCH] info: error out when file matching options used on non-directory When file matching options are specified when getting info of something other than a directory, they won't have any effect, so error out to avoid confusion. This commit was sponsored by mo on Patreon. --- CHANGELOG | 8 ++++++++ Command/Info.hs | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 23d78ac04c..949cd456d5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,11 @@ +git-annex (7.20190820) UNRELEASED; urgency=medium + + * info: When file matching options are specified when getting + info of something other than a directory, they won't have any effect, + so error out to avoid confusion. + + -- Joey Hess Sat, 24 Aug 2019 12:54:35 -0400 + git-annex (7.20190819) upstream; urgency=medium * New git-lfs special remote, which can be used to store data on any git-lfs diff --git a/Command/Info.hs b/Command/Info.hs index c52b99d696..c6dce7db5e 100644 --- a/Command/Info.hs +++ b/Command/Info.hs @@ -132,6 +132,7 @@ start o ps = do globalInfo :: InfoOptions -> Annex () globalInfo o = do + disallowMatchingOptions u <- getUUID whenM ((==) DeadTrusted <$> lookupTrust u) $ earlyWarning "Warning: This repository is currently marked as dead." @@ -144,6 +145,7 @@ itemInfo :: InfoOptions -> String -> Annex () itemInfo o p = ifM (isdir p) ( dirInfo o p , do + disallowMatchingOptions v <- Remote.byName' p case v of Right r -> remoteInfo o r @@ -164,6 +166,10 @@ noInfo s = do showNote $ "not a directory or an annexed file or a treeish or a remote or a uuid" showEndFail +disallowMatchingOptions :: Annex () +disallowMatchingOptions = whenM Limit.limited $ + giveup "File matching options can only be used when getting info on a directory." + dirInfo :: InfoOptions -> FilePath -> Annex () dirInfo o dir = showCustom (unwords ["info", dir]) $ do stats <- selStats