On 25/03/24 09:32AM, Phillip Wood wrote: > Hi Justin > > On 21/03/2025 23:16, Justin Tobler wrote: > > In 199f44cb2ead (builtin/clone: allow remote helpers to detect repo, > > 2024-02-27), clones started partially initializing the refdb before > > executing the remote helpers by creating a HEAD file and "refs/" > > directory. This has resulted in some scenarios where git-clone(1) now > > prints the default branch name advice message where it previously did > > not. > > > > A side-effect of the HEAD file already existing, is that computation of > > the default branch name is handled later in execution. This matters > > because prior to 97abaab5f6 (refs: drop `git_default_branch_name()`, > > 2024-05-17), the default branch value would be computed during its first > > execution and cached. Subsequent invocations would simply return the > > cached value. Since the next `git_default_branch_name()` call site, > > which is invoked through `guess_remote_head()`, is not configured to > > suppress the advice message, computing the default branch name results > > in the advice message being printed. > > > > Configure `guess_remote_head()` to suppress the advice message, > > restoring the previous behavior. > > > > Signed-off-by: Justin Tobler <jltobler@xxxxxxxxx> > > --- > > builtin/clone.c | 3 ++- > > t/t5607-clone-bundle.sh | 12 ++++++++++++ > > 2 files changed, 14 insertions(+), 1 deletion(-) > > > > diff --git a/builtin/clone.c b/builtin/clone.c > > index f14229abf4..a4008715ec 100644 > > --- a/builtin/clone.c > > +++ b/builtin/clone.c > > @@ -1523,7 +1523,8 @@ int cmd_clone(int argc, > > } > > remote_head = find_ref_by_name(refs, "HEAD"); > > - remote_head_points_at = guess_remote_head(remote_head, mapped_refs, 0); > > + remote_head_points_at = guess_remote_head(remote_head, mapped_refs, > > + REMOTE_GUESS_HEAD_QUIET); > > There is another caller of guess_remote_head() in wanted_peer_refs() which I > think we probably want to be quiet as well. I don't see how it is helpful to > the user to prompt them about setting the default branch name used when > creating local repositories during a clone of a remote repository. For `wanted_peer_refs()` to invoke `guess_remote_head()`, the `--single-branch` option must be set. This means, outside of the bundle clone example, there is another way to get unexpected advice message to print. Interestingly, if you perform a bundle clone with the `--single-branch` option, the same advice message prints twice. I'll send a followup version that also suppresses the unwanted advice message from `wanted_peer_refs()`. Thanks, -Justin