]> git.ipfire.org Git - thirdparty/git.git/commitdiff
send-pack: detect when the server doesn't support our hash
authorbrian m. carlson <sandals@crustytoothpaste.net>
Mon, 25 May 2020 19:58:57 +0000 (19:58 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 27 May 2020 17:07:06 +0000 (10:07 -0700)
Detect when the server doesn't support our hash algorithm and abort.
If the server does support our hash, advertise it as part of our
capabilities.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
send-pack.c

index d1b7edc9957874dea1a1d1c8daf62e2ef2d7f8d8..fb037568a946a362b02f6a21e72e97c48a94b5d5 100644 (file)
@@ -362,6 +362,7 @@ int send_pack(struct send_pack_args *args,
        int atomic_supported = 0;
        int use_push_options = 0;
        int push_options_supported = 0;
+       int object_format_supported = 0;
        unsigned cmds_sent = 0;
        int ret;
        struct async demux;
@@ -388,6 +389,9 @@ int send_pack(struct send_pack_args *args,
        if (server_supports("push-options"))
                push_options_supported = 1;
 
+       if (!server_supports_hash(the_hash_algo->name, &object_format_supported))
+               die(_("the receiving end does not support this repository's hash algorithm"));
+
        if (args->push_cert != SEND_PACK_PUSH_CERT_NEVER) {
                int len;
                push_cert_nonce = server_feature_value("push-cert", &len);
@@ -428,6 +432,8 @@ int send_pack(struct send_pack_args *args,
                strbuf_addstr(&cap_buf, " atomic");
        if (use_push_options)
                strbuf_addstr(&cap_buf, " push-options");
+       if (object_format_supported)
+               strbuf_addf(&cap_buf, " object-format=%s", the_hash_algo->name);
        if (agent_supported)
                strbuf_addf(&cap_buf, " agent=%s", git_user_agent_sanitized());