Skip to content

Commit bf70636

Browse files
avargitster
authored andcommitted
push: test that <src> doesn't DWYM if <dst> is unqualified
Add a test asserting that "git push origin <src>:<dst>" where <src> is a branch, tag, tree or blob in refs/remotes/* doesn't DWYM when <dst> is unqualified. This has never been the case, but there haven't been any tests for this behavior. See f88395a ("Renaming push.", 2005-08-03), bb9fca8 ("git-push: Update description of refspecs and add examples", 2007-06-09) and f8aae12 ("push: allow unqualified dest refspecs to DWIM", 2008-04-23) which are most relevant commits that have changed or documented the behavior of the DWYM feature in the past. These tests were originally meant to lead up to a patch that made refs/remotes/* on the LHS imply refs/heads/* on the RHS, see [1]. That patch proved controversial and may not ever land in git.git, but we should have the tests that remind us what the current behavior is in case it's ever changed. 1. https://public-inbox.org/git/[email protected]/ Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent dd8dd30 commit bf70636

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

t/t5505-remote.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,5 +1249,32 @@ test_expect_success 'unqualified <dst> refspec DWIM and advice' '
12491249
)
12501250
'
12511251

1252+
test_expect_success 'refs/remotes/* <src> refspec and unqualified <dst> DWIM and advice' '
1253+
(
1254+
cd two &&
1255+
git tag -a -m "Some tag" my-tag master &&
1256+
git update-ref refs/trees/my-head-tree HEAD^{tree} &&
1257+
git update-ref refs/blobs/my-file-blob HEAD:file
1258+
) &&
1259+
(
1260+
cd test &&
1261+
git config --add remote.two.fetch "+refs/tags/*:refs/remotes/tags-from-two/*" &&
1262+
git config --add remote.two.fetch "+refs/trees/*:refs/remotes/trees-from-two/*" &&
1263+
git config --add remote.two.fetch "+refs/blobs/*:refs/remotes/blobs-from-two/*" &&
1264+
git fetch --no-tags two &&
1265+
1266+
test_must_fail git push origin refs/remotes/two/another:dst 2>err &&
1267+
test_i18ngrep "error: The destination you" err &&
1268+
1269+
test_must_fail git push origin refs/remotes/tags-from-two/my-tag:dst-tag 2>err &&
1270+
test_i18ngrep "error: The destination you" err &&
1271+
1272+
test_must_fail git push origin refs/remotes/trees-from-two/my-head-tree:dst-tree 2>err &&
1273+
test_i18ngrep "error: The destination you" err &&
1274+
1275+
test_must_fail git push origin refs/remotes/blobs-from-two/my-file-blob:dst-blob 2>err &&
1276+
test_i18ngrep "error: The destination you" err
1277+
)
1278+
'
12521279

12531280
test_done

0 commit comments

Comments
 (0)