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

[PATCH 3/6] transport-helper: clarify pushing without refspecs

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Apr 18, 2013, 00:05 UTC
Message-ID
<1366243524-18202-4-git-send-email-felipe.contreras@gmail.com>
In-Reply-To
<1366243524-18202-1-git-send-email-felipe.contreras@gmail.com>

This has never worked, since it's inception the code simply skips all the refs, essentially telling fast-export to do nothing.

Let's at least tell the user what's going on.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 Documentation/gitremote-helpers.txt | 4 ++--
 t/t5801-remote-helpers.sh           | 6 +++---
 transport-helper.c                  | 5 +++--
 3 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/Documentation/gitremote-helpers.txt b/Documentation/gitremote-helpers.txt
index ba7240c..4d26e37 100644
--- a/Documentation/gitremote-helpers.txt
+++ b/Documentation/gitremote-helpers.txt
@@ -162,8 +162,8 @@ Miscellaneous capabilities
 	For remote helpers that implement 'import' or 'export', this capability
 	allows the refs to be constrained to a private namespace, instead of
 	writing to refs/heads or refs/remotes directly.
-	It is recommended that all importers providing the 'import' or 'export'
-	capabilities use this.
+	It is recommended that all importers providing the 'import'
+	capability use this. It's mandatory for 'export'.
 +
 A helper advertising the capability
 `refspec refs/heads/*:refs/svn/origin/branches/*`
diff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh
index cd1873c..3eeb309 100755
--- a/t/t5801-remote-helpers.sh
+++ b/t/t5801-remote-helpers.sh
@@ -111,13 +111,13 @@ test_expect_success 'pulling without refspecs' '
 	compare_refs local2 HEAD server HEAD
 '
 
-test_expect_failure 'pushing without refspecs' '
+test_expect_success 'pushing without refspecs' '
 	test_when_finished "(cd local2 && git reset --hard origin)" &&
 	(cd local2 &&
 	echo content >>file &&
 	git commit -a -m ten &&
-	GIT_REMOTE_TESTGIT_REFSPEC="" git push) &&
-	compare_refs local2 HEAD server HEAD
+	GIT_REMOTE_TESTGIT_REFSPEC="" test_must_fail git push 2> ../error) &&
+	grep "remote-helper doesn.t support push; refspec needed" error
 '
 
 test_expect_success 'pulling without marks' '
diff --git a/transport-helper.c b/transport-helper.c
index cea787c..4d98567 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -785,6 +785,9 @@ static int push_refs_with_export(struct transport *transport,
 	struct string_list revlist_args = STRING_LIST_INIT_NODUP;
 	struct strbuf buf = STRBUF_INIT;
 
+	if (!data->refspecs)
+		die("remote-helper doesn't support push; refspec needed");
+
 	helper = get_helper(transport);
 
 	write_constant(helper->in, "export\n");
@@ -795,8 +798,6 @@ static int push_refs_with_export(struct transport *transport,
 		char *private;
 		unsigned char sha1[20];
 
-		if (!data->refspecs)
-			continue;
 		private = apply_refspecs(data->refspecs, data->refspec_nr, ref->name);
 		if (private && !get_sha1(private, sha1)) {
 			strbuf_addf(&buf, "^%s", private);
-- 
1.8.2.1.679.g509521a
Previous: Felipe ContrerasNext: Sverre Rabbelier
Message 8 of 14 in “transport-helper: some clarifications and a fix”
  1. 0/6 transport-helper: some clarifications and a fixFelipe Contreras, Apr 18, 2013
  2. 1/6 transport-helper: clarify *:* refspecFelipe Contreras, Apr 18, 2013
  3. Thomas RastApr 18, 2013
  4. Felipe ContrerasApr 18, 2013
  5. Thomas RastApr 18, 2013
  6. Felipe ContrerasApr 18, 2013
  7. 2/6 transport-helper: update refspec documentationFelipe Contreras, Apr 18, 2013
  8. 3/6 transport-helper: clarify pushing without refspecsFelipe Contreras, Apr 18, 2013
  9. Sverre RabbelierApr 18, 2013
  10. Stefano LattariniApr 18, 2013
  11. 4/6 transport-helper: warn when refspec is not usedFelipe Contreras, Apr 18, 2013
  12. 5/6 transport-helper: trivial code shuffleFelipe Contreras, Apr 18, 2013
  13. 6/6 transport-helper: update remote helper namespaceFelipe Contreras, Apr 18, 2013
  14. Felipe ContrerasApr 18, 2013

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.