Skip to content

Commit f339894

Browse files
committed
Merge branch 'jt/fetch-pack-v2'
"git fetch-pack" now can talk the version 2 protocol. * jt/fetch-pack-v2: fetch-pack: support protocol version 2
2 parents d3b0178 + 4316ff3 commit f339894

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

builtin/fetch-pack.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
5555
struct oid_array shallow = OID_ARRAY_INIT;
5656
struct string_list deepen_not = STRING_LIST_INIT_DUP;
5757
struct packet_reader reader;
58+
enum protocol_version version;
5859

5960
fetch_if_missing = 0;
6061

@@ -219,9 +220,11 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
219220
PACKET_READ_CHOMP_NEWLINE |
220221
PACKET_READ_GENTLE_ON_EOF);
221222

222-
switch (discover_version(&reader)) {
223+
version = discover_version(&reader);
224+
switch (version) {
223225
case protocol_v2:
224-
die("support for protocol v2 not implemented yet");
226+
get_remote_refs(fd[1], &reader, &ref, 0, NULL, NULL);
227+
break;
225228
case protocol_v1:
226229
case protocol_v0:
227230
get_remote_heads(&reader, &ref, 0, NULL, &shallow);
@@ -231,7 +234,7 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
231234
}
232235

233236
ref = fetch_pack(&args, fd, conn, ref, dest, sought, nr_sought,
234-
&shallow, pack_lockfile_ptr, protocol_v0);
237+
&shallow, pack_lockfile_ptr, version);
235238
if (pack_lockfile) {
236239
printf("lock %s\n", pack_lockfile);
237240
fflush(stdout);

t/t5500-fetch-pack.sh

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -439,15 +439,23 @@ test_expect_success 'setup tests for the --stdin parameter' '
439439
) >input.dup
440440
'
441441

442-
test_expect_success 'fetch refs from cmdline' '
443-
(
444-
cd client &&
445-
git fetch-pack --no-progress .. $(cat ../input)
446-
) >output &&
447-
cut -d " " -f 2 <output | sort >actual &&
448-
test_cmp expect actual
442+
test_expect_success 'setup fetch refs from cmdline v[12]' '
443+
cp -r client client1 &&
444+
cp -r client client2
449445
'
450446

447+
for version in '' 1 2
448+
do
449+
test_expect_success "protocol.version=$version fetch refs from cmdline" "
450+
(
451+
cd client$version &&
452+
GIT_TEST_PROTOCOL_VERSION=$version git fetch-pack --no-progress .. \$(cat ../input)
453+
) >output &&
454+
cut -d ' ' -f 2 <output | sort >actual &&
455+
test_cmp expect actual
456+
"
457+
done
458+
451459
test_expect_success 'fetch refs from stdin' '
452460
(
453461
cd client &&

0 commit comments

Comments
 (0)