wt-status.h: drop stdio.h include
[gitweb.git] / transport.c
index d0608df5c90cab4d2e2a2071a7416aeac75004e1..f1fcd2c4b006dc2ece2019ac91f73a2f42bbf6bd 100644 (file)
@@ -252,6 +252,14 @@ static int connect_setup(struct transport *transport, int for_push)
        return 0;
 }
 
+static void die_if_server_options(struct transport *transport)
+{
+       if (!transport->server_options || !transport->server_options->nr)
+               return;
+       advise(_("see protocol.version in 'git help config' for more details"));
+       die(_("server options require protocol version 2 or later"));
+}
+
 /*
  * Obtains the protocol version from the transport and writes it to
  * transport->data->version, first connecting if not already connected.
@@ -286,6 +294,7 @@ static struct ref *handshake(struct transport *transport, int for_push,
                break;
        case protocol_v1:
        case protocol_v0:
+               die_if_server_options(transport);
                get_remote_heads(&reader, &refs,
                                 for_push ? REF_NORMAL : 0,
                                 &data->extra_have,
@@ -314,7 +323,6 @@ static int fetch_refs_via_pack(struct transport *transport,
        int ret = 0;
        struct git_transport_data *data = transport->data;
        struct ref *refs = NULL;
-       char *dest = xstrdup(transport->url);
        struct fetch_pack_args args;
        struct ref *refs_tmp = NULL;
 
@@ -356,16 +364,17 @@ static int fetch_refs_via_pack(struct transport *transport,
 
        switch (data->version) {
        case protocol_v2:
-               refs = fetch_pack(&args, data->fd, data->conn,
+               refs = fetch_pack(&args, data->fd,
                                  refs_tmp ? refs_tmp : transport->remote_refs,
-                                 dest, to_fetch, nr_heads, &data->shallow,
+                                 to_fetch, nr_heads, &data->shallow,
                                  &transport->pack_lockfile, data->version);
                break;
        case protocol_v1:
        case protocol_v0:
-               refs = fetch_pack(&args, data->fd, data->conn,
+               die_if_server_options(transport);
+               refs = fetch_pack(&args, data->fd,
                                  refs_tmp ? refs_tmp : transport->remote_refs,
-                                 dest, to_fetch, nr_heads, &data->shallow,
+                                 to_fetch, nr_heads, &data->shallow,
                                  &transport->pack_lockfile, data->version);
                break;
        case protocol_unknown_version:
@@ -389,7 +398,6 @@ static int fetch_refs_via_pack(struct transport *transport,
 
        free_refs(refs_tmp);
        free_refs(refs);
-       free(dest);
        return ret;
 }