Re: [RFC] add test cases for the --repo option to git push
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:46:17
Michael J Gruber [off-list ref] writes:
quoted hunk
@@ -419,6 +419,41 @@ test_expect_success 'push with config remote.*.push = HEAD' ' git config --remove-section remote.there git config --remove-section branch.master +test_expect_success 'push with --repo=repourl from non-tracking branch' ' + + mk_test heads/master && + git push --repo=testrepo && + check_push_result $the_commit heads/master +' + +# set up fake remote config +test_expect_success 'push with --repo=remoterepo from non-tracking branch' ' + + mk_test heads/master && + git config remote.testremote.url testrepo && + git push --repo=testremote && + check_push_result $the_commit heads/master +' + +# set up fake tracking info; testrepo exists, origin does not. +test_expect_failure 'push with --repo=repo from tracking branch with bad config' ' + + mk_test heads/master && + git config branch.master.remote origin && + test_must_fail git push --repo=testrepo +'
At this point, you have:
branch.master.remote = origin
remote.testremote.url = testrepo
and nothing else related to push. And you are asking a "git push but
instead of origin please default to testrepo".
In response to that request, in order to figure out what refs to push by
default, remote.testremote.push instead of remote.origin.push will be
consulted, and we won't even have to notice nor complain the missing
remote.origin. remote.testremote.push is missing, so the push defaults to
the "matching ref" behaviour.
I do not understand why you expect the above to fail.
+test_expect_failure 'push with --repo=repo from tracking branch with good config' ' + + mk_test heads/master && + git config branch.master.remote testrepo && + git push --repo=origin && + check_push_result $the_commit heads/master +'
Likewise. I think the "good/bad config" labels given to your two test scripts are swapped and there is no bug or misfeature here.