Teach a client to recognize that a server understands protocol v1 by
looking at the first pkt-line the server sends in response. This is
done by looking for the response "version 1" send by upload-pack or
receive-pack.
Signed-off-by: Brandon Williams <redacted>
---
connect.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/connect.c b/connect.c
index 49b28b83b..2702e1f2e 100644
--- a/connect.c
+++ b/connect.c
@@ -11,6 +11,7 @@
#include "string-list.h"
#include "sha1-array.h"
#include "transport.h"
+#include "protocol.h"
static char *server_capabilities;
static const char *parse_feature_value(const char *, const char *, int *);
@@ -142,6 +143,27 @@ struct ref **get_remote_heads(int in, char *src_buf, size_t src_len,
if (len < 0)
die_initial_contact(saw_response);
+ /* Only check for version information on first response */
+ if (!saw_response) {
+ switch (determine_protocol_version_client(buffer)) {
+ case protocol_v1:
+ /*
+ * First pkt-line contained the version string.
+ * Continue on to process the ref advertisement.
+ */
+ continue;
+ case protocol_v0:
+ /*
+ * Server is speaking protocol v0 and sent a
+ * ref so we need to process it.
+ */
+ break;
+ default:
+ die("server is speaking an unknown protocol");
+ break;
+ }
+ }
+
if (!len)
break;
--
2.14.1.690.gbb1197296e-goog