Subject: Re: [PATCH v2 4/5] fetch: teach independent negotiation (no packfile)

From: Derrick Stolee <[email-masked]>
Date: Wed, 5 May 2021 12:44:42 -0400

On 5/4/2021 5:16 PM, Jonathan Tan wrote:

> +void negotiate_using_fetch(const struct oid_array *negotiation_tips,
> +			   const struct string_list *server_options,
> +			   int stateless_rpc,
> +			   int fd[],
> +			   struct oidset *acked_commits)
> +{
> +	struct fetch_negotiator negotiator;
> +	struct packet_reader reader;
> +	struct object_array nt_object_array = OBJECT_ARRAY_INIT;
> +	struct strbuf req_buf = STRBUF_INIT;
> +	int haves_to_send = INITIAL_FLUSH;
> +	int in_vain = 0;
> +	int seen_ack = 0;
> +	int last_iteration = 0;
> +	timestamp_t min_generation = GENERATION_NUMBER_INFINITY;

...

> +		/* Process ACKs/NAKs */
> +		process_section_header(&reader, "acknowledgments", 0);
> +		while (process_ack(&negotiator, &reader, &common_oid,
> +				   &received_ready)) {
> +			struct commit *commit = lookup_commit(the_repository,
> +							      &common_oid);
> +			if (commit) {
> +				timestamp_t generation;
> +
> +				parse_commit_or_die(commit);
> +				commit->object.flags |= COMMON;
> +				generation = commit_graph_generation(commit);
> +				if (generation < min_generation)
> +					min_generation = generation;
> +			}
> +			in_vain = 0;
> +			seen_ack = 1;
> +			oidset_insert(acked_commits, &common_oid);
> +		}
> +		if (received_ready)
> +			die(_("unexpected 'ready' from remote"));
> +		else
> +			do_check_stateless_delimiter(stateless_rpc, &reader);
> +		if (can_all_from_reach_with_flag(&nt_object_array, COMMON,
> +						 REACH_SCRATCH, 0,
> +						 min_generation))
> +			last_iteration = 1;

I'm just chiming in to confirm that this use of min_generation is
correct. Thanks!

-Stolee