path: root/fast-import.c
diff options
authorShawn O. Pearce <>2007-08-01 14:23:08 (GMT)
committerShawn O. Pearce <>2007-08-19 07:38:36 (GMT)
commitac053c02029d88c7ed4d7e92949a1586eb3f7704 (patch)
tree84e5e58df838e7f27d8cee33cb1fae6d0f7b6917 /fast-import.c
parent1fdb649c6ac4cfc536983077b4851a1959cbc1c4 (diff)
Allow frontends to bidirectionally communicate with fast-import
The existing checkpoint command is very useful to force fast-import to dump the branches out to disk so that standard Git tools can access them and the objects they refer to. However there was not a way to know when fast-import had finished executing the checkpoint and it was safe to read those refs. The progress command can be used to make fast-import output any message of the frontend's choosing to standard out. The frontend can scan for these messages using select() or poll() to monitor a pipe connected to the standard output of fast-import. Signed-off-by: Shawn O. Pearce <>
Diffstat (limited to 'fast-import.c')
1 files changed, 14 insertions, 0 deletions
diff --git a/fast-import.c b/fast-import.c
index 4bc7f81..429ab49 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -8,6 +8,7 @@ Format of STDIN stream:
| new_tag
| reset_branch
| checkpoint
+ | progress
new_blob ::= 'blob' lf
@@ -53,6 +54,9 @@ Format of STDIN stream:
checkpoint ::= 'checkpoint' lf
+ progress ::= 'progress' sp not_lf* lf
+ lf?;
# note: the first idnum in a stream should be 1 and subsequent
# idnums should not have gaps between values as this will cause
# the stream parser to reserve space for the gapped values. An
@@ -2125,6 +2129,14 @@ static void cmd_checkpoint(void)
+static void cmd_progress(void)
+ fwrite(command_buf.buf, 1, command_buf.len - 1, stdout);
+ fputc('\n', stdout);
+ fflush(stdout);
+ skip_optional_lf();
static void import_marks(const char *input_file)
char line[512];
@@ -2235,6 +2247,8 @@ int main(int argc, const char **argv)
else if (!strcmp("checkpoint", command_buf.buf))
+ else if (!prefixcmp(command_buf.buf, "progress "))
+ cmd_progress();
die("Unsupported command: %s", command_buf.buf);