git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Fix push with refspecs containing wildcards

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 8, 2007, 07:42 UTC
Message-ID
<7vodjqlwnc.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<7v4pljlzm3.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano <gitster@pobox.com> writes:
Show 9 quoted lines
> 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
Previous: Junio C HamanoNext: Alex Riesen
Message 7 of 8 in “git-send-pack: broken handling of ref specs with wildcards”
  1. Alex RiesenJun 7, 2007
  2. Johannes SchindelinJun 7, 2007
  3. Junio C HamanoJun 8, 2007
  4. Daniel BarkalowJun 8, 2007
  5. Fix push with refspecs containing wildcardsAlex Riesen, Jun 7, 2007
  6. Junio C HamanoJun 8, 2007
  7. Junio C HamanoJun 8, 2007
  8. Alex RiesenJun 8, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.