better handling of multiple repositories with the same name

Used to fail with a bad error message, indicating there was no
repository with the specified name, or something like that. Now, suggest
they use the uuid to disambiguate.

* info, enableremotemote, renameremote: Avoid a confusing message when more
  than one repository matches the user provided name.
* info: Exit nonzero when the input is not supported.

Sponsored-by: Kevin Mueller on Patreon
This commit is contained in:
Joey Hess 2023-02-13 14:30:54 -04:00
parent 826b225ca8
commit 452b080dba
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
6 changed files with 41 additions and 33 deletions

View file

@ -35,12 +35,12 @@ start ps@(oldname:newname:[]) = Annex.SpecialRemote.findExisting oldname >>= \ca
-- as a fallback when there is nothing with the name in the
-- special remote log.
[] -> Remote.nameToUUID' oldname >>= \case
Left e -> giveup e
Right u -> do
([u], _) -> do
m <- Logs.Remote.remoteConfigMap
case M.lookup u m of
Nothing -> giveup "That is not a special remote."
Just cfg -> go u cfg Nothing
(_, msg) -> giveup msg
_ -> giveup $ "There are multiple special remotes named " ++ oldname ++ ". Provide instead the uuid or description of the remote to rename."
where
ai = ActionItemOther Nothing