aboutsummaryrefslogtreecommitdiff
path: root/Command/InitRemote.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-10-15 15:47:49 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-10-15 15:47:49 -0400
commit9a4c5746c2df53f9c385b62a051772f8dd91b1a9 (patch)
treee1fdf05c330c9102290201c83976e4f3b05cd9a4 /Command/InitRemote.hs
parenta919ef54ff13438d12da75d98015b1299bc9c6ee (diff)
initremote: Don't allow creating a special remote that has the same name as an existing git remote.
This is not a complete fix. For one, git remote will happily go add a remote that has the same name as an existing special remote. For another, enableremote will enable a special remote over top of an existing git remote. And, also, the webapp might.
Diffstat (limited to 'Command/InitRemote.hs')
-rw-r--r--Command/InitRemote.hs14
1 files changed, 9 insertions, 5 deletions
diff --git a/Command/InitRemote.hs b/Command/InitRemote.hs
index e2fc4146d..51ea15373 100644
--- a/Command/InitRemote.hs
+++ b/Command/InitRemote.hs
@@ -33,11 +33,15 @@ start (name:ws) = ifM (isJust <$> findExisting name)
( error $ "There is already a special remote named \"" ++ name ++
"\". (Use enableremote to enable an existing special remote.)"
, do
- let c = newConfig name
- t <- findType config
-
- showStart "initremote" name
- next $ perform t name $ M.union config c
+ ifM (isJust <$> Remote.byNameOnly name)
+ ( error $ "There is already a remote named \"" ++ name ++ "\""
+ , do
+ let c = newConfig name
+ t <- findType config
+
+ showStart "initremote" name
+ next $ perform t name $ M.union config c
+ )
)
where
config = Logs.Remote.keyValToConfig ws