@ -285,10 +285,8 @@ static int find_common(struct fetch_negotiator *negotiator,
PACKET_READ_CHOMP_NEWLINE |
PACKET_READ_CHOMP_NEWLINE |
PACKET_READ_DIE_ON_ERR_PACKET);
PACKET_READ_DIE_ON_ERR_PACKET);
if (!args->no_dependents) {
mark_tips(negotiator, args->negotiation_tips);
mark_tips(negotiator, args->negotiation_tips);
for_each_cached_alternate(negotiator, insert_one_alternate_object);
for_each_cached_alternate(negotiator, insert_one_alternate_object);
}
fetching = 0;
fetching = 0;
for ( ; refs ; refs = refs->next) {
for ( ; refs ; refs = refs->next) {
@ -305,12 +303,8 @@ static int find_common(struct fetch_negotiator *negotiator,
* We use lookup_object here because we are only
* We use lookup_object here because we are only
* interested in the case we *know* the object is
* interested in the case we *know* the object is
* reachable and we have already scanned it.
* reachable and we have already scanned it.
*
* Do this only if args->no_dependents is false (if it is true,
* we cannot trust the object flags).
*/
*/
if (!args->no_dependents &&
if (((o = lookup_object(the_repository, remote)) != NULL) &&
((o = lookup_object(the_repository, remote)) != NULL) &&
(o->flags & COMPLETE)) {
(o->flags & COMPLETE)) {
continue;
continue;
}
}
@ -410,8 +404,6 @@ static int find_common(struct fetch_negotiator *negotiator,
trace2_region_enter("fetch-pack", "negotiation_v0_v1", the_repository);
trace2_region_enter("fetch-pack", "negotiation_v0_v1", the_repository);
flushes = 0;
flushes = 0;
retval = -1;
retval = -1;
if (args->no_dependents)
goto done;
while ((oid = negotiator->next(negotiator))) {
while ((oid = negotiator->next(negotiator))) {
packet_buf_write(&req_buf, "have %s\n", oid_to_hex(oid));
packet_buf_write(&req_buf, "have %s\n", oid_to_hex(oid));
print_verbose(args, "have %s", oid_to_hex(oid));
print_verbose(args, "have %s", oid_to_hex(oid));
@ -666,9 +658,7 @@ struct loose_object_iter {
/*
/*
* Mark recent commits available locally and reachable from a local ref as
* Mark recent commits available locally and reachable from a local ref as
* COMPLETE. If args->no_dependents is false, also mark COMPLETE remote refs as
* COMPLETE.
* COMMON_REF (otherwise, we are not planning to participate in negotiation, and
* thus do not need COMMON_REF marks).
*
*
* The cutoff time for recency is determined by this heuristic: it is the
* The cutoff time for recency is determined by this heuristic: it is the
* earliest commit time of the objects in refs that are commits and that we know
* 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,
struct fetch_negotiator negotiator_alloc;
struct fetch_negotiator negotiator_alloc;
struct fetch_negotiator *negotiator;
struct fetch_negotiator *negotiator;
if (args->no_dependents) {
negotiator = &negotiator_alloc;
negotiator = NULL;
fetch_negotiator_init(r, negotiator);
} else {
negotiator = &negotiator_alloc;
fetch_negotiator_init(r, negotiator);
}
sort_ref_list(&ref, ref_compare_name);
sort_ref_list(&ref, ref_compare_name);
QSORT(sought, nr_sought, cmp_ref_by_name);
QSORT(sought, nr_sought, cmp_ref_by_name);
@ -1062,15 +1048,11 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args,
if (!server_supports_hash(the_hash_algo->name, NULL))
if (!server_supports_hash(the_hash_algo->name, NULL))
die(_("Server does not support this repository's object format"));
die(_("Server does not support this repository's object format"));
if (!args->no_dependents) {
mark_complete_and_common_ref(negotiator, args, &ref);
mark_complete_and_common_ref(negotiator, args, &ref);
filter_refs(args, &ref, sought, nr_sought);
filter_refs(args, &ref, sought, nr_sought);
if (everything_local(args, &ref)) {
if (everything_local(args, &ref)) {
packet_flush(fd[1]);
packet_flush(fd[1]);
goto all_done;
goto all_done;
}
} else {
filter_refs(args, &ref, sought, nr_sought);
}
}
if (find_common(negotiator, args, fd, &oid, ref) < 0)
if (find_common(negotiator, args, fd, &oid, ref) < 0)
if (!args->keep_pack)
if (!args->keep_pack)
@ -1119,7 +1101,7 @@ static void add_shallow_requests(struct strbuf *req_buf,
packet_buf_write(req_buf, "deepen-relative\n");
packet_buf_write(req_buf, "deepen-relative\n");
}
}
static void add_wants(int no_dependents, const struct ref *wants, struct strbuf *req_buf)
static void add_wants(const struct ref *wants, struct strbuf *req_buf)
{
{
int use_ref_in_want = server_supports_feature("fetch", "ref-in-want", 0);
int use_ref_in_want = server_supports_feature("fetch", "ref-in-want", 0);
@ -1136,12 +1118,8 @@ static void add_wants(int no_dependents, const struct ref *wants, struct strbuf
* We use lookup_object here because we are only
* We use lookup_object here because we are only
* interested in the case we *know* the object is
* interested in the case we *know* the object is
* reachable and we have already scanned it.
* reachable and we have already scanned it.
*
* Do this only if args->no_dependents is false (if it is true,
* we cannot trust the object flags).
*/
*/
if (!no_dependents &&
if (((o = lookup_object(the_repository, remote)) != NULL) &&
((o = lookup_object(the_repository, remote)) != NULL) &&
(o->flags & COMPLETE)) {
(o->flags & COMPLETE)) {
continue;
continue;
}
}
@ -1275,19 +1253,14 @@ static int send_fetch_request(struct fetch_negotiator *negotiator, int fd_out,
}
}
/* add wants */
/* add wants */
add_wants(args->no_dependents, wants, &req_buf);
add_wants(wants, &req_buf);
if (args->no_dependents) {
/* Add all of the common commits we've found in previous rounds */
packet_buf_write(&req_buf, "done");
add_common(&req_buf, common);
ret = 1;
} else {
/* Add all of the common commits we've found in previous rounds */
add_common(&req_buf, common);
/* Add initial haves */
/* Add initial haves */
ret = add_haves(negotiator, seen_ack, &req_buf,
ret = add_haves(negotiator, seen_ack, &req_buf,
haves_to_send, in_vain);
haves_to_send, in_vain);
}
/* Send request */
/* Send request */
packet_buf_flush(&req_buf);
packet_buf_flush(&req_buf);
@ -1547,12 +1520,8 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
struct string_list packfile_uris = STRING_LIST_INIT_DUP;
struct string_list packfile_uris = STRING_LIST_INIT_DUP;
int i;
int i;
if (args->no_dependents) {
negotiator = &negotiator_alloc;
negotiator = NULL;
fetch_negotiator_init(r, negotiator);
} else {
negotiator = &negotiator_alloc;
fetch_negotiator_init(r, negotiator);
}
packet_reader_init(&reader, fd[0], NULL, 0,
packet_reader_init(&reader, fd[0], NULL, 0,
PACKET_READ_CHOMP_NEWLINE |
PACKET_READ_CHOMP_NEWLINE |
@ -1576,21 +1545,16 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
args->deepen = 1;
args->deepen = 1;
/* Filter 'ref' by 'sought' and those that aren't local */
/* Filter 'ref' by 'sought' and those that aren't local */
if (!args->no_dependents) {
mark_complete_and_common_ref(negotiator, args, &ref);
mark_complete_and_common_ref(negotiator, args, &ref);
filter_refs(args, &ref, sought, nr_sought);
filter_refs(args, &ref, sought, nr_sought);
if (everything_local(args, &ref))
if (everything_local(args, &ref))
state = FETCH_DONE;
state = FETCH_DONE;
else
else
state = FETCH_SEND_REQUEST;
mark_tips(negotiator, args->negotiation_tips);
for_each_cached_alternate(negotiator,
insert_one_alternate_object);
} else {
filter_refs(args, &ref, sought, nr_sought);
state = FETCH_SEND_REQUEST;
state = FETCH_SEND_REQUEST;
}
mark_tips(negotiator, args->negotiation_tips);
for_each_cached_alternate(negotiator,
insert_one_alternate_object);
break;
break;
case FETCH_SEND_REQUEST:
case FETCH_SEND_REQUEST:
if (!negotiation_started) {
if (!negotiation_started) {
@ -1911,20 +1875,6 @@ struct ref *fetch_pack(struct fetch_pack_args *args,
if (nr_sought)
if (nr_sought)
nr_sought = remove_duplicates_in_refs(sought, nr_sought);
nr_sought = remove_duplicates_in_refs(sought, nr_sought);
if (args->no_dependents && !args->filter_options.choice) {
/*
* The protocol does not support requesting that only the
* wanted objects be sent, so approximate this by setting a
* "blob:none" filter if no filter is already set. This works
* for all object types: note that wanted blobs will still be
* sent because they are directly specified as a "want".
*
* NEEDSWORK: Add an option in the protocol to request that
* only the wanted objects be sent, and implement it.
*/
parse_list_objects_filter(&args->filter_options, "blob:none");
}
if (version != protocol_v2 && !ref) {
if (version != protocol_v2 && !ref) {
packet_flush(fd[1]);
packet_flush(fd[1]);
die(_("no matching remote head"));
die(_("no matching remote head"));