transport: rename negotiation_tips

The previous change added the --negotiation-restrict synonym for the --negotiation-tip option for 'git fetch'. In anticipation of adding a new option that behaves similarly but with distinct changes to its behavior, rename the internal representation of this data from 'negotiation_tips' to 'negotiation_restrict_tips'. The 'tips' part is kept because this is an oid_array in the transport layer. This requires the builtin to handle parsing refs into collections of oids so the transport layer can handle this cleaner form of the data. Also update the string_list used to store the inputs from command-line options. Reviewed-by: Matthew John Cheetham <mjcheetham@outlook.com> Signed-off-by: Derrick Stolee <stolee@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Derrick Stolee committed May 19, 2026 at 16:24 UTC 4aef7dbb063cfd0923baae5a431913256edad667
6 files changed +28 -28
builtin/fetch.c
+9 -9
@@ -98,7 +98,7 @@ static struct transport *gtransport;
98 static struct transport *gsecondary;
99 static struct refspec refmap = REFSPEC_INIT_FETCH;
100 static struct string_list server_options = STRING_LIST_INIT_DUP;
101 -static struct string_list negotiation_tip = STRING_LIST_INIT_NODUP;
101 +static struct string_list negotiation_restrict = STRING_LIST_INIT_NODUP;
102
103 struct fetch_config {
104 enum display_format display_format;
@@ -1534,13 +1534,13 @@ static int add_oid(const struct reference *ref, void *cb_data)
1534 return 0;
1535 }
1536
1537 -static void add_negotiation_tips(struct git_transport_options *smart_options)
1537 +static void add_negotiation_restrict_tips(struct git_transport_options *smart_options)
1538 {
1539 struct oid_array *oids = xcalloc(1, sizeof(*oids));
1540 int i;
1541
1542 - for (i = 0; i < negotiation_tip.nr; i++) {
1543 - const char *s = negotiation_tip.items[i].string;
1542 + for (i = 0; i < negotiation_restrict.nr; i++) {
1543 + const char *s = negotiation_restrict.items[i].string;
1544 struct refs_for_each_ref_options opts = {
1545 .pattern = s,
1546 };
@@ -1561,7 +1561,7 @@ static void add_negotiation_tips(struct git_transport_options *smart_options)
1561 warning(_("ignoring %s=%s because it does not match any refs"),
1562 "--negotiation-restrict", s);
1563 }
1564 - smart_options->negotiation_tips = oids;
1564 + smart_options->negotiation_restrict_tips = oids;
1565 }
1566
1567 static struct transport *prepare_transport(struct remote *remote, int deepen,
@@ -1595,9 +1595,9 @@ static struct transport *prepare_transport(struct remote *remote, int deepen,
1595 set_option(transport, TRANS_OPT_LIST_OBJECTS_FILTER, spec);
1596 set_option(transport, TRANS_OPT_FROM_PROMISOR, "1");
1597 }
1598 - if (negotiation_tip.nr) {
1598 + if (negotiation_restrict.nr) {
1599 if (transport->smart_options)
1600 - add_negotiation_tips(transport->smart_options);
1600 + add_negotiation_restrict_tips(transport->smart_options);
1601 else
1602 warning(_("ignoring %s because the protocol does not support it"),
1603 "--negotiation-restrict");
@@ -2566,7 +2566,7 @@ int cmd_fetch(int argc,
2566 N_("specify fetch refmap"), PARSE_OPT_NONEG, parse_refmap_arg),
2567 OPT_STRING_LIST('o', "server-option", &server_options, N_("server-specific"), N_("option to transmit")),
2568 OPT_IPVERSION(&family),
2569 - OPT_STRING_LIST(0, "negotiation-restrict", &negotiation_tip, N_("revision"),
2569 + OPT_STRING_LIST(0, "negotiation-restrict", &negotiation_restrict, N_("revision"),
2570 N_("report that we have only objects reachable from this object")),
2571 OPT_ALIAS(0, "negotiation-tip", "negotiation-restrict"),
2572 OPT_BOOL(0, "negotiate-only", &negotiate_only,
@@ -2658,7 +2658,7 @@ int cmd_fetch(int argc,
2658 config.display_format = DISPLAY_FORMAT_PORCELAIN;
2659 }
2660
2661 - if (negotiate_only && !negotiation_tip.nr)
2661 + if (negotiate_only && !negotiation_restrict.nr)
2662 die(_("%s needs one or more %s"), "--negotiate-only",
2663 "--negotiation-restrict=*");
2664
fetch-pack.c
+9 -9
@@ -291,21 +291,21 @@ static int next_flush(int stateless_rpc, int count)
291 }
292
293 static void mark_tips(struct fetch_negotiator *negotiator,
294 - const struct oid_array *negotiation_tips)
294 + const struct oid_array *negotiation_restrict_tips)
295 {
296 struct refs_for_each_ref_options opts = {
297 .flags = REFS_FOR_EACH_INCLUDE_BROKEN,
298 };
299 int i;
300
301 - if (!negotiation_tips) {
301 + if (!negotiation_restrict_tips) {
302 refs_for_each_ref_ext(get_main_ref_store(the_repository),
303 rev_list_insert_ref_oid, negotiator, &opts);
304 return;
305 }
306
307 - for (i = 0; i < negotiation_tips->nr; i++)
308 - rev_list_insert_ref(negotiator, &negotiation_tips->oid[i]);
307 + for (i = 0; i < negotiation_restrict_tips->nr; i++)
308 + rev_list_insert_ref(negotiator, &negotiation_restrict_tips->oid[i]);
309 return;
310 }
311
@@ -355,7 +355,7 @@ static int find_common(struct fetch_negotiator *negotiator,
355 PACKET_READ_CHOMP_NEWLINE |
356 PACKET_READ_DIE_ON_ERR_PACKET);
357
358 - mark_tips(negotiator, args->negotiation_tips);
358 + mark_tips(negotiator, args->negotiation_restrict_tips);
359 for_each_cached_alternate(negotiator, insert_one_alternate_object);
360
361 fetching = 0;
@@ -1728,7 +1728,7 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
1728 else
1729 state = FETCH_SEND_REQUEST;
1730
1731 - mark_tips(negotiator, args->negotiation_tips);
1731 + mark_tips(negotiator, args->negotiation_restrict_tips);
1732 for_each_cached_alternate(negotiator,
1733 insert_one_alternate_object);
1734 break;
@@ -2177,7 +2177,7 @@ static void clear_common_flag(struct oidset *s)
2177 }
2178 }
2179
2180 -void negotiate_using_fetch(const struct oid_array *negotiation_tips,
2180 +void negotiate_using_fetch(const struct oid_array *negotiation_restrict_tips,
2181 const struct string_list *server_options,
2182 int stateless_rpc,
2183 int fd[],
@@ -2195,13 +2195,13 @@ void negotiate_using_fetch(const struct oid_array *negotiation_tips,
2195 timestamp_t min_generation = GENERATION_NUMBER_INFINITY;
2196
2197 fetch_negotiator_init(the_repository, &negotiator);
2198 - mark_tips(&negotiator, negotiation_tips);
2198 + mark_tips(&negotiator, negotiation_restrict_tips);
2199
2200 packet_reader_init(&reader, fd[0], NULL, 0,
2201 PACKET_READ_CHOMP_NEWLINE |
2202 PACKET_READ_DIE_ON_ERR_PACKET);
2203
2204 - oid_array_for_each((struct oid_array *) negotiation_tips,
2204 + oid_array_for_each((struct oid_array *) negotiation_restrict_tips,
2205 add_to_object_array,
2206 &nt_object_array);
2207
fetch-pack.h
+2 -2
@@ -21,7 +21,7 @@ struct fetch_pack_args {
21 * If not NULL, during packfile negotiation, fetch-pack will send "have"
22 * lines only with these tips and their ancestors.
23 */
24 - const struct oid_array *negotiation_tips;
24 + const struct oid_array *negotiation_restrict_tips;
25
26 unsigned deepen_relative:1;
27 unsigned quiet:1;
@@ -89,7 +89,7 @@ struct ref *fetch_pack(struct fetch_pack_args *args,
89 * In the capability advertisement that has happened prior to invoking this
90 * function, the "wait-for-done" capability must be present.
91 */
92 -void negotiate_using_fetch(const struct oid_array *negotiation_tips,
92 +void negotiate_using_fetch(const struct oid_array *negotiation_restrict_tips,
93 const struct string_list *server_options,
94 int stateless_rpc,
95 int fd[],
transport-helper.c
+1 -1
@@ -754,7 +754,7 @@ static int fetch_refs(struct transport *transport,
754 set_helper_option(transport, "filter", spec);
755 }
756
757 - if (data->transport_options.negotiation_tips)
757 + if (data->transport_options.negotiation_restrict_tips)
758 warning(_("ignoring %s because the protocol does not support it."),
759 "--negotiation-restrict");
760
transport.c
+5 -5
@@ -463,7 +463,7 @@ static int fetch_refs_via_pack(struct transport *transport,
463 args.refetch = data->options.refetch;
464 args.stateless_rpc = transport->stateless_rpc;
465 args.server_options = transport->server_options;
466 - args.negotiation_tips = data->options.negotiation_tips;
466 + args.negotiation_restrict_tips = data->options.negotiation_restrict_tips;
467 args.reject_shallow_remote = transport->smart_options->reject_shallow;
468
469 if (!data->finished_handshake) {
@@ -491,7 +491,7 @@ static int fetch_refs_via_pack(struct transport *transport,
491 warning(_("server does not support wait-for-done"));
492 ret = -1;
493 } else {
494 - negotiate_using_fetch(data->options.negotiation_tips,
494 + negotiate_using_fetch(data->options.negotiation_restrict_tips,
495 transport->server_options,
496 transport->stateless_rpc,
497 data->fd,
@@ -979,9 +979,9 @@ static int disconnect_git(struct transport *transport)
979 finish_connect(data->conn);
980 }
981
982 - if (data->options.negotiation_tips) {
983 - oid_array_clear(data->options.negotiation_tips);
984 - free(data->options.negotiation_tips);
982 + if (data->options.negotiation_restrict_tips) {
983 + oid_array_clear(data->options.negotiation_restrict_tips);
984 + free(data->options.negotiation_restrict_tips);
985 }
986 list_objects_filter_release(&data->options.filter_options);
987 oid_array_clear(&data->extra_have);
transport.h
+2 -2
@@ -40,13 +40,13 @@ struct git_transport_options {
40
41 /*
42 * This is only used during fetch. See the documentation of
43 - * negotiation_tips in struct fetch_pack_args.
43 + * negotiation_restrict_tips in struct fetch_pack_args.
44 *
45 * This field is only supported by transports that support connect or
46 * stateless_connect. Set this field directly instead of using
47 * transport_set_option().
48 */
49 - struct oid_array *negotiation_tips;
49 + struct oid_array *negotiation_restrict_tips;
50
51 /*
52 * If allocated, whenever transport_fetch_refs() is called, add known