diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2007-08-01 10:23:08 -0400 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2007-08-19 03:38:36 -0400 |
commit | ac053c02029d88c7ed4d7e92949a1586eb3f7704 (patch) | |
tree | 84e5e58df838e7f27d8cee33cb1fae6d0f7b6917 /fast-import.c | |
parent | 1fdb649c6ac4cfc536983077b4851a1959cbc1c4 (diff) | |
download | git-ac053c02029d88c7ed4d7e92949a1586eb3f7704.tar.gz git-ac053c02029d88c7ed4d7e92949a1586eb3f7704.tar.xz |
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 <spearce@spearce.org>
Diffstat (limited to 'fast-import.c')
-rw-r--r-- | fast-import.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/fast-import.c b/fast-import.c index 4bc7f81bc..429ab491b 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 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) skip_optional_lf(); } +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) cmd_reset_branch(); else if (!strcmp("checkpoint", command_buf.buf)) cmd_checkpoint(); + else if (!prefixcmp(command_buf.buf, "progress ")) + cmd_progress(); else die("Unsupported command: %s", command_buf.buf); } |