transport-helper: use the new done feature where possible

In other words, use fast-export --use-done-feature to add a 'done' command at the end of streams passed to remote helpers' "import" commands, and teach the remote helpers implementing "export" to use the 'done' command in turn when producing their streams. The trailing \n in the protocol signals the helper that the connection is about to close, allowing it to do whatever cleanup neccesary. Previously, the connection would already be closed by the time the trailing \n was to be written. Now that the remote-helper protocol uses the new done command in its fast-import streams, this is no longer the case and we can safely write the trailing \n. Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com> Acked-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Sverre Rabbelier committed Jul 16, 2011 at 15:03 UTC 1f25c50419c5f46cd6b818438fe641cf942ee6ad
2 files changed +4 -7
git-remote-testgit.py
+2
@@ -123,6 +123,8 @@ def do_import(repo, args):
123 repo = update_local_repo(repo)
124 repo.exporter.export_repo(repo.gitdir, args)
125
126 + print "done"
127 +
128
129 def do_export(repo, args):
130 """Imports a fast-import stream from git to testgit.
transport-helper.c
+2 -7
@@ -380,8 +380,9 @@ static int get_exporter(struct transport *transport,
380 /* we need to duplicate helper->in because we want to use it after
381 * fastexport is done with it. */
382 fastexport->out = dup(helper->in);
383 - fastexport->argv = xcalloc(4 + revlist_args->nr, sizeof(*fastexport->argv));
383 + fastexport->argv = xcalloc(5 + revlist_args->nr, sizeof(*fastexport->argv));
384 fastexport->argv[argc++] = "fast-export";
385 + fastexport->argv[argc++] = "--use-done-feature";
386 if (export_marks)
387 fastexport->argv[argc++] = export_marks;
388 if (import_marks)
@@ -417,11 +418,8 @@ static int fetch_with_import(struct transport *transport,
418 sendline(data, &buf);
419 strbuf_reset(&buf);
420 }
420 - if (disconnect_helper(transport))
421 - die("Error while disconnecting helper");
421 if (finish_command(&fastimport))
422 die("Error while running fast-import");
424 -
423 free(fastimport.argv);
424 fastimport.argv = NULL;
425
@@ -764,11 +762,8 @@ static int push_refs_with_export(struct transport *transport,
762 export_marks, import_marks, &revlist_args))
763 die("Couldn't run fast-export");
764
767 - data->no_disconnect_req = 1;
765 if (finish_command(&exporter))
766 die("Error while running fast-export");
770 - if (disconnect_helper(transport))
771 - die("Error while disconnecting helper");
767 return 0;
768 }
769