diff --git a/builtin/remote.c b/builtin/remote.c index 46ecfd9f7b0dd0b28169341d14132df376e509bc..b4ff4689770e402675faba2ce400150b4803a360 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 ac79dd915da4a520e90fca6a11a239aba6e688d7..17c6330f988ecc98735307fbfd8bded5283feb61 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