summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2015-01-14 12:29:47 -0800
committerJunio C Hamano <gitster@pobox.com>2015-01-14 12:29:47 -0800
commit7fd92d9ed0255faf64ed78f02eadc902c7824008 (patch)
tree0d5eaf6c14aa0d0606f94253b8ff4de8a8c852a6
parentaddfb21a94fb4e6b9d07b270f7bb3748767a8f38 (diff)
parentb90c95d90ed9e96a0c1515c00fa8c0f92a0cb130 (diff)
downloadgit-7fd92d9ed0255faf64ed78f02eadc902c7824008.tar.gz
Merge branch 'js/remote-add-with-insteadof'
"git remote add $name $URL" is now allowed when "url.$URL.insteadOf" is already defined. * js/remote-add-with-insteadof: Add a regression test for 'git remote add <existing> <same-url>' git remote: allow adding remotes agreeing with url.<...>.insteadOf
-rw-r--r--builtin/remote.c4
-rwxr-xr-xt/t5505-remote.sh5
2 files changed, 8 insertions, 1 deletions
diff --git a/builtin/remote.c b/builtin/remote.c
index 46ecfd9f7b..b4ff468977 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -180,7 +180,9 @@ 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);
diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh
index ac79dd915d..17c6330f98 100755
--- a/t/t5505-remote.sh
+++ b/t/t5505-remote.sh
@@ -1113,4 +1113,9 @@ test_extra_arg set-url origin newurl oldurl
# prune takes any number of args
# update takes any number of args
+test_expect_success 'add remote matching the "insteadOf" URL' '
+ git config url.xyz@example.com.insteadOf backup &&
+ git remote add backup xyz@example.com
+'
+
test_done