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

[PATCH 3/8] transport-helper: add support for old:new refspec

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Apr 20, 2014, 18:59 UTC
Message-ID
<1398020370-11406-4-git-send-email-felipe.contreras@gmail.com>
In-Reply-To
<1398020370-11406-1-git-send-email-felipe.contreras@gmail.com>
By using fast-export's new --refspec option.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 t/t5801-remote-helpers.sh |  2 +-
 transport-helper.c        | 13 ++++++++++---
 2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh
index 25fd2e7..52b3c99 100755
--- a/t/t5801-remote-helpers.sh
+++ b/t/t5801-remote-helpers.sh
@@ -87,7 +87,7 @@ test_expect_success 'push new branch by name' '
 	compare_refs local HEAD server refs/heads/new-name
 '
 
-test_expect_failure 'push new branch with old:new refspec' '
+test_expect_success 'push new branch with old:new refspec' '
 	(cd local &&
 	 git push origin new-name:new-refspec
 	) &&
diff --git a/transport-helper.c b/transport-helper.c
index 86e1679..3f45c47 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -856,7 +856,7 @@ static int push_refs_with_export(struct transport *transport,
 	struct ref *ref;
 	struct child_process *helper, exporter;
 	struct helper_data *data = transport->data;
-	struct string_list revlist_args = STRING_LIST_INIT_NODUP;
+	struct string_list revlist_args = STRING_LIST_INIT_DUP;
 	struct strbuf buf = STRBUF_INIT;
 
 	if (!data->refspecs)
@@ -894,8 +894,13 @@ static int push_refs_with_export(struct transport *transport,
 		free(private);
 
 		if (ref->peer_ref) {
-			if (strcmp(ref->peer_ref->name, ref->name))
-				die("remote-helpers do not support old:new syntax");
+			if (strcmp(ref->name, ref->peer_ref->name)) {
+				struct strbuf buf = STRBUF_INIT;
+				strbuf_addf(&buf, "%s:%s", ref->peer_ref->name, ref->name);
+				string_list_append(&revlist_args, "--refspec");
+				string_list_append(&revlist_args, buf.buf);
+				strbuf_release(&buf);
+			}
 			string_list_append(&revlist_args, ref->peer_ref->name);
 		}
 	}
@@ -903,6 +908,8 @@ static int push_refs_with_export(struct transport *transport,
 	if (get_exporter(transport, &exporter, &revlist_args))
 		die("Couldn't run fast-export");
 
+	string_list_clear(&revlist_args, 1);
+
 	if (finish_command(&exporter))
 		die("Error while running fast-export");
 	push_update_refs_status(data, remote_refs, flags);
-- 
1.9.1+fc3.9.gc73078e
Previous: Felipe ContrerasNext: Felipe Contreras
Message 4 of 9 in “transport-helper: refspec support”
  1. 0/8 transport-helper: refspec supportFelipe Contreras, Apr 20, 2014
  2. 1/8 fast-export: improve argument parsingFelipe Contreras, Apr 20, 2014
  3. 2/8 fast-export: add new --refspec optionFelipe Contreras, Apr 20, 2014
  4. 3/8 transport-helper: add support for old:new refspecFelipe Contreras, Apr 20, 2014
  5. 4/8 transport-helper: add support to push symbolic refsFelipe Contreras, Apr 20, 2014
  6. 5/8 fast-import: add support to delete refsFelipe Contreras, Apr 20, 2014
  7. 6/8 fast-export: add support to delete refsFelipe Contreras, Apr 20, 2014
  8. 7/8 transport-helper: add support to delete branchesFelipe Contreras, Apr 20, 2014
  9. 8/8 transport-helper: remove unnecessary strbuf resetsFelipe Contreras, Apr 20, 2014

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.