From patchwork Wed May 13 00:53:49 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: 11544417 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 2B28F1668 for ; Wed, 13 May 2020 00:55:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 141C72078C for ; Wed, 13 May 2020 00:55:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (3072-bit key) header.d=crustytoothpaste.net header.i=@crustytoothpaste.net header.b="kUPMNlJk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732032AbgEMAzR (ORCPT ); Tue, 12 May 2020 20:55:17 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:38232 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732004AbgEMAzM (ORCPT ); Tue, 12 May 2020 20:55:12 -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 68CA760CF9; Wed, 13 May 2020 00:54:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1589331281; bh=smurCJGXxF6jSqhkjKD9sTFjDwJyxySvg1esDLljrV0=; 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=kUPMNlJkE1KskRogfJ5atV+F5eRvyzwKJksI/H9Xse93wyDg5qy4ogP7OtL2Efgjc vEQyWTznDlsvua8boxWrgNsHHKMdn3xpoGqgBi6ZSHTKwg8H6ccZtV0HHsjJkDzanK ZQQf9yPWOcHqAW9v1zy9llTjRjsQsts9CbfhlsPOS7SWP1vCnQw7UDgsOOV9hEiM6x Nvh7jRlyMkbSWDnpeQYMEcKe0ui/jIzjkM8CT3bWbGArVNQ9Fan5yh6jj/PgvU9cza lImvw93t9LIdBxNarddEvrQTL243AqHAsP5MhhS+B3TOFFdRbiCiPznoU9Cw2PVMrd u8CfzNCH9dJQTvP6FLXZYBLx0tSj9hqY+3qrHoym0ZIl+R3/6wNpSqqQ5VdcFg06c5 mh/TENmZTIYB7GRIg5sLvJBYGlTnunEEOePXnoik6PoOqtKCkT90LRIzvwHWkXEJEm OlOnALAi1UYPnHW75x76Sy2mJBPaGt+tEhqq3DRicTfawm+xjaN From: "brian m. carlson" To: Cc: Jonathan Tan Subject: [PATCH 09/44] transport: add a hash algorithm member Date: Wed, 13 May 2020 00:53:49 +0000 Message-Id: <20200513005424.81369-10-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.26.2.761.g0e0b3e54be In-Reply-To: <20200513005424.81369-1-sandals@crustytoothpaste.net> References: <20200513005424.81369-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 When connecting to a remote system, we need to know what hash algorithm it will be using to talk to us. Add a hash_algo member to struct transport and add a function to read this data from the transport object. Signed-off-by: brian m. carlson --- transport.c | 8 ++++++++ transport.h | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/transport.c b/transport.c index 15f5ba4e8f..b43d985f90 100644 --- a/transport.c +++ b/transport.c @@ -311,6 +311,7 @@ static struct ref *handshake(struct transport *transport, int for_push, BUG("unknown protocol version"); } data->got_remote_heads = 1; + transport->hash_algo = reader.hash_algo; if (reader.line_peeked) BUG("buffer must be empty at the end of handshake()"); @@ -996,9 +997,16 @@ struct transport *transport_get(struct remote *remote, const char *url) ret->smart_options->receivepack = remote->receivepack; } + ret->hash_algo = &hash_algos[GIT_HASH_SHA1]; + return ret; } +const struct git_hash_algo *transport_get_hash_algo(struct transport *transport) +{ + return transport->hash_algo; +} + int transport_set_option(struct transport *transport, const char *name, const char *value) { diff --git a/transport.h b/transport.h index 4298c855be..2a9f96c05a 100644 --- a/transport.h +++ b/transport.h @@ -115,6 +115,8 @@ struct transport { struct git_transport_options *smart_options; enum transport_family family; + + const struct git_hash_algo *hash_algo; }; #define TRANSPORT_PUSH_ALL (1<<0) @@ -243,6 +245,12 @@ int transport_push(struct repository *repo, const struct ref *transport_get_remote_refs(struct transport *transport, const struct argv_array *ref_prefixes); +/* + * Fetch the hash algorithm used by a remote. + * + * This can only be called after fetching the remote refs. + */ +const struct git_hash_algo *transport_get_hash_algo(struct transport *transport); int transport_fetch_refs(struct transport *transport, struct ref *refs); void transport_unlock_pack(struct transport *transport); int transport_disconnect(struct transport *transport);