Re: [PATCH] Fix push with refspecs containing wildcards

Subsystems: the rest

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH] Fix push with refspecs containing wildcards

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:43:14

Junio C Hamano [off-list ref] writes:
Sending a fix is a good thing, but whenever doing one, could
people please also do a testcase that demonstrates the original
bug, and also a demonstration that the fix does not introduce
regression?

For this one, obviously a test for push that uses such wildcard
ref is needed but at the same time we would want a test for push
that does _not_ use a wildcard, fetch that uses a wildcard, and
a fetch that does not use a wildcard.
How about this?
---

 t/t5516-fetch-push.sh |   82 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 82 insertions(+), 0 deletions(-)
diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
new file mode 100755
index 0000000..dba018f
--- /dev/null
+++ b/t/t5516-fetch-push.sh
@@ -0,0 +1,80 @@
+#!/bin/sh
+
+test_description='fetching and pushing, with or without wildcard'
+
+. ./test-lib.sh
+
+mk_empty () {
+	rm -fr testrepo &&
+	mkdir testrepo &&
+	(
+		cd testrepo &&
+		git init
+	)
+}
+
+test_expect_success setup '
+
+	: >path1 &&
+	git add path1 &&
+	test_tick &&
+	git commit -a -m repo &&
+	the_commit=$(git show-ref -s --verify refs/heads/master)
+
+'
+
+test_expect_success 'fetch without wildcard' '
+	mk_empty &&
+	(
+		cd testrepo &&
+		git fetch .. refs/heads/master:refs/remotes/origin/master &&
+
+		r=$(git show-ref -s --verify refs/remotes/origin/master) &&
+		test "z$r" = "z$the_commit" &&
+
+		test 1 = $(git for-each-ref refs/remotes/origin | wc -l)
+	)
+'
+
+test_expect_success 'fetch with wildcard' '
+	mk_empty &&
+	(
+		cd testrepo &&
+		git config remote.up.url .. &&
+		git config remote.up.fetch "refs/heads/*:refs/remotes/origin/*" &&
+		git fetch up &&
+
+		r=$(git show-ref -s --verify refs/remotes/origin/master) &&
+		test "z$r" = "z$the_commit" &&
+
+		test 1 = $(git for-each-ref refs/remotes/origin | wc -l)
+	)
+'
+
+test_expect_success 'push without wildcard' '
+	mk_empty &&
+
+	git push testrepo refs/heads/master:refs/remotes/origin/master &&
+	(
+		cd testrepo &&
+		r=$(git show-ref -s --verify refs/remotes/origin/master) &&
+		test "z$r" = "z$the_commit" &&
+
+		test 1 = $(git for-each-ref refs/remotes/origin | wc -l)
+	)
+'
+
+test_expect_success 'push with wildcard' '
+	mk_empty &&
+
+	git push testrepo "refs/heads/*:refs/remotes/origin/*" &&
+	(
+		cd testrepo &&
+		r=$(git show-ref -s --verify refs/remotes/origin/master) &&
+		test "z$r" = "z$the_commit" &&
+
+		test 1 = $(git for-each-ref refs/remotes/origin | wc -l)
+	)
+'
+
+test_done

Re: [PATCH] Fix push with refspecs containing wildcards

From: Alex Riesen <hidden>
Date: 2016-06-15 22:43:14

Junio C Hamano, Fri, Jun 08, 2007 09:42:47 +0200:
Junio C Hamano [off-list ref] writes:
quoted
Sending a fix is a good thing, but whenever doing one, could
people please also do a testcase that demonstrates the original
bug, and also a demonstration that the fix does not introduce
regression?
Sorry. I actually have a test script I used to develop the fix,
but somehow missed to send it.
quoted
For this one, obviously a test for push that uses such wildcard
ref is needed but at the same time we would want a test for push
that does _not_ use a wildcard, fetch that uses a wildcard, and
a fetch that does not use a wildcard.
How about this?
---

 t/t5516-fetch-push.sh |   82 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 82 insertions(+), 0 deletions(-)
Gratefully-Acked-by: Alex Riesen [off-list ref]
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help