Skip to content

Commit 9dfa8db

Browse files
jonathantanmygitster
authored andcommitted
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>
1 parent 7ca3c0a commit 9dfa8db

File tree

6 files changed

+30
-115
lines changed

6 files changed

+30
-115
lines changed

builtin/fetch-pack.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,6 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
153153
args.from_promisor = 1;
154154
continue;
155155
}
156-
if (!strcmp("--no-dependents", arg)) {
157-
args.no_dependents = 1;
158-
continue;
159-
}
160156
if (skip_prefix(arg, ("--" CL_ARG__FILTER "="), &arg)) {
161157
parse_list_objects_filter(&args.filter_options, arg);
162158
continue;

fetch-pack.c

Lines changed: 30 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -285,10 +285,8 @@ static int find_common(struct fetch_negotiator *negotiator,
285285
PACKET_READ_CHOMP_NEWLINE |
286286
PACKET_READ_DIE_ON_ERR_PACKET);
287287

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);
292290

293291
fetching = 0;
294292
for ( ; refs ; refs = refs->next) {
@@ -305,12 +303,8 @@ static int find_common(struct fetch_negotiator *negotiator,
305303
* We use lookup_object here because we are only
306304
* interested in the case we *know* the object is
307305
* 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).
311306
*/
312-
if (!args->no_dependents &&
313-
((o = lookup_object(the_repository, remote)) != NULL) &&
307+
if (((o = lookup_object(the_repository, remote)) != NULL) &&
314308
(o->flags & COMPLETE)) {
315309
continue;
316310
}
@@ -410,8 +404,6 @@ static int find_common(struct fetch_negotiator *negotiator,
410404
trace2_region_enter("fetch-pack", "negotiation_v0_v1", the_repository);
411405
flushes = 0;
412406
retval = -1;
413-
if (args->no_dependents)
414-
goto done;
415407
while ((oid = negotiator->next(negotiator))) {
416408
packet_buf_write(&req_buf, "have %s\n", oid_to_hex(oid));
417409
print_verbose(args, "have %s", oid_to_hex(oid));
@@ -666,9 +658,7 @@ struct loose_object_iter {
666658

667659
/*
668660
* 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.
672662
*
673663
* The cutoff time for recency is determined by this heuristic: it is the
674664
* 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,
969959
struct fetch_negotiator negotiator_alloc;
970960
struct fetch_negotiator *negotiator;
971961

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);
978964

979965
sort_ref_list(&ref, ref_compare_name);
980966
QSORT(sought, nr_sought, cmp_ref_by_name);
@@ -1062,15 +1048,11 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args,
10621048
if (!server_supports_hash(the_hash_algo->name, NULL))
10631049
die(_("Server does not support this repository's object format"));
10641050

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;
10741056
}
10751057
if (find_common(negotiator, args, fd, &oid, ref) < 0)
10761058
if (!args->keep_pack)
@@ -1119,7 +1101,7 @@ static void add_shallow_requests(struct strbuf *req_buf,
11191101
packet_buf_write(req_buf, "deepen-relative\n");
11201102
}
11211103

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)
11231105
{
11241106
int use_ref_in_want = server_supports_feature("fetch", "ref-in-want", 0);
11251107

@@ -1136,12 +1118,8 @@ static void add_wants(int no_dependents, const struct ref *wants, struct strbuf
11361118
* We use lookup_object here because we are only
11371119
* interested in the case we *know* the object is
11381120
* 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).
11421121
*/
1143-
if (!no_dependents &&
1144-
((o = lookup_object(the_repository, remote)) != NULL) &&
1122+
if (((o = lookup_object(the_repository, remote)) != NULL) &&
11451123
(o->flags & COMPLETE)) {
11461124
continue;
11471125
}
@@ -1275,19 +1253,14 @@ static int send_fetch_request(struct fetch_negotiator *negotiator, int fd_out,
12751253
}
12761254

12771255
/* add wants */
1278-
add_wants(args->no_dependents, wants, &req_buf);
1256+
add_wants(wants, &req_buf);
12791257

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);
12861260

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);
12911264

12921265
/* Send request */
12931266
packet_buf_flush(&req_buf);
@@ -1547,12 +1520,8 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
15471520
struct string_list packfile_uris = STRING_LIST_INIT_DUP;
15481521
int i;
15491522

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);
15561525

15571526
packet_reader_init(&reader, fd[0], NULL, 0,
15581527
PACKET_READ_CHOMP_NEWLINE |
@@ -1576,21 +1545,16 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
15761545
args->deepen = 1;
15771546

15781547
/* 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
15921553
state = FETCH_SEND_REQUEST;
1593-
}
1554+
1555+
mark_tips(negotiator, args->negotiation_tips);
1556+
for_each_cached_alternate(negotiator,
1557+
insert_one_alternate_object);
15941558
break;
15951559
case FETCH_SEND_REQUEST:
15961560
if (!negotiation_started) {
@@ -1911,20 +1875,6 @@ struct ref *fetch_pack(struct fetch_pack_args *args,
19111875
if (nr_sought)
19121876
nr_sought = remove_duplicates_in_refs(sought, nr_sought);
19131877

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-
19281878
if (version != protocol_v2 && !ref) {
19291879
packet_flush(fd[1]);
19301880
die(_("no matching remote head"));

fetch-pack.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,6 @@ struct fetch_pack_args {
4242
unsigned deepen:1;
4343
unsigned from_promisor:1;
4444

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-
5945
/*
6046
* Because fetch_pack() overwrites the shallow file upon a
6147
* successful deepening non-clone fetch, if this struct

remote-curl.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ struct options {
4040
push_cert : 2,
4141
deepen_relative : 1,
4242
from_promisor : 1,
43-
no_dependents : 1,
4443
atomic : 1,
4544
object_format : 1;
4645
const struct git_hash_algo *hash_algo;
@@ -190,9 +189,6 @@ static int set_option(const char *name, const char *value)
190189
} else if (!strcmp(name, "from-promisor")) {
191190
options.from_promisor = 1;
192191
return 0;
193-
} else if (!strcmp(name, "no-dependents")) {
194-
options.no_dependents = 1;
195-
return 0;
196192
} else if (!strcmp(name, "filter")) {
197193
options.filter = xstrdup(value);
198194
return 0;
@@ -1175,8 +1171,6 @@ static int fetch_git(struct discovery *heads,
11751171
strvec_push(&args, "--deepen-relative");
11761172
if (options.from_promisor)
11771173
strvec_push(&args, "--from-promisor");
1178-
if (options.no_dependents)
1179-
strvec_push(&args, "--no-dependents");
11801174
if (options.filter)
11811175
strvec_pushf(&args, "--filter=%s", options.filter);
11821176
strvec_push(&args, url.buf);

transport.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,6 @@ static int set_git_option(struct git_transport_options *opts,
232232
} else if (!strcmp(name, TRANS_OPT_FROM_PROMISOR)) {
233233
opts->from_promisor = !!value;
234234
return 0;
235-
} else if (!strcmp(name, TRANS_OPT_NO_DEPENDENTS)) {
236-
opts->no_dependents = !!value;
237-
return 0;
238235
} else if (!strcmp(name, TRANS_OPT_LIST_OBJECTS_FILTER)) {
239236
list_objects_filter_die_if_populated(&opts->filter_options);
240237
parse_list_objects_filter(&opts->filter_options, value);
@@ -359,7 +356,6 @@ static int fetch_refs_via_pack(struct transport *transport,
359356
args.cloning = transport->cloning;
360357
args.update_shallow = data->options.update_shallow;
361358
args.from_promisor = data->options.from_promisor;
362-
args.no_dependents = data->options.no_dependents;
363359
args.filter_options = data->options.filter_options;
364360
args.stateless_rpc = transport->stateless_rpc;
365361
args.server_options = transport->server_options;

transport.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ struct git_transport_options {
1616
unsigned update_shallow : 1;
1717
unsigned deepen_relative : 1;
1818
unsigned from_promisor : 1;
19-
unsigned no_dependents : 1;
2019

2120
/*
2221
* If this transport supports connect or stateless-connect,
@@ -201,12 +200,6 @@ void transport_check_allowed(const char *type);
201200
/* Indicate that these objects are being fetched by a promisor */
202201
#define TRANS_OPT_FROM_PROMISOR "from-promisor"
203202

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-
210203
/* Filter objects for partial clone and fetch */
211204
#define TRANS_OPT_LIST_OBJECTS_FILTER "filter"
212205

0 commit comments

Comments
 (0)