Skip to content

Commit 1f25c50

Browse files
SRabbeliergitster
authored andcommitted
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 <[email protected]> Acked-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent cc56732 commit 1f25c50

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

git-remote-testgit.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ def do_import(repo, args):
123123
repo = update_local_repo(repo)
124124
repo.exporter.export_repo(repo.gitdir, args)
125125

126+
print "done"
127+
126128

127129
def do_export(repo, args):
128130
"""Imports a fast-import stream from git to testgit.

transport-helper.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,9 @@ static int get_exporter(struct transport *transport,
380380
/* we need to duplicate helper->in because we want to use it after
381381
* fastexport is done with it. */
382382
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));
384384
fastexport->argv[argc++] = "fast-export";
385+
fastexport->argv[argc++] = "--use-done-feature";
385386
if (export_marks)
386387
fastexport->argv[argc++] = export_marks;
387388
if (import_marks)
@@ -417,11 +418,8 @@ static int fetch_with_import(struct transport *transport,
417418
sendline(data, &buf);
418419
strbuf_reset(&buf);
419420
}
420-
if (disconnect_helper(transport))
421-
die("Error while disconnecting helper");
422421
if (finish_command(&fastimport))
423422
die("Error while running fast-import");
424-
425423
free(fastimport.argv);
426424
fastimport.argv = NULL;
427425

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

767-
data->no_disconnect_req = 1;
768765
if (finish_command(&exporter))
769766
die("Error while running fast-export");
770-
if (disconnect_helper(transport))
771-
die("Error while disconnecting helper");
772767
return 0;
773768
}
774769

0 commit comments

Comments
 (0)