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

[PATCH 10/19] Allow helpers to request marks for fast-import

From
Sverre Rabbelier <srabbelier@gmail.com>
Date
Oct 29, 2009, 18:01 UTC
Message-ID
<1256839287-19016-11-git-send-email-srabbelier@gmail.com>
In-Reply-To
<1256839287-19016-1-git-send-email-srabbelier@gmail.com>
From: Johan Herland <johan@herland.net>

The 'marks' capability is reported by the remote helper if it requires the fast-import marks database to loaded/saved by any git-fast-import process that is provided by the transport machinery. The feature is advertised along with exactly one argument: the location of the file containing the marks database.

Signed-off-by: Johan Herland <johan@herland.net>
Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
---
	Unchanged.
 Documentation/git-remote-helpers.txt |    8 ++++++++
 transport-helper.c                   |   15 +++++++++++++++
 2 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/Documentation/git-remote-helpers.txt b/Documentation/git-remote-helpers.txt
index 2c5130f..9a3c5bc 100644
--- a/Documentation/git-remote-helpers.txt
+++ b/Documentation/git-remote-helpers.txt
@@ -67,6 +67,14 @@ CAPABILITIES
 'import'::
 	This helper supports the 'import' command.
 
+'marks' filename::
+	Helper requires the marks from a git-fast-import run to be
+	loaded from, and saved to, the given filename. When this
+	"feature" is advertised, each git-fast-import run must load
+	and save the internal marks database (see the --import-marks
+	and --export-marks option to git-fast-import for more details)
+	located at the given filename.
+
 REF LIST ATTRIBUTES
 -------------------
 
diff --git a/transport-helper.c b/transport-helper.c
index 36a265d..cd3f0df 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -10,6 +10,7 @@ struct helper_data
 {
 	const char *name;
 	struct child_process *helper;
+	char *marks_filename;
 	unsigned fetch : 1;
 	unsigned import : 1;
 };
@@ -51,6 +52,8 @@ static struct child_process *get_helper(struct transport *transport)
 			data->fetch = 1;
 		if (!strcmp(buf.buf, "import"))
 			data->import = 1;
+		if (!prefixcmp(buf.buf, "marks "))
+			data->marks_filename = xstrdup(buf.buf + 6);
 	}
 	return data->helper;
 }
@@ -104,11 +107,21 @@ static int fetch_with_fetch(struct transport *transport,
 static int get_importer(struct transport *transport, struct child_process *fastimport)
 {
 	struct child_process *helper = get_helper(transport);
+	struct helper_data *data = transport->data;
 	memset(fastimport, 0, sizeof(*fastimport));
 	fastimport->in = helper->out;
 	fastimport->argv = xcalloc(5, sizeof(*fastimport->argv));
 	fastimport->argv[0] = "fast-import";
 	fastimport->argv[1] = "--quiet";
+	if (data->marks_filename) {
+		struct strbuf buf = STRBUF_INIT;
+		strbuf_addf(&buf, "--export-marks=%s", data->marks_filename);
+		fastimport->argv[2] = strbuf_detach(&buf, 0);
+		if (!access(data->marks_filename, R_OK)) {
+			strbuf_addf(&buf, "--import-marks=%s", data->marks_filename);
+			fastimport->argv[3] = strbuf_detach(&buf, 0);
+		}
+	}
 
 	fastimport->git_cmd = 1;
 	return start_command(fastimport);
@@ -137,6 +150,8 @@ static int fetch_with_import(struct transport *transport,
 	}
 	disconnect_helper(transport);
 	finish_command(&fastimport);
+	free((char *) fastimport.argv[2]);
+	free((char *) fastimport.argv[3]);
 
 	for (i = 0; i < nr_heads; i++) {
 		posn = to_fetch[i];
-- 
1.6.5.2.291.gf76a3
Previous: Sverre RabbelierNext: Johan Herland
Message 24 of 43 in “Reroll of the remote-vcs-helper series”
  1. 0/19 Reroll of the remote-vcs-helper seriesSverre Rabbelier, Oct 29, 2009
  2. 01/19 Use a function to determine whether a remote is validSverre Rabbelier, Oct 29, 2009
  3. 02/19 Allow fetch to modify refsSverre Rabbelier, Oct 29, 2009
  4. Daniel BarkalowOct 30, 2009
  5. Sverre RabbelierOct 30, 2009
  6. Daniel BarkalowOct 30, 2009
  7. Sverre RabbelierOct 30, 2009
  8. 03/19 Allow programs to not depend on remotes having urlsSverre Rabbelier, Oct 29, 2009
  9. Daniel BarkalowOct 30, 2009
  10. Sverre RabbelierOct 30, 2009
  11. 04/19 Add a config option for remotes to specify a foreign vcsSverre Rabbelier, Oct 29, 2009
  12. 05/19 Add support for "import" helper commandSverre Rabbelier, Oct 29, 2009
  13. 06/19 Factor ref updating out of fetch_with_importSverre Rabbelier, Oct 29, 2009
  14. Daniel BarkalowOct 30, 2009
  15. Sverre RabbelierOct 30, 2009
  16. Daniel BarkalowOct 30, 2009
  17. Sverre RabbelierNov 2, 2009
  18. Daniel BarkalowNov 2, 2009
  19. Sverre RabbelierNov 2, 2009
  20. Daniel BarkalowNov 2, 2009
  21. 07/19 Allow helpers to report in "list" command that the ref is unchangedSverre Rabbelier, Oct 29, 2009
  22. 08/19 Fix memory leak in helper method for disconnectSverre Rabbelier, Oct 29, 2009
  23. 09/19 Finally make remote helper support usefulSverre Rabbelier, Oct 29, 2009
  24. 10/19 Allow helpers to request marks for fast-importSverre Rabbelier, Oct 29, 2009
  25. Johan HerlandOct 30, 2009
  26. Sverre RabbelierOct 30, 2009
  27. Johan HerlandOct 31, 2009
  28. Sverre RabbelierOct 31, 2009
  29. 11/19 Basic build infrastructure for Python scriptsSverre Rabbelier, Oct 29, 2009
  30. 12/19 1/2: Add Python support library for CVS remote helperSverre Rabbelier, Oct 29, 2009
  31. Johan HerlandOct 30, 2009
  32. Sverre RabbelierOct 30, 2009
  33. 13/19 2/2: Add Python support library for CVS remote helperSverre Rabbelier, Oct 29, 2009
  34. 14/19 git-remote-cvs: Remote helper program for CVS repositoriesSverre Rabbelier, Oct 29, 2009
  35. 15/19 Add simple selftests of git-remote-cvs functionalitySverre Rabbelier, Oct 29, 2009
  36. 16/19 Fix the Makefile-generated path to the git_remote_cvs package in git-remote-cvsSverre Rabbelier, Oct 29, 2009
  37. 17/19 More fixes to the git-remote-cvs installation procedureSverre Rabbelier, Oct 29, 2009
  38. 18/19 Refactor git_remote_cvs to a more generic git_remote_helpersSverre Rabbelier, Oct 29, 2009
  39. Johan HerlandOct 30, 2009
  40. Sverre RabbelierOct 30, 2009
  41. 19/19 .gitignore: add git-remote-cvsSverre Rabbelier, Oct 29, 2009
  42. Shawn O. PearceOct 29, 2009
  43. Sverre RabbelierOct 29, 2009

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.