From: Joey Hess Date: Fri, 22 Sep 2023 17:29:48 +0000 (-0400) Subject: enableremote: Avoid overwriting existing git remote when passed the uuid of a special... X-Git-Tag: archive/raspbian/10.20250416-2+rpi1~1^2~32^2~18 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=41f4d0bda9999da7db6d40fa5d862b885f67e91f;p=git-annex.git enableremote: Avoid overwriting existing git remote when passed the uuid of a specialremote that was earlier initialized with the same name --- diff --git a/CHANGELOG b/CHANGELOG index 0923922b43..ef2765a773 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -13,6 +13,8 @@ git-annex (10.20230829) UNRELEASED; urgency=medium before updating export remotes. * lookupkey: Added --ref option. * Support being built with crypton rather than cryptonite. + * enableremote: Avoid overwriting existing git remote when passed the uuid + of a specialremote that was earlier initialized with the same name. -- Joey Hess Mon, 28 Aug 2023 13:10:17 -0400 diff --git a/Command/EnableRemote.hs b/Command/EnableRemote.hs index 9f364c19c9..4d04610cdd 100644 --- a/Command/EnableRemote.hs +++ b/Command/EnableRemote.hs @@ -99,6 +99,16 @@ startSpecialRemote' _ _ _ _ _ = performSpecialRemote :: PerformSpecialRemote performSpecialRemote t u oldc c gc mcu = do + -- Avoid enabling a special remote if there is another remote + -- with the same name. + case SpecialRemote.lookupName c of + Nothing -> noop + Just name -> do + rs <- Remote.remoteList + case filter (\rmt -> Remote.name rmt == name) rs of + (rmt:_) | Remote.uuid rmt /= u -> + giveup $ "Not overwriting currently configured git remote named \"" ++ name ++ "\"" + _ -> noop (c', u') <- R.setup t (R.Enable oldc) (Just u) Nothing c gc next $ cleanupSpecialRemote t u' c' mcu diff --git a/doc/bugs/git-annex-enableremote_confusing_behavior_when_there_is_a_git_remote_with_same_name_as_special_remote.mdwn b/doc/bugs/git-annex-enableremote_confusing_behavior_when_there_is_a_git_remote_with_same_name_as_special_remote.mdwn index d6d51ed563..84ac671cee 100644 --- a/doc/bugs/git-annex-enableremote_confusing_behavior_when_there_is_a_git_remote_with_same_name_as_special_remote.mdwn +++ b/doc/bugs/git-annex-enableremote_confusing_behavior_when_there_is_a_git_remote_with_same_name_as_special_remote.mdwn @@ -9,3 +9,5 @@ annex-uuid and adding whatever other git configs the special remote uses. (initremote does check if there's already a remote with the same name, and refuses to overwrite it). + +> [[fixed|done]] --[[Joey]] diff --git a/doc/bugs/git-annex-enableremote_confusing_behavior_when_there_is_a_git_remote_with_same_name_as_special_remote/comment_1_7f28aecc6ecefd7d47979f73330759d2._comment b/doc/bugs/git-annex-enableremote_confusing_behavior_when_there_is_a_git_remote_with_same_name_as_special_remote/comment_1_7f28aecc6ecefd7d47979f73330759d2._comment new file mode 100644 index 0000000000..d70e00024e --- /dev/null +++ b/doc/bugs/git-annex-enableremote_confusing_behavior_when_there_is_a_git_remote_with_same_name_as_special_remote/comment_1_7f28aecc6ecefd7d47979f73330759d2._comment @@ -0,0 +1,18 @@ +[[!comment format=mdwn + username="joey" + subject="""comment 1""" + date="2023-09-22T17:05:28Z" + content=""" +The behavior in the first case has changed, it now displays: + + enableremote (normal) foo ok + +And the normal git remote is left as-is. Which seems more or less +reasonable. + +The behavior in the second case (passing the uuid) is still as described. + +I've fixed that to instead fail with: + + git-annex: Not overwriting currently configured git remote named "foo" +"""]]