[PATCH 02/15] t5516: demonstrate push with "./"-prefixed source
- From
Jon Simons <jon@jonsimons.org>
- Date
- Oct 9, 2026, 19:29 UTC
- Message-ID
- <20261009192953.81794-3-jon@jonsimons.org>
- In-Reply-To
- <20261009192953.81794-1-jon@jonsimons.org>
'git push <repo> ./refs/heads/main:refs/heads/frotz' succeeds today and pushes refs/heads/main, although "./refs/heads/main" is not a valid refname. count_refspec_match() compares the source to each local ref using refname_match(), which formats its given name with mkpath(), whose cleanup_path() strips leading "./".
Add a test_expect_failure asserting that such a source is rejected with "src refspec ./refs/heads/main does not match any". An upcoming commit stops using mkpath() in refname_match(), at which point the test is toggled to test_expect_success.
Signed-off-by: Jon Simons <jon@jonsimons.org> --- t/t5516-fetch-push.sh | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh index b982b209bf..aaeb251e2f 100755 --- a/t/t5516-fetch-push.sh +++ b/t/t5516-fetch-push.sh @@ -433,6 +433,12 @@ test_expect_success 'push with onelevel ref' ' test_must_fail git push testrepo HEAD:refs/onelevel ' +test_expect_failure 'push with "./"-prefixed src does not match any ref' ' + mk_test testrepo heads/main && + test_must_fail git push testrepo ./refs/heads/main:refs/heads/frotz 2>err && + test_grep "src refspec ./refs/heads/main does not match any" err +' + test_expect_success 'push with colon-less refspec (1)' ' mk_test testrepo heads/frotz tags/frotz && git branch -f frotz main &&
-- 2.55.0