>From f80bdf3272e7bdf790ee67fb94196a8aa139331f Mon Sep 17 00:00:00 2001 From: Anastas Dancha <anapsix@xxxxxxxxx> Date: Mon, 15 Dec 2014 16:30:50 -0500 Subject: [PATCH] remote: allow adding remote w same name as alias When ~/.gitconfig contains an alias (i.e. myremote) and you are adding a new remote using the same name for remote, Git will refuse to add the remote with the same name as one of the aliases, even though the remote with such name is not setup for current repo. $ git remote add myremote git@xxxxxxxx:team/repo.git fatal: remote myremote already exists. The fatal error comes from strcmp(name, remote->url[0]) condition, which compares a name of the new remote with existing urls of all the remotes, including the ones from ~/.gitconfig (or global variant). I'm not sure why that is necessary, unless Git is meant to prevent users from naming their remotes as their remote aliases.. Imho, if someone want's to git remote add myremote myremote, they should, since git-remote always takes 2 arguments, first being the new remote's name and second being new remote's url (or alias, if set). Thanks to @mymuss for sanity check and debugging. Signed-off-by: Anastas Dancha <anapsix@xxxxxxxxx> --- builtin/remote.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/builtin/remote.c b/builtin/remote.c index 7f28f92..7471d0a 100644 --- a/builtin/remote.c +++ b/builtin/remote.c @@ -180,9 +180,8 @@ static int add(int argc, const char **argv) url = argv[1]; remote = remote_get(name); - if (remote && (remote->url_nr > 1 || strcmp(name, remote->url[0]) || - remote->fetch_refspec_nr)) - die(_("remote %s already exists."), name); + if (remote && (remote->url_nr > 1 || remote->fetch_refspec_nr)) + die(_("remote %s %s already exists."), name, url); strbuf_addf(&buf2, "refs/heads/test:refs/remotes/%s/test", name); if (!valid_fetch_refspec(buf2.buf)) -- 2.2.0 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html