Skip to content

Commit 9504bc9

Browse files
SRabbeliergitster
authored andcommitted
transport-helper: change import semantics
Currently the helper must somehow guess how many import statements to read before it starts outputting its fast-export stream. This is because the remote helper infrastructure runs fast-import only once, so the helper is forced to output one stream for all import commands it will receive. The only reason this worked in the past was because only one ref was imported at a time. Change the semantics of the import statement such that it matches that of the push statement. That is, the import statement is followed by a series of import statements that are terminated by a '\n'. Signed-off-by: Sverre Rabbelier <[email protected]> Acked-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6c8151a commit 9504bc9

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

git-remote-testgit.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,22 @@ def do_import(repo, args):
120120
if not repo.gitdir:
121121
die("Need gitdir to import")
122122

123+
ref = args[0]
124+
refs = [ref]
125+
126+
while True:
127+
line = sys.stdin.readline()
128+
if line == '\n':
129+
break
130+
if not line.startswith('import '):
131+
die("Expected import line.")
132+
133+
# strip of leading 'import '
134+
ref = line[7:].strip()
135+
refs.append(ref)
136+
123137
repo = update_local_repo(repo)
124-
repo.exporter.export_repo(repo.gitdir, args)
138+
repo.exporter.export_repo(repo.gitdir, refs)
125139

126140
print "done"
127141

t/t5800-remote-helpers.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ test_expect_success 'fetch new branch' '
9898
compare_refs public HEAD localclone FETCH_HEAD
9999
'
100100

101-
test_expect_failure 'fetch multiple branches' '
101+
test_expect_success 'fetch multiple branches' '
102102
(cd localclone &&
103103
git fetch
104104
) &&

transport-helper.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,9 @@ static int fetch_with_import(struct transport *transport,
418418
sendline(data, &buf);
419419
strbuf_reset(&buf);
420420
}
421+
422+
write_constant(data->helper->in, "\n");
423+
421424
if (finish_command(&fastimport))
422425
die("Error while running fast-import");
423426
free(fastimport.argv);

0 commit comments

Comments
 (0)