transport: rename got_remote_heads

The 'got_remote_heads' member of 'struct git_transport_data' was used historically to indicate that the initial server connection was made and the ref advertisement was returned. With protocol v2, that initial handshake does not necessarily include the ref advertisement, so this member is not an accurate name. Thankfully, all uses of the member are only checking to see if the handshake should take place, not whether or not some local data has the ref advertisement. Rename the member to 'finished_handshake' to represent the proper state. Note that the variable is only set to 1 during the handshake() method. Signed-off-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Derrick Stolee committed Dec 22, 2022 at 15:14 UTC 1b759e0cf1c18c637e40c6c191a0b614e4e4ea43
1 file changed +9 -9
transport.c
+9 -9
@@ -198,7 +198,7 @@ struct git_transport_data {
198 struct git_transport_options options;
199 struct child_process *conn;
200 int fd[2];
201 - unsigned got_remote_heads : 1;
201 + unsigned finished_handshake : 1;
202 enum protocol_version version;
203 struct oid_array extra_have;
204 struct oid_array shallow;
@@ -345,7 +345,7 @@ static struct ref *handshake(struct transport *transport, int for_push,
345 case protocol_unknown_version:
346 BUG("unknown protocol version");
347 }
348 - data->got_remote_heads = 1;
348 + data->finished_handshake = 1;
349 transport->hash_algo = reader.hash_algo;
350
351 if (reader.line_peeked)
@@ -421,7 +421,7 @@ static int fetch_refs_via_pack(struct transport *transport,
421 args.negotiation_tips = data->options.negotiation_tips;
422 args.reject_shallow_remote = transport->smart_options->reject_shallow;
423
424 - if (!data->got_remote_heads) {
424 + if (!data->finished_handshake) {
425 int i;
426 int must_list_refs = 0;
427 for (i = 0; i < nr_heads; i++) {
@@ -461,7 +461,7 @@ static int fetch_refs_via_pack(struct transport *transport,
461 to_fetch, nr_heads, &data->shallow,
462 &transport->pack_lockfiles, data->version);
463
464 - data->got_remote_heads = 0;
464 + data->finished_handshake = 0;
465 data->options.self_contained_and_connected =
466 args.self_contained_and_connected;
467 data->options.connectivity_checked = args.connectivity_checked;
@@ -846,7 +846,7 @@ static int git_transport_push(struct transport *transport, struct ref *remote_re
846 if (transport_color_config() < 0)
847 return -1;
848
849 - if (!data->got_remote_heads)
849 + if (!data->finished_handshake)
850 get_refs_via_connect(transport, 1, NULL);
851
852 memset(&args, 0, sizeof(args));
@@ -894,7 +894,7 @@ static int git_transport_push(struct transport *transport, struct ref *remote_re
894 else
895 ret = finish_connect(data->conn);
896 data->conn = NULL;
897 - data->got_remote_heads = 0;
897 + data->finished_handshake = 0;
898
899 return ret;
900 }
@@ -914,7 +914,7 @@ static int disconnect_git(struct transport *transport)
914 {
915 struct git_transport_data *data = transport->data;
916 if (data->conn) {
917 - if (data->got_remote_heads && !transport->stateless_rpc)
917 + if (data->finished_handshake && !transport->stateless_rpc)
918 packet_flush(data->fd[1]);
919 close(data->fd[0]);
920 if (data->fd[1] >= 0)
@@ -949,7 +949,7 @@ void transport_take_over(struct transport *transport,
949 data->conn = child;
950 data->fd[0] = data->conn->out;
951 data->fd[1] = data->conn->in;
952 - data->got_remote_heads = 0;
952 + data->finished_handshake = 0;
953 transport->data = data;
954
955 transport->vtable = &taken_over_vtable;
@@ -1150,7 +1150,7 @@ struct transport *transport_get(struct remote *remote, const char *url)
1150 ret->smart_options = &(data->options);
1151
1152 data->conn = NULL;
1153 - data->got_remote_heads = 0;
1153 + data->finished_handshake = 0;
1154 } else {
1155 /* Unknown protocol in URL. Pass to external handler. */
1156 int len = external_specification_len(url);