@matheusbsbs / matheus-bagliano / commits / 7c97af4d64
Fork 0

transport: add a hash algorithm member

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 <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

brian m. carlson committed May 25, 2020 at 19:58 UTC 7c97af4d64100bf9ce4b335ee91e743378e2e181
2 files changed +16
transport.c
+8
@@ -311,6 +311,7 @@ static struct ref *handshake(struct transport *transport, int for_push,
311 BUG("unknown protocol version");
312 }
313 data->got_remote_heads = 1;
314 + transport->hash_algo = reader.hash_algo;
315
316 if (reader.line_peeked)
317 BUG("buffer must be empty at the end of handshake()");
@@ -996,9 +997,16 @@ struct transport *transport_get(struct remote *remote, const char *url)
997 ret->smart_options->receivepack = remote->receivepack;
998 }
999
1000 + ret->hash_algo = &hash_algos[GIT_HASH_SHA1];
1001 +
1002 return ret;
1003 }
1004
1005 +const struct git_hash_algo *transport_get_hash_algo(struct transport *transport)
1006 +{
1007 + return transport->hash_algo;
1008 +}
1009 +
1010 int transport_set_option(struct transport *transport,
1011 const char *name, const char *value)
1012 {
transport.h
+8
@@ -115,6 +115,8 @@ struct transport {
115 struct git_transport_options *smart_options;
116
117 enum transport_family family;
118 +
119 + const struct git_hash_algo *hash_algo;
120 };
121
122 #define TRANSPORT_PUSH_ALL (1<<0)
@@ -243,6 +245,12 @@ int transport_push(struct repository *repo,
245 const struct ref *transport_get_remote_refs(struct transport *transport,
246 const struct argv_array *ref_prefixes);
247
248 +/*
249 + * Fetch the hash algorithm used by a remote.
250 + *
251 + * This can only be called after fetching the remote refs.
252 + */
253 +const struct git_hash_algo *transport_get_hash_algo(struct transport *transport);
254 int transport_fetch_refs(struct transport *transport, struct ref *refs);
255 void transport_unlock_pack(struct transport *transport);
256 int transport_disconnect(struct transport *transport);