Skip to content

Commit 237ffed

Browse files
bmwillgitster
authored andcommitted
http: eliminate "# service" line when using protocol v2
When an http info/refs request is made, requesting that protocol v2 be used, don't send a "# service" line since this line is not part of the v2 spec. Signed-off-by: Brandon Williams <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 884e586 commit 237ffed

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

http-backend.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "url.h"
1111
#include "argv-array.h"
1212
#include "packfile.h"
13+
#include "protocol.h"
1314

1415
static const char content_type[] = "Content-Type";
1516
static const char content_length[] = "Content-Length";
@@ -466,8 +467,11 @@ static void get_info_refs(struct strbuf *hdr, char *arg)
466467
hdr_str(hdr, content_type, buf.buf);
467468
end_headers(hdr);
468469

469-
packet_write_fmt(1, "# service=git-%s\n", svc->name);
470-
packet_flush(1);
470+
471+
if (determine_protocol_version_server() != protocol_v2) {
472+
packet_write_fmt(1, "# service=git-%s\n", svc->name);
473+
packet_flush(1);
474+
}
471475

472476
argv[0] = svc->name;
473477
run_service(argv, 0);

remote-curl.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,9 @@ static struct discovery *discover_refs(const char *service, int for_push)
396396
;
397397

398398
last->proto_git = 1;
399+
} else if (maybe_smart &&
400+
last->len > 5 && starts_with(last->buf + 4, "version 2")) {
401+
last->proto_git = 1;
399402
}
400403

401404
if (last->proto_git)

0 commit comments

Comments
 (0)