Merge branch 'jc/denoise-rm-to-resolve' into maint
[gitweb.git] / transport.c
index 365ea574c7b52e0fc4381295eed6650ca5f67a87..453de8f7041b966a9bd0eaee20ef8f5758cec2f1 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,
@@ -362,6 +371,7 @@ static int fetch_refs_via_pack(struct transport *transport,
                break;
        case protocol_v1:
        case protocol_v0:
+               die_if_server_options(transport);
                refs = fetch_pack(&args, data->fd,
                                  refs_tmp ? refs_tmp : transport->remote_refs,
                                  to_fetch, nr_heads, &data->shallow,
@@ -1216,6 +1226,20 @@ int transport_push(struct repository *r,
                err = push_had_errors(remote_refs);
                ret = push_ret | err;
 
+               if ((flags & TRANSPORT_PUSH_ATOMIC) && err) {
+                       struct ref *it;
+                       for (it = remote_refs; it; it = it->next)
+                               switch (it->status) {
+                               case REF_STATUS_NONE:
+                               case REF_STATUS_UPTODATE:
+                               case REF_STATUS_OK:
+                                       it->status = REF_STATUS_ATOMIC_PUSH_FAILED;
+                                       break;
+                               default:
+                                       break;
+                               }
+               }
+
                if (!quiet || err)
                        transport_print_push_status(transport->url, remote_refs,
                                        verbose | porcelain, porcelain,