On Tue, Apr 03, 2012 at 04:59:07PM -0400, Jeff King wrote: > > + if (!push_url_of_remote(remote, &dest_url) || > > + !push_url_of_remote(branch_dest, &branch_dest_url) || > > + strcmp(dest_url[0], branch_dest_url[0])) > > + die(_("You are pushing to remote '%s', which is not the " > > + "upstream of your\ncurrent branch '%s'.\n"), > > + remote->name, branch->name); > > + } > > Hmm. So this will actually detect "git push $URL" when $URL matches the > remote's configured URL. I feel like this distinction has come up > before, and we decided not to equate the two. But now I can't remember > where (maybe it when fetching via URL versus via remote?). > > What should happen if there are multiple push URLs configured? Your code > will match iff it is the first one. I would think it should either > require all to match, or it should proceed if any of the URLs match. > I think the latter makes more sense, though personally I would simply > have compared the remote names. If this is the behavior we want, here are some squashable tests (on top of my other tests) to check the URL-matching, and to expose the multiple-URL case. --- diff --git a/t/t5528-push-default.sh b/t/t5528-push-default.sh index c334c51..d809615 100755 --- a/t/t5528-push-default.sh +++ b/t/t5528-push-default.sh @@ -51,4 +51,29 @@ test_expect_success '"upstream" does not push when remotes do not match' ' test_must_fail git push parent2 ' +test_expect_success '"upstream" remote-match checks URLs' ' + git checkout master && + test_config branch.master.remote parent1 && + test_config branch.master.merge refs/heads/foo && + test_config push.default upstream && + test_commit six && + git push repo1 && + echo six >expect && + git --git-dir=repo1 log -1 --format=%s foo >actual && + test_cmp expect actual +' + +test_expect_failure '"upstream" remote-match checks all URLs' ' + git checkout master && + git config --add remote.parent1.push repo2 && + test_config branch.master.remote parent1 && + test_config branch.master.merge refs/heads/foo && + test_config push.default upstream && + test_commit seven && + git push repo2 && + echo seven >expect && + git --git-dir=repo2 log -1 --format=%s foo >actual && + test_cmp expect actual +' + test_done -- 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