avoid combining multiple words provided to trust/untrust/dead

* trust, untrust, semitrust, dead: Fix behavior when provided with
  multiple repositories to operate on.
* trust, untrust, semitrust, dead: When provided with no parameters,
  do not operate on a repository that has an empty name.

The man page and usage already indicated that multiple repos could be
provided to these commands, but they actually used unwords to combine
everything into string, and found a repo matching that string. This was
especially bad when no parameters resulted in the empty string and some
repo happened to have an empty description.

This does change the behavior, and it's possible someone relied on the
current behavior to eg, trust a repo by name with the name not quoted into
a single parameter. But fixing the empty string bug and matching the
documentation are worth breaking that usage.

Note that git-annex init/reinit do still unwords multiple parameters when
provided to them. That is inconsistent behavior, but it certianly seems
possible that something does run git-annex init with an unquoted
description, and I don't think it's worth breaking that just to make it more
consistent with these other commands.

Sponsored-by: Boyd Stephen Smith Jr. on Patreon
This commit is contained in:
Joey Hess 2022-10-03 13:48:40 -04:00
parent 99e4dc8d41
commit 15f9fcbcb1
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
3 changed files with 15 additions and 4 deletions

View file

@ -1,3 +1,12 @@
git-annex (10.20221004) UNRELEASED; urgency=medium
* trust, untrust, semitrust, dead: Fix behavior when provided with
multiple repositories to operate on.
* trust, untrust, semitrust, dead: When provided with no parameters,
do not operate on a repository that has an empty name.
-- Joey Hess <id@joeyh.name> Mon, 03 Oct 2022 13:36:42 -0400
git-annex (10.20221003) upstream; urgency=medium git-annex (10.20221003) upstream; urgency=medium
* Avoid displaying warning about git-annex restage needing to be run * Avoid displaying warning about git-annex restage needing to be run

View file

@ -24,12 +24,12 @@ seek :: CmdParams -> CommandSeek
seek = trustCommand "trust" Trusted seek = trustCommand "trust" Trusted
trustCommand :: String -> TrustLevel -> CmdParams -> CommandSeek trustCommand :: String -> TrustLevel -> CmdParams -> CommandSeek
trustCommand c level = withWords (commandAction . start) trustCommand _ _ [] = giveup "no repository name specified"
trustCommand c level ps = withStrings (commandAction . start) ps
where where
start ws = do start name = do
let name = unwords ws
u <- Remote.nameToUUID name u <- Remote.nameToUUID name
let si = SeekInput ws let si = SeekInput [name]
starting c (ActionItemOther (Just name)) si (perform name u) starting c (ActionItemOther (Just name)) si (perform name u)
perform name uuid = do perform name uuid = do
when (level >= Trusted) $ when (level >= Trusted) $

View file

@ -9,3 +9,5 @@ I would be ok with `git-annex dead ""` doing that, perhaps, but when
no parameters are given, it constructs the empty string itself, which is a bug. no parameters are given, it constructs the empty string itself, which is a bug.
Found this in <https://bugs.debian.org/855648> --[[Joey]] Found this in <https://bugs.debian.org/855648> --[[Joey]]
> [[fixed|done]] --[[Joey]]