[PATCH v2 0/2] Let `git remote add` play nicer with url.<url>.insteadOf

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Anastas Dancha reported that it is not possible to add a remote when
there is already a url.<url>.insteadOf = <nick> setting in
$HOME/.gitconfig.

While it makes sense to prevent surprises when a user adds a remote and
it fetches from somewhere completely different, it makes less sense to
prevent adding a remote when it is actually the same that was specified
in the config.

Therefore we add just another check that let's `git remote add` continue
when the "existing" remote's URL is identical to the specified one.

Interdiff below the diffstat (the commit message was also touched up to
stop pretending that we allow adding a remote twice when the URL did not
change).

Signed-off-by: Johannes Schindelin <johannes.schindelin@xxxxxx>

Johannes Schindelin (2):
  git remote: allow adding remotes agreeing with url.<...>.insteadOf
  Add a regression test for 'git remote add <existing> <same-url>'

 builtin/remote.c  | 4 +++-
 t/t5505-remote.sh | 5 +++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/builtin/remote.c b/builtin/remote.c
index 9168c83..b4ff468 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -180,7 +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]) &&
+	if (remote && (remote->url_nr > 1 ||
+			(strcmp(name, remote->url[0]) &&
 				strcmp(url, remote->url[0])) ||
 			remote->fetch_refspec_nr))
 		die(_("remote %s already exists."), name);
-- 
2.0.0.rc3.9669.g840d1f9
--
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



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]