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.
This commit is contained in:
parent
8012d61874
commit
c650389118
2 changed files with 14 additions and 0 deletions
|
@ -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 <id@joeyh.name> Sat, 24 Aug 2019 12:54:35 -0400
|
||||||
|
|
||||||
git-annex (7.20190819) upstream; urgency=medium
|
git-annex (7.20190819) upstream; urgency=medium
|
||||||
|
|
||||||
* New git-lfs special remote, which can be used to store data on any git-lfs
|
* New git-lfs special remote, which can be used to store data on any git-lfs
|
||||||
|
|
|
@ -132,6 +132,7 @@ start o ps = do
|
||||||
|
|
||||||
globalInfo :: InfoOptions -> Annex ()
|
globalInfo :: InfoOptions -> Annex ()
|
||||||
globalInfo o = do
|
globalInfo o = do
|
||||||
|
disallowMatchingOptions
|
||||||
u <- getUUID
|
u <- getUUID
|
||||||
whenM ((==) DeadTrusted <$> lookupTrust u) $
|
whenM ((==) DeadTrusted <$> lookupTrust u) $
|
||||||
earlyWarning "Warning: This repository is currently marked as dead."
|
earlyWarning "Warning: This repository is currently marked as dead."
|
||||||
|
@ -144,6 +145,7 @@ itemInfo :: InfoOptions -> String -> Annex ()
|
||||||
itemInfo o p = ifM (isdir p)
|
itemInfo o p = ifM (isdir p)
|
||||||
( dirInfo o p
|
( dirInfo o p
|
||||||
, do
|
, do
|
||||||
|
disallowMatchingOptions
|
||||||
v <- Remote.byName' p
|
v <- Remote.byName' p
|
||||||
case v of
|
case v of
|
||||||
Right r -> remoteInfo o r
|
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"
|
showNote $ "not a directory or an annexed file or a treeish or a remote or a uuid"
|
||||||
showEndFail
|
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 :: InfoOptions -> FilePath -> Annex ()
|
||||||
dirInfo o dir = showCustom (unwords ["info", dir]) $ do
|
dirInfo o dir = showCustom (unwords ["info", dir]) $ do
|
||||||
stats <- selStats
|
stats <- selStats
|
||||||
|
|
Loading…
Reference in a new issue