diff mbox series

[v3,6/8] push: test that <src> doesn't DWYM if <dst> is unqualified

Message ID 20181026230741.23321-7-avarab@gmail.com (mailing list archive)
State New, archived
Headers show
Series None | expand

Commit Message

Ævar Arnfjörð Bjarmason Oct. 26, 2018, 11:07 p.m. UTC
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 worked, but there's been no test for
this behavior.

See f88395ac23 ("Renaming push.", 2005-08-03), bb9fca80ce ("git-push:
Update description of refspecs and add examples", 2007-06-09) and
f8aae12034 ("push: allow unqualified dest refspecs to DWIM",
2008-04-23) which are most relevant commits that have changed or
documented the behavior of this feature in the past.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 t/t5505-remote.sh | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

Comments

Junio C Hamano Oct. 29, 2018, 5:19 a.m. UTC | #1
Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:

> 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 worked, but there's been no test for
> this behavior.

"has never worked" sounded as if there is a breakage, but that is
not what meant here.  We didn't DWIM overly agressively (which would
have led us to possibly push into a wrong place) and correctly
rejected the push instead, right?

> +test_expect_success 'refs/remotes/* <src> refspec and unqualified <dst> DWIM and advice' '
> +	(
> +		cd two &&
> +		git tag -a -m "Some tag" some-tag master &&
> +		git update-ref refs/trees/my-head-tree HEAD^{tree} &&
> +		git update-ref refs/blobs/my-file-blob HEAD:file
> +	) &&
> +	(
> +		cd test &&
> +		git config --add remote.two.fetch "+refs/tags/*:refs/remotes/two-tags/*" &&
> +		git config --add remote.two.fetch "+refs/trees/*:refs/remotes/two-trees/*" &&
> +		git config --add remote.two.fetch "+refs/blobs/*:refs/remotes/two-blobs/*" &&
> +		git fetch --no-tags two &&
> +
> +		test_must_fail git push origin refs/remotes/two/another:dst 2>err &&
> +		test_i18ngrep "error: The destination you" err &&
> +
> +		test_must_fail git push origin refs/remotes/two-tags/some-tag:dst-tag 2>err &&

This made me go "Huh?  some-tag is one tag; what is the other tag in
two-tags/ hierarchy?"  I think you meant by "two-tags" a hierarchy
to store tags taken from the remote "two"; calling it "tags-from-two"
may have avoided such a confusion.

> +		test_i18ngrep "error: The destination you" err &&
> +
> +		test_must_fail git push origin refs/remotes/two-trees/my-head-tree:dst-tree 2>err &&
> +		test_i18ngrep "error: The destination you" err &&
> +
> +		test_must_fail git push origin refs/remotes/two-blobs/my-file-blob:dst-blob 2>err &&
> +		test_i18ngrep "error: The destination you" err
> +	)
> +'
> +
>  
>  test_done
diff mbox series

Patch

diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh
index 2e58721f98..979a13b415 100755
--- a/t/t5505-remote.sh
+++ b/t/t5505-remote.sh
@@ -1246,5 +1246,33 @@  test_expect_success 'unqualified <dst> refspec DWIM and advice' '
 	)
 '
 
+test_expect_success 'refs/remotes/* <src> refspec and unqualified <dst> DWIM and advice' '
+	(
+		cd two &&
+		git tag -a -m "Some tag" some-tag master &&
+		git update-ref refs/trees/my-head-tree HEAD^{tree} &&
+		git update-ref refs/blobs/my-file-blob HEAD:file
+	) &&
+	(
+		cd test &&
+		git config --add remote.two.fetch "+refs/tags/*:refs/remotes/two-tags/*" &&
+		git config --add remote.two.fetch "+refs/trees/*:refs/remotes/two-trees/*" &&
+		git config --add remote.two.fetch "+refs/blobs/*:refs/remotes/two-blobs/*" &&
+		git fetch --no-tags two &&
+
+		test_must_fail git push origin refs/remotes/two/another:dst 2>err &&
+		test_i18ngrep "error: The destination you" err &&
+
+		test_must_fail git push origin refs/remotes/two-tags/some-tag:dst-tag 2>err &&
+		test_i18ngrep "error: The destination you" err &&
+
+		test_must_fail git push origin refs/remotes/two-trees/my-head-tree:dst-tree 2>err &&
+		test_i18ngrep "error: The destination you" err &&
+
+		test_must_fail git push origin refs/remotes/two-blobs/my-file-blob:dst-blob 2>err &&
+		test_i18ngrep "error: The destination you" err
+	)
+'
+
 
 test_done