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 <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Brandon Williams committed
Mar 15, 2018 at 10:31 UTC
237ffedd46098a5b8a303cfbac7ecb0ff3a8a7a7
2 files changed
+9
-2
http-backend.c
+6
-2
@@ -10,6 +10,7 @@
10
#include "url.h"
11
#include "argv-array.h"
12
#include "packfile.h"
13
+#include "protocol.h"
14
15
static const char content_type[] = "Content-Type";
16
static const char content_length[] = "Content-Length";
@@ -466,8 +467,11 @@ static void get_info_refs(struct strbuf *hdr, char *arg)
467
hdr_str(hdr, content_type, buf.buf);
468
end_headers(hdr);
469
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
+ }
475
476
argv[0] = svc->name;
477
run_service(argv, 0);
remote-curl.c
+3
@@ -396,6 +396,9 @@ static struct discovery *discover_refs(const char *service, int for_push)
396
;
397
398
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;
402
}
403
404
if (last->proto_git)