From patchwork Mon May 25 19:58:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brian m. carlson" X-Patchwork-Id: 11569347 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0059190 for ; Mon, 25 May 2020 20:00:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D26242075F for ; Mon, 25 May 2020 19:59:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (3072-bit key) header.d=crustytoothpaste.net header.i=@crustytoothpaste.net header.b="A6XJCRUT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390452AbgEYT76 (ORCPT ); Mon, 25 May 2020 15:59:58 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:38716 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390393AbgEYT7t (ORCPT ); Mon, 25 May 2020 15:59:49 -0400 Received: from camp.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:b610:a2f0:36c1:12e3]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id 7EF90609CF; Mon, 25 May 2020 19:59:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1590436787; bh=edUdmuqwqgrI4d7hU9gk2tehK/HwKep/ouFUbgKC4Xo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Reply-To: Subject:Date:To:CC:Resent-Date:Resent-From:Resent-To:Resent-Cc: In-Reply-To:References:Content-Type:Content-Disposition; b=A6XJCRUTQUKscCWf5X97I6xLbNgW7naieDvuPKDBa73ov++gSVHGGmesN0/nmn9Qg WK9WEpHWs7hB0OtYmgcmL7SJEkDQrFmHqzEO72vRo143dsLWQYfYMtNxxSeMt+JifL XR7cH+vhUmgsjDNGDOd+4+9At/lzqI9CAIzSRFCI5et7+3WjX9r7kVPz7fyY8lafPq 9jjKLUnL2CLcla5JOnuY+8ViG+PwqKpPhlrLPA13jT8JBLkFirNOqMJq17kyWnuQJ8 wWi8YjU4GozmXjkHC2bm6kjnnwabblRrOnNnzoLoz8Gp0vhs4ziieOe0xgQJU6R0/F 5/3Xc+2On+v77Dvq4GLDnwUAEhTPQK0zX/MUJkmJ9KGTD0M7CRoQUfJEktVwZaJoTH oLFsvioikQViBhvSNxRDltmRWXmCLEIDveXe9dLGX65Lpqk9G9MKdqlTf+nPsIhnpn 3+VjDZ0S0/0e0OOgzfigNJbECeXWm8jAWbHnXajFk/GQmR5lRn7 From: "brian m. carlson" To: Cc: =?utf-8?q?Martin_=C3=85gren?= Subject: [PATCH v2 11/44] send-pack: detect when the server doesn't support our hash Date: Mon, 25 May 2020 19:58:57 +0000 Message-Id: <20200525195930.309665-12-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.27.0.rc0.183.gde8f92d652 In-Reply-To: <20200525195930.309665-1-sandals@crustytoothpaste.net> References: <20200513005424.81369-1-sandals@crustytoothpaste.net> <20200525195930.309665-1-sandals@crustytoothpaste.net> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org 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 --- send-pack.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/send-pack.c b/send-pack.c index 0abee22283..02aefcb08e 100644 --- a/send-pack.c +++ b/send-pack.c @@ -363,6 +363,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; @@ -389,6 +390,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); @@ -429,6 +433,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());