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

[PATCH 6/9] transport-helper: add support for old:new refspec

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
May 25, 2013, 02:47 UTC
Message-ID
<1369450060-19011-7-git-send-email-felipe.contreras@gmail.com>
In-Reply-To
<1369450060-19011-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>
---
 t/t5801-remote-helpers.sh |  2 +-
 transport-helper.c        | 14 ++++++++++++--
 2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh
index 4899af3..6a7db8b 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 e461764..cc2150f 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -809,7 +809,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)
@@ -844,13 +844,23 @@ static int push_refs_with_export(struct transport *transport,
 		}
 		free(private);
 
-		if (ref->peer_ref)
+		if (ref->peer_ref) {
+			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);
+		}
 	}
 
 	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);
-- 
1.8.3.rc3.312.g47657de
Previous: Eric SunshineNext: Felipe Contreras
Message 8 of 11 in “transport-helper: a bunch of improvements”
  1. 0/9 transport-helper: a bunch of improvementsFelipe Contreras, May 25, 2013
  2. 1/9 transport-helper: check if the dry-run is supportedFelipe Contreras, May 25, 2013
  3. 2/9 transport-helper: add 'force' to 'export' helpersFelipe Contreras, May 25, 2013
  4. 3/9 transport-helper: check for 'forced update' messageFelipe Contreras, May 25, 2013
  5. 4/9 fast-export: improve argument parsingFelipe Contreras, May 25, 2013
  6. 5/9 fast-export: add new --refspec optionFelipe Contreras, May 25, 2013
  7. Eric SunshineMay 25, 2013
  8. 6/9 transport-helper: add support for old:new refspecFelipe Contreras, May 25, 2013
  9. 7/9 fast-import: add support to delete refsFelipe Contreras, May 25, 2013
  10. 8/9 fast-export: add support to delete refsFelipe Contreras, May 25, 2013
  11. 9/9 transport-helper: add support to delete branchesFelipe Contreras, May 25, 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.