avoid combining multiple words provided to trust/untrust/dead
authorJoey Hess <joeyh@joeyh.name>
Mon, 3 Oct 2022 17:48:40 +0000 (13:48 -0400)
committerJoey Hess <joeyh@joeyh.name>
Mon, 3 Oct 2022 17:48:40 +0000 (13:48 -0400)
* 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
CHANGELOG
Command/Trust.hs
doc/bugs/dead_with_no_params_can_mark_repo_with_empty_description_dead.mdwn

index 3aafa1e850bffb55505bf931c9c916cf3fc29d14..728d66a871280ce94a3ecaafd698f92877d441ec 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -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
 
   * Avoid displaying warning about git-annex restage needing to be run
index 176b491fbe2dd35a3380095aa64d0f283b8d5f9a..44fb968e3de855f676738bf3164d568fab78fe1c 100644 (file)
@@ -24,12 +24,12 @@ seek :: CmdParams -> CommandSeek
 seek = trustCommand "trust" Trusted
 
 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
-       start ws = do
-               let name = unwords ws
+       start name = do
                u <- Remote.nameToUUID name
-               let si = SeekInput ws
+               let si = SeekInput [name]
                starting c (ActionItemOther (Just name)) si (perform name u)
        perform name uuid = do
                when (level >= Trusted) $
index 8f3ce8808885c12f3df583e9fcd300e7794ddb25..d84b00045320547c20b62d33c50686d7415dd50d 100644 (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.
 
 Found this in <https://bugs.debian.org/855648> --[[Joey]]
+
+> [[fixed|done]] --[[Joey]]