summaryrefslogtreecommitdiff
path: root/t/helper
diff options
context:
space:
mode:
authorJiang Xin <worldhello.net@gmail.com>2020-11-11 11:32:02 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-11-11 20:46:56 (GMT)
commit80ffeb94f4c9eae4e099fec47e39105fc1e19132 (patch)
treec2f5ac59cee627ff251ce1fc09da78e17824c255 /t/helper
parentf65003b4c4abea49a00cc9f3d87b9f37db6b48f1 (diff)
downloadgit-80ffeb94f4c9eae4e099fec47e39105fc1e19132.zip
git-80ffeb94f4c9eae4e099fec47e39105fc1e19132.tar.gz
git-80ffeb94f4c9eae4e099fec47e39105fc1e19132.tar.bz2
receive-pack: use default version 0 for proc-receive
In the verison negotiation phase between "receive-pack" and "proc-receive", "proc-receive" can send an empty flush-pkt to end the negotiation and use default version 0. Capabilities (such as "push-options") are not supported in version 0. Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/helper')
-rw-r--r--t/helper/test-proc-receive.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/t/helper/test-proc-receive.c b/t/helper/test-proc-receive.c
index 6652ced..cc08506 100644
--- a/t/helper/test-proc-receive.c
+++ b/t/helper/test-proc-receive.c
@@ -45,8 +45,14 @@ static void proc_receive_verison(struct packet_reader *reader) {
if (packet_reader_read(reader) != PACKET_READ_NORMAL)
break;
+ /* Ignore version negotiation for version 0 */
+ if (version == 0)
+ continue;
+
if (reader->pktlen > 8 && starts_with(reader->line, "version=")) {
server_version = atoi(reader->line+8);
+ if (server_version != 1)
+ die("bad protocol version: %d", server_version);
linelen = strlen(reader->line);
if (linelen < reader->pktlen) {
const char *feature_list = reader->line + linelen + 1;
@@ -58,15 +64,13 @@ static void proc_receive_verison(struct packet_reader *reader) {
}
}
- if (server_version != 1)
- die("bad protocol version: %d", server_version);
-
if (die_write_version)
die("die with the --die-write-version option");
- packet_write_fmt(1, "version=%d%c%s\n",
- version, '\0',
- use_push_options && !no_push_options ? "push-options": "");
+ if (version != 0)
+ packet_write_fmt(1, "version=%d%c%s\n",
+ version, '\0',
+ use_push_options && !no_push_options ? "push-options": "");
packet_flush(1);
}