Skip to content

Commit

Permalink
Merge branch 'js/remote-add-with-insteadof'
Browse files Browse the repository at this point in the history
"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
  • Loading branch information
Junio C Hamano committed Jan 14, 2015
2 parents addfb21 + b90c95d commit 7fd92d9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion builtin/remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
5 changes: 5 additions & 0 deletions t/t5505-remote.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 7fd92d9

Please sign in to comment.