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

Re: Getting a commit sha1 from fast-import in a remote-helper

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Nov 18, 2014, 03:27 UTC
Message-ID
<20141118032740.GJ4336@google.com>
In-Reply-To
<20141118023520.GB14034@glandium.org>
Mike Hommey wrote:
> And while I'm here, it's sad that one needs to emit a dummy cat-blob or
> ls command to wait for a checkpoint to be finished

That's a good point. (Though relying on checkpoints to read back information is an ugly trick, so if we can get other commands to provide the information you need then that would be better.)

The old-fashioned way is to do "progress checkpoint done". Alas, that writes to the progress fd, which doesn't go to the remote helper's stdin. How about something like this?

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
diff --git i/Documentation/git-fast-import.txt w/Documentation/git-fast-import.txt
index 377eeaa..c0dedac 100644
--- i/Documentation/git-fast-import.txt
+++ w/Documentation/git-fast-import.txt
@@ -1055,6 +1055,12 @@ ls::
 	rather than wasting time on the early part of an import
 	before the unsupported command is detected.
 
+notify-on-checkpoint::
+	Cause the backend to write `checkpoint complete` to the file
+	descriptor set with `--cat-blob-fd`, or to `stdout` if
+	`--cat-blob-fd` was unspecified, when finishing a checkpoint
+	requested via a `checkpoint` command or SIGUSR1.
+
 notes::
 	Require that the backend support the 'notemodify' (N)
 	subcommand to the 'commit' command.
diff --git i/fast-import.c w/fast-import.c
index d0bd285..ccf4768 100644
--- i/fast-import.c
+++ w/fast-import.c
@@ -329,6 +329,7 @@ static const char *import_marks_file;
 static int import_marks_file_from_stream;
 static int import_marks_file_ignore_missing;
 static int relative_marks_paths;
+static int notify_on_checkpoint;
 
 /* Our last blob */
 static struct last_object last_blob = { STRBUF_INIT, 0, 0, 0 };
@@ -3094,6 +3095,9 @@ static void checkpoint(void)
 		dump_tags();
 		dump_marks();
 	}
+	if (notify_on_checkpoint)
+		cat_blob_write("checkpoint complete\n",
+			       strlen("checkpoint complete\n"));
 }
 
 static void parse_checkpoint(void)
@@ -3244,6 +3248,8 @@ static int parse_one_feature(const char *feature, int from_stream)
 		option_export_marks(arg);
 	} else if (!strcmp(feature, "cat-blob")) {
 		; /* Don't die - this feature is supported */
+	} else if (!strcmp(feature, "notify-on-checkpoint")) {
+		notify_on_checkpoint = 1;
 	} else if (!strcmp(feature, "relative-marks")) {
 		relative_marks_paths = 1;
 	} else if (!strcmp(feature, "no-relative-marks")) {
Previous: Mike HommeyNext: Mike Hommey
Message 12 of 15 in “Getting a commit sha1 from fast-import in a remote-helper”
  1. Mike HommeyNov 18, 2014
  2. Jonathan NiederNov 18, 2014
  3. Mike HommeyNov 18, 2014
  4. Jonathan NiederNov 18, 2014
  5. Mike HommeyNov 18, 2014
  6. Mike HommeyNov 19, 2014
  7. Jonathan NiederNov 19, 2014
  8. Mike HommeyNov 19, 2014
  9. Jonathan NiederNov 19, 2014
  10. Mike HommeyNov 18, 2014
  11. Mike HommeyNov 18, 2014
  12. Jonathan NiederNov 18, 2014
  13. Mike HommeyNov 18, 2014
  14. Jonathan NiederNov 18, 2014
  15. Mike HommeyNov 18, 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.