Anastas Dancha schrieb am 16.12.2014 um 03:30:
> From f80bdf3272e7bdf790ee67fb94196a8aa139331f Mon Sep 17 00:00:00 2001
> From: Anastas Dancha <anap...@random.io>
> 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 g...@host.com: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).

While that is true for "git remote", it is wrong for "git push" and the
like, which takes "remote name or remote URL" as a parameter. Therefore,
remote names and remote aliases need to be unique within the same namespace.

> Thanks to @mymuss for sanity check and debugging.
> 
> Signed-off-by: Anastas Dancha <anap...@random.io>
> ---
>  builtin/remote.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to