@matheusbsbs / matheus-bagliano / commits / 9dfa8dbeee
Fork 0

fetch-pack: remove no_dependents code

Now that Git has switched to using a subprocess to lazy-fetch missing objects, remove the no_dependents code as it is no longer used. Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan Tan committed Aug 17, 2020 at 21:01 UTC 9dfa8dbeee18a126aabcdd36a06e5d6b5eb6a58a
6 files changed +30 -115
builtin/fetch-pack.c
-4
@@ -153,10 +153,6 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
153 args.from_promisor = 1;
154 continue;
155 }
156 - if (!strcmp("--no-dependents", arg)) {
157 - args.no_dependents = 1;
158 - continue;
159 - }
156 if (skip_prefix(arg, ("--" CL_ARG__FILTER "="), &arg)) {
157 parse_list_objects_filter(&args.filter_options, arg);
158 continue;
fetch-pack.c
+30 -80
@@ -285,10 +285,8 @@ static int find_common(struct fetch_negotiator *negotiator,
285 PACKET_READ_CHOMP_NEWLINE |
286 PACKET_READ_DIE_ON_ERR_PACKET);
287
288 - if (!args->no_dependents) {
289 - mark_tips(negotiator, args->negotiation_tips);
290 - for_each_cached_alternate(negotiator, insert_one_alternate_object);
291 - }
288 + mark_tips(negotiator, args->negotiation_tips);
289 + for_each_cached_alternate(negotiator, insert_one_alternate_object);
290
291 fetching = 0;
292 for ( ; refs ; refs = refs->next) {
@@ -305,12 +303,8 @@ static int find_common(struct fetch_negotiator *negotiator,
303 * We use lookup_object here because we are only
304 * interested in the case we *know* the object is
305 * reachable and we have already scanned it.
308 - *
309 - * Do this only if args->no_dependents is false (if it is true,
310 - * we cannot trust the object flags).
306 */
312 - if (!args->no_dependents &&
313 - ((o = lookup_object(the_repository, remote)) != NULL) &&
307 + if (((o = lookup_object(the_repository, remote)) != NULL) &&
308 (o->flags & COMPLETE)) {
309 continue;
310 }
@@ -410,8 +404,6 @@ static int find_common(struct fetch_negotiator *negotiator,
404 trace2_region_enter("fetch-pack", "negotiation_v0_v1", the_repository);
405 flushes = 0;
406 retval = -1;
413 - if (args->no_dependents)
414 - goto done;
407 while ((oid = negotiator->next(negotiator))) {
408 packet_buf_write(&req_buf, "have %s\n", oid_to_hex(oid));
409 print_verbose(args, "have %s", oid_to_hex(oid));
@@ -666,9 +658,7 @@ struct loose_object_iter {
658
659 /*
660 * Mark recent commits available locally and reachable from a local ref as
669 - * COMPLETE. If args->no_dependents is false, also mark COMPLETE remote refs as
670 - * COMMON_REF (otherwise, we are not planning to participate in negotiation, and
671 - * thus do not need COMMON_REF marks).
661 + * COMPLETE.
662 *
663 * The cutoff time for recency is determined by this heuristic: it is the
664 * earliest commit time of the objects in refs that are commits and that we know
@@ -969,12 +959,8 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args,
959 struct fetch_negotiator negotiator_alloc;
960 struct fetch_negotiator *negotiator;
961
972 - if (args->no_dependents) {
973 - negotiator = NULL;
974 - } else {
975 - negotiator = &negotiator_alloc;
976 - fetch_negotiator_init(r, negotiator);
977 - }
962 + negotiator = &negotiator_alloc;
963 + fetch_negotiator_init(r, negotiator);
964
965 sort_ref_list(&ref, ref_compare_name);
966 QSORT(sought, nr_sought, cmp_ref_by_name);
@@ -1062,15 +1048,11 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args,
1048 if (!server_supports_hash(the_hash_algo->name, NULL))
1049 die(_("Server does not support this repository's object format"));
1050
1065 - if (!args->no_dependents) {
1066 - mark_complete_and_common_ref(negotiator, args, &ref);
1067 - filter_refs(args, &ref, sought, nr_sought);
1068 - if (everything_local(args, &ref)) {
1069 - packet_flush(fd[1]);
1070 - goto all_done;
1071 - }
1072 - } else {
1073 - filter_refs(args, &ref, sought, nr_sought);
1051 + mark_complete_and_common_ref(negotiator, args, &ref);
1052 + filter_refs(args, &ref, sought, nr_sought);
1053 + if (everything_local(args, &ref)) {
1054 + packet_flush(fd[1]);
1055 + goto all_done;
1056 }
1057 if (find_common(negotiator, args, fd, &oid, ref) < 0)
1058 if (!args->keep_pack)
@@ -1119,7 +1101,7 @@ static void add_shallow_requests(struct strbuf *req_buf,
1101 packet_buf_write(req_buf, "deepen-relative\n");
1102 }
1103
1122 -static void add_wants(int no_dependents, const struct ref *wants, struct strbuf *req_buf)
1104 +static void add_wants(const struct ref *wants, struct strbuf *req_buf)
1105 {
1106 int use_ref_in_want = server_supports_feature("fetch", "ref-in-want", 0);
1107
@@ -1136,12 +1118,8 @@ static void add_wants(int no_dependents, const struct ref *wants, struct strbuf
1118 * We use lookup_object here because we are only
1119 * interested in the case we *know* the object is
1120 * reachable and we have already scanned it.
1139 - *
1140 - * Do this only if args->no_dependents is false (if it is true,
1141 - * we cannot trust the object flags).
1121 */
1143 - if (!no_dependents &&
1144 - ((o = lookup_object(the_repository, remote)) != NULL) &&
1122 + if (((o = lookup_object(the_repository, remote)) != NULL) &&
1123 (o->flags & COMPLETE)) {
1124 continue;
1125 }
@@ -1275,19 +1253,14 @@ static int send_fetch_request(struct fetch_negotiator *negotiator, int fd_out,
1253 }
1254
1255 /* add wants */
1278 - add_wants(args->no_dependents, wants, &req_buf);
1256 + add_wants(wants, &req_buf);
1257
1280 - if (args->no_dependents) {
1281 - packet_buf_write(&req_buf, "done");
1282 - ret = 1;
1283 - } else {
1284 - /* Add all of the common commits we've found in previous rounds */
1285 - add_common(&req_buf, common);
1258 + /* Add all of the common commits we've found in previous rounds */
1259 + add_common(&req_buf, common);
1260
1287 - /* Add initial haves */
1288 - ret = add_haves(negotiator, seen_ack, &req_buf,
1289 - haves_to_send, in_vain);
1290 - }
1261 + /* Add initial haves */
1262 + ret = add_haves(negotiator, seen_ack, &req_buf,
1263 + haves_to_send, in_vain);
1264
1265 /* Send request */
1266 packet_buf_flush(&req_buf);
@@ -1547,12 +1520,8 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
1520 struct string_list packfile_uris = STRING_LIST_INIT_DUP;
1521 int i;
1522
1550 - if (args->no_dependents) {
1551 - negotiator = NULL;
1552 - } else {
1553 - negotiator = &negotiator_alloc;
1554 - fetch_negotiator_init(r, negotiator);
1555 - }
1523 + negotiator = &negotiator_alloc;
1524 + fetch_negotiator_init(r, negotiator);
1525
1526 packet_reader_init(&reader, fd[0], NULL, 0,
1527 PACKET_READ_CHOMP_NEWLINE |
@@ -1576,21 +1545,16 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
1545 args->deepen = 1;
1546
1547 /* Filter 'ref' by 'sought' and those that aren't local */
1579 - if (!args->no_dependents) {
1580 - mark_complete_and_common_ref(negotiator, args, &ref);
1581 - filter_refs(args, &ref, sought, nr_sought);
1582 - if (everything_local(args, &ref))
1583 - state = FETCH_DONE;
1584 - else
1585 - state = FETCH_SEND_REQUEST;
1586 -
1587 - mark_tips(negotiator, args->negotiation_tips);
1588 - for_each_cached_alternate(negotiator,
1589 - insert_one_alternate_object);
1590 - } else {
1591 - filter_refs(args, &ref, sought, nr_sought);
1548 + mark_complete_and_common_ref(negotiator, args, &ref);
1549 + filter_refs(args, &ref, sought, nr_sought);
1550 + if (everything_local(args, &ref))
1551 + state = FETCH_DONE;
1552 + else
1553 state = FETCH_SEND_REQUEST;
1593 - }
1554 +
1555 + mark_tips(negotiator, args->negotiation_tips);
1556 + for_each_cached_alternate(negotiator,
1557 + insert_one_alternate_object);
1558 break;
1559 case FETCH_SEND_REQUEST:
1560 if (!negotiation_started) {
@@ -1911,20 +1875,6 @@ struct ref *fetch_pack(struct fetch_pack_args *args,
1875 if (nr_sought)
1876 nr_sought = remove_duplicates_in_refs(sought, nr_sought);
1877
1914 - if (args->no_dependents && !args->filter_options.choice) {
1915 - /*
1916 - * The protocol does not support requesting that only the
1917 - * wanted objects be sent, so approximate this by setting a
1918 - * "blob:none" filter if no filter is already set. This works
1919 - * for all object types: note that wanted blobs will still be
1920 - * sent because they are directly specified as a "want".
1921 - *
1922 - * NEEDSWORK: Add an option in the protocol to request that
1923 - * only the wanted objects be sent, and implement it.
1924 - */
1925 - parse_list_objects_filter(&args->filter_options, "blob:none");
1926 - }
1927 -
1878 if (version != protocol_v2 && !ref) {
1879 packet_flush(fd[1]);
1880 die(_("no matching remote head"));
fetch-pack.h
-14
@@ -42,20 +42,6 @@ struct fetch_pack_args {
42 unsigned deepen:1;
43 unsigned from_promisor:1;
44
45 - /*
46 - * Attempt to fetch only the wanted objects, and not any objects
47 - * referred to by them. Due to protocol limitations, extraneous
48 - * objects may still be included. (When fetching non-blob
49 - * objects, only blobs are excluded; when fetching a blob, the
50 - * blob itself will still be sent. The client does not need to
51 - * know whether a wanted object is a blob or not.)
52 - *
53 - * If 1, fetch_pack() will also not modify any object flags.
54 - * This allows fetch_pack() to safely be called by any function,
55 - * regardless of which object flags it uses (if any).
56 - */
57 - unsigned no_dependents:1;
58 -
45 /*
46 * Because fetch_pack() overwrites the shallow file upon a
47 * successful deepening non-clone fetch, if this struct
remote-curl.c
-6
@@ -40,7 +40,6 @@ struct options {
40 push_cert : 2,
41 deepen_relative : 1,
42 from_promisor : 1,
43 - no_dependents : 1,
43 atomic : 1,
44 object_format : 1;
45 const struct git_hash_algo *hash_algo;
@@ -190,9 +189,6 @@ static int set_option(const char *name, const char *value)
189 } else if (!strcmp(name, "from-promisor")) {
190 options.from_promisor = 1;
191 return 0;
193 - } else if (!strcmp(name, "no-dependents")) {
194 - options.no_dependents = 1;
195 - return 0;
192 } else if (!strcmp(name, "filter")) {
193 options.filter = xstrdup(value);
194 return 0;
@@ -1175,8 +1171,6 @@ static int fetch_git(struct discovery *heads,
1171 strvec_push(&args, "--deepen-relative");
1172 if (options.from_promisor)
1173 strvec_push(&args, "--from-promisor");
1178 - if (options.no_dependents)
1179 - strvec_push(&args, "--no-dependents");
1174 if (options.filter)
1175 strvec_pushf(&args, "--filter=%s", options.filter);
1176 strvec_push(&args, url.buf);
transport.c
-4
@@ -232,9 +232,6 @@ static int set_git_option(struct git_transport_options *opts,
232 } else if (!strcmp(name, TRANS_OPT_FROM_PROMISOR)) {
233 opts->from_promisor = !!value;
234 return 0;
235 - } else if (!strcmp(name, TRANS_OPT_NO_DEPENDENTS)) {
236 - opts->no_dependents = !!value;
237 - return 0;
235 } else if (!strcmp(name, TRANS_OPT_LIST_OBJECTS_FILTER)) {
236 list_objects_filter_die_if_populated(&opts->filter_options);
237 parse_list_objects_filter(&opts->filter_options, value);
@@ -359,7 +356,6 @@ static int fetch_refs_via_pack(struct transport *transport,
356 args.cloning = transport->cloning;
357 args.update_shallow = data->options.update_shallow;
358 args.from_promisor = data->options.from_promisor;
362 - args.no_dependents = data->options.no_dependents;
359 args.filter_options = data->options.filter_options;
360 args.stateless_rpc = transport->stateless_rpc;
361 args.server_options = transport->server_options;
transport.h
-7
@@ -16,7 +16,6 @@ struct git_transport_options {
16 unsigned update_shallow : 1;
17 unsigned deepen_relative : 1;
18 unsigned from_promisor : 1;
19 - unsigned no_dependents : 1;
19
20 /*
21 * If this transport supports connect or stateless-connect,
@@ -201,12 +200,6 @@ void transport_check_allowed(const char *type);
200 /* Indicate that these objects are being fetched by a promisor */
201 #define TRANS_OPT_FROM_PROMISOR "from-promisor"
202
204 -/*
205 - * Indicate that only the objects wanted need to be fetched, not their
206 - * dependents
207 - */
208 -#define TRANS_OPT_NO_DEPENDENTS "no-dependents"
209 -
203 /* Filter objects for partial clone and fetch */
204 #define TRANS_OPT_LIST_OBJECTS_FILTER "filter"
205