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
This commit is contained in:
Junio C Hamano 2015-01-14 12:29:47 -08:00
commit 7fd92d9ed0
2 changed files with 8 additions and 1 deletions

View file

@ -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);

View file

@ -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