From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fout-b5-smtp.messagingengine.com (fout-b5-smtp.messagingengine.com [202.12.124.148]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C38A931195B for ; Wed, 26 Aug 2026 16:46:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.148 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787762793; cv=none; b=tzO3ifkWvDp1iozkA5qHG0VFj9mFaPdRHoEIxhCUWZN9yNFrjeGWf8cI6wEVYAqEKvT4CV5rEazszEdEPatvYIGq2FvsSRihm2FXsBCCqmDStct0cOTVmtF13F3YtjW+LF9PRswel0PiV4kFEpfvQOFx72PYhTDDflvaTUus68s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787762793; c=relaxed/simple; bh=5IqJD9VolkbJEAPxeZlUF+kHU0E0KfTOCF6UMACbfGk=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=CRV1pQnH9aTqWXEzkEBBqSyAXcl5XtX99cktLlQTP3DD55bNnZIl6FXIhf3gOjLFQu0EGOJZenz8MkQLq+GfFvbB5Wf/asjaFZ/FHobko4nEXoAfvFmsS6GItKMriZrx/qUrslzq26Ne7mInK1rk85ZA8EvjyCBmLyeqeQWfKwM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com; spf=pass smtp.mailfrom=pobox.com; dkim=pass (2048-bit key) header.d=pobox.com header.i=@pobox.com header.b=gHv5KVwW; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=NYWZP5Jk; arc=none smtp.client-ip=202.12.124.148 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pobox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pobox.com header.i=@pobox.com header.b="gHv5KVwW"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="NYWZP5Jk" Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfout.stl.internal (Postfix) with ESMTP id 64B721D0003E; Wed, 26 Aug 2026 12:46:11 -0400 (EDT) Received: from phl-frontend-02 ([10.202.2.161]) by phl-compute-05.internal (MEProxy); Wed, 26 Aug 2026 12:46:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pobox.com; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1787762771; x=1787849171; bh=YRdlePeVJC sI49yHtCamHFsBGJEhMvR8twY4JSYFiH0=; b=gHv5KVwWxnvWTP58s66uLnLWIK cgPiCB/pAfzbJRAY2IbruF7IhHW50ADtARfwn+WWN51VrbfpkiO9S0JQ9dHXp5qQ 7gHxZIR2niAxbgbjfKkAS1yRCWMIZXqGdUTMum81UQ8oarQjdCjvIPWbCPl1JlqJ eX3MCefnCTNkvnVh1TdQ0+RdkUmiHI6dso82rguoPJOwe7qO5ABpbLw18mqxklWS ef9Tj75Txx9cJzLiC9FsS5apbQOm9nzULwKbr9UjEBTQyjOsg0h47uKLIIBO1UBX Xco3elASBoPbVqxAeCtSFoyAea9tXFnH0GzcFD1U+cregB3GnGRyUfj9kUsQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1787762771; x=1787849171; bh=YRdlePeVJCsI49yHtCamHFsBGJEhMvR8twY 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ERr0TQ X-ME-Proxy: Feedback-ID: if26b431b:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 26 Aug 2026 12:46:10 -0400 (EDT) From: Junio C Hamano To: "Yoichi NAKAYAMA via GitGitGadget" Cc: git@vger.kernel.org, Harald Nordgren , Yoichi Nakayama , "D. Ben Knoble" Subject: Re: [PATCH v9 2/4] checkout: improve message for ambiguous remote branch name In-Reply-To: <89c0f4d30317ebf7cda884710944e9a6f23d46fe.1787741111.git.gitgitgadget@gmail.com> (Yoichi NAKAYAMA via GitGitGadget's message of "Wed, 26 Aug 2026 10:45:08 +0000") References: <89c0f4d30317ebf7cda884710944e9a6f23d46fe.1787741111.git.gitgitgadget@gmail.com> Date: Wed, 26 Aug 2026 09:46:09 -0700 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain "Yoichi NAKAYAMA via GitGitGadget" writes: > diff --git a/checkout.c b/checkout.c > index 1588b116ee..2806b783ec 100644 > --- a/checkout.c > +++ b/checkout.c > @@ -8,6 +8,7 @@ > #include "checkout.h" > #include "config.h" > #include "strbuf.h" > +#include "string-list.h" > > struct tracking_name_data { > /* const */ char *src_ref; > @@ -17,6 +18,7 @@ struct tracking_name_data { > const char *default_remote; > char *default_dst_ref; > struct object_id *default_dst_oid; > + struct string_list **remote_names; > }; Do we really need double indirection? The unique_tracking_name() function that uses this struct for callback receives a pointer to the string list the caller has, and the job of the callback is to append to the supplied string list. It is not like it wants to swap the given pointer to a string list to the pointer to another string list, so I do not see a reason for anybody involved in the callchain to want this as a pointer to a pointer. > #define TRACKING_NAME_DATA_INIT { 0 } > @@ -39,6 +41,8 @@ static int check_tracking_name(struct remote *remote, void *cb_data) > oidcpy(dst, cb->dst_oid); > cb->default_dst_oid = dst; > } > + if (cb->remote_names) > + string_list_append(*cb->remote_names, remote->name); If we lose the double indirection, this can become string_list_append(cb->remote_names, remote->name); > char *unique_tracking_name(const char *name, struct object_id *oid, > - int *dwim_remotes_matched) > + int *dwim_remotes_matched, > + struct string_list *dwim_remote_names) > { > struct tracking_name_data cb_data = TRACKING_NAME_DATA_INIT; > const char *default_remote = NULL; > - if (!repo_config_get_string_tmp(the_repository, "checkout.defaultremote", &default_remote)) > + > + if (!repo_config_get_string_tmp(the_repository, > + "checkout.defaultremote", > + &default_remote)) > cb_data.default_remote = default_remote; > cb_data.src_ref = xstrfmt("refs/heads/%s", name); > cb_data.dst_oid = oid; > + if (dwim_remote_names) > + cb_data.remote_names = &dwim_remote_names; And this can become cb_data.remote_names = dwim_remote_names;