Skip to content

Commit

Permalink
transport-helper: use the new done feature where possible
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Sverre Rabbelier authored and Junio C Hamano committed Jul 19, 2011
1 parent cc56732 commit 1f25c50
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
2 changes: 2 additions & 0 deletions git-remote-testgit.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ def do_import(repo, args):
repo = update_local_repo(repo)
repo.exporter.export_repo(repo.gitdir, args)

print "done"


def do_export(repo, args):
"""Imports a fast-import stream from git to testgit.
Expand Down
9 changes: 2 additions & 7 deletions transport-helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,9 @@ static int get_exporter(struct transport *transport,
/* we need to duplicate helper->in because we want to use it after
* fastexport is done with it. */
fastexport->out = dup(helper->in);
fastexport->argv = xcalloc(4 + revlist_args->nr, sizeof(*fastexport->argv));
fastexport->argv = xcalloc(5 + revlist_args->nr, sizeof(*fastexport->argv));
fastexport->argv[argc++] = "fast-export";
fastexport->argv[argc++] = "--use-done-feature";
if (export_marks)
fastexport->argv[argc++] = export_marks;
if (import_marks)
Expand Down Expand Up @@ -417,11 +418,8 @@ static int fetch_with_import(struct transport *transport,
sendline(data, &buf);
strbuf_reset(&buf);
}
if (disconnect_helper(transport))
die("Error while disconnecting helper");
if (finish_command(&fastimport))
die("Error while running fast-import");

free(fastimport.argv);
fastimport.argv = NULL;

Expand Down Expand Up @@ -764,11 +762,8 @@ static int push_refs_with_export(struct transport *transport,
export_marks, import_marks, &revlist_args))
die("Couldn't run fast-export");

data->no_disconnect_req = 1;
if (finish_command(&exporter))
die("Error while running fast-export");
if (disconnect_helper(transport))
die("Error while disconnecting helper");
return 0;
}

Expand Down

0 comments on commit 1f25c50

Please sign in to comment.