Re: [PATCH v2] remote.c: defer remote.<name>.followRemoteHEAD validation

From
Matt Hunter <hidden>
Date
2026-11-06 09:35:04
Reply to
Junio C Hamano, 2026-11-06
On Thu Nov 5, 2026 at 11:03 PM EST, Junio C Hamano wrote:
Hmph, interesting.  Can you rewrite Colin's patch using this, and
then merge the result into 'seen' (after reverting Colin's topic
ch/remote-defer-follow-remote-head-validation from 'seen' first) to
see how badly it crashes with other topics in flight?
I still have the commit sitting around.  I tried this and a replay of
the current topic to compare -- the conflict is the same in both
cases.  eg: Nothing else in flight is touching the
get_follow_remote_head() function.


static int do_fetch(struct transport *transport,
		    struct refspec *rs,
		    const struct fetch_config *config,
		    struct list_objects_filter_options *filter_options,
		    struct oidset *updated_tips)
{
	struct ref_transaction *transaction = NULL;
	struct ref *ref_map = NULL;
	struct display_state display_state = { 0 };
	int autotags = (transport->remote->fetch_tags == 1);
	int retcode = 0;
	const struct ref *remote_refs;
	struct transport_ls_refs_options transport_ls_refs_options =
		TRANSPORT_LS_REFS_OPTIONS_INIT;
	struct fetch_head fetch_head = { 0 };
	struct strbuf err = STRBUF_INIT;
	struct ref_update_display_info_array display_array = { 0 };
	struct strmap rejected_refs = STRMAP_INIT;
	int summary_width = 0;
	int follow_remote_head = FOLLOW_REMOTE_NEVER;
<<<<<<< HEAD
	bool apply_follow_remote_head_config = false;
=======
	const char *no_warn_branch = NULL;
quoted
quoted
quoted
quoted
quoted
quoted
try-merge
	if (tags == TAGS_DEFAULT) {
		if (transport->remote->fetch_tags == 2)
			tags = TAGS_SET;
		if (transport->remote->fetch_tags == -1)
			tags = TAGS_UNSET;
	}

	/* if not appending, truncate FETCH_HEAD */
	if (!append && write_fetch_head) {
		retcode = truncate_fetch_head();
		if (retcode)
			goto cleanup;
	}

	if (rs->nr) {
		refspec_ref_prefixes(rs, &transport_ls_refs_options.ref_prefixes);
	} else if (transport->remote->fetch.nr) {
		refspec_ref_prefixes(&transport->remote->fetch,
				     &transport_ls_refs_options.ref_prefixes);
		apply_follow_remote_head_config = true;

<<<<<<< HEAD
		/*
		 * The configured refspec may not cover the current
		 * branch's upstream (e.g. a narrowed -t refspec), so
		 * make sure we can still fetch it regardless.
		 */
		collect_upstream_from_remote(the_repository, transport->remote,
					      NULL, &transport_ls_refs_options.ref_prefixes);
	} else {
		/*
		 * The --refmap command line option, if given, takes
		 * precedence over remote.<name>.fetchRefmap.
		 */
		struct refspec *effective_refmap = refmap.nr ? &refmap :
			&transport->remote->refmap;

		if (effective_refmap->nr) {
			branches_tracking_remote(the_repository, transport->remote,
						  &transport_ls_refs_options.ref_prefixes);
			apply_follow_remote_head_config = true;
		} else {
			collect_upstream_from_remote(the_repository, transport->remote,
						      NULL, &transport_ls_refs_options.ref_prefixes);
=======
		if (transport->remote->fetch.nr) {
			refspec_ref_prefixes(&transport->remote->fetch,
					     &transport_ls_refs_options.ref_prefixes);
			follow_remote_head =
				get_follow_remote_head(transport, config,
						&no_warn_branch);
		}
		if (branch && branch_has_merge_config(branch) &&
		    !strcmp(branch->remote_name, transport->remote->name)) {
			int i;
			for (i = 0; i < branch->merge_nr; i++) {
				strvec_push(&transport_ls_refs_options.ref_prefixes,
					    branch->merge[i]->src);
			}
quoted
quoted
quoted
quoted
quoted
quoted
try-merge
		}

		/*
		 * If there are no refs specified to fetch, then we just
		 * fetch HEAD; mention that to narrow the advertisement.
		 */
		if (!transport_ls_refs_options.ref_prefixes.nr)
			strvec_push(&transport_ls_refs_options.ref_prefixes,
				    "HEAD");
	}
Thread (19 messages) 19 messages, 3 authors, last reply 1h ago
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help