From: Phillip Wood <phillip.wood123@gmail.com>
To: Justin Tobler <jltobler@gmail.com>, git@vger.kernel.org
Cc: ps@pks.im, alan@norbauer.com
Subject: Re: [PATCH v2 2/3] builtin/clone: suppress unexpected default branch advice
Date: Mon, 24 Mar 2025 09:32:18 +0000 [thread overview]
Message-ID: <966aa1cc-fd4a-42b7-a241-0537767021ed@gmail.com> (raw)
In-Reply-To: <20250321231639.180762-3-jltobler@gmail.com>
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@gmail.com>
> ---
> 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.
Best Wishes
Phillip
>
> if (option_branch) {
> our_head_points_at = find_remote_branch(mapped_refs, option_branch);
> diff --git a/t/t5607-clone-bundle.sh b/t/t5607-clone-bundle.sh
> index 82e3621ec5..f526bb1c69 100755
> --- a/t/t5607-clone-bundle.sh
> +++ b/t/t5607-clone-bundle.sh
> @@ -211,4 +211,16 @@ test_expect_success 'git bundle v3 rejects unknown capabilities' '
> test_grep "unknown capability .unknown=silly." output
> '
>
> +test_expect_success 'cloning bundle suppresses default branch name advice' '
> + test_when_finished "rm -rf bundle-repo clone-repo" &&
> +
> + git init bundle-repo &&
> + git -C bundle-repo commit --allow-empty -m init &&
> + git -C bundle-repo bundle create repo.bundle --all &&
> + GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= \
> + git clone bundle-repo/repo.bundle clone-repo 2>err &&
> +
> + test_grep ! "hint: " err
> +'
> +
> test_done
next prev parent reply other threads:[~2025-03-24 9:32 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-19 9:53 bug: git shows hints that should be suppressed alan
2025-03-19 9:58 ` alan
2025-03-19 14:45 ` Elijah Newren
2025-03-20 1:36 ` Justin Tobler
2025-03-20 1:46 ` [PATCH 0/2] clone: suppress unexpected advice message during clone Justin Tobler
2025-03-20 1:46 ` [PATCH 1/2] remote: allow `guess_remote_head()` to suppress advice Justin Tobler
2025-03-20 5:13 ` Patrick Steinhardt
2025-03-20 23:30 ` Justin Tobler
2025-03-21 8:52 ` Junio C Hamano
2025-03-20 1:46 ` [PATCH 2/2] clone: suppress unexpected default branch advice Justin Tobler
2025-03-20 5:13 ` Patrick Steinhardt
2025-03-20 23:36 ` Justin Tobler
2025-03-20 11:10 ` [PATCH 0/2] clone: suppress unexpected advice message during clone Phillip Wood
2025-03-20 23:48 ` Justin Tobler
2025-03-21 16:42 ` Phillip Wood
2025-03-21 23:16 ` [PATCH v2 0/3] " Justin Tobler
2025-03-21 23:16 ` [PATCH v2 1/3] remote: allow `guess_remote_head()` to suppress advice Justin Tobler
2025-03-24 9:31 ` Phillip Wood
2025-03-24 15:21 ` Justin Tobler
2025-03-24 19:29 ` phillip.wood123
2025-03-21 23:16 ` [PATCH v2 2/3] builtin/clone: suppress unexpected default branch advice Justin Tobler
2025-03-24 9:32 ` Phillip Wood [this message]
2025-03-24 15:35 ` Justin Tobler
2025-03-21 23:16 ` [PATCH v2 3/3] advice: allow disabling default branch name advice Justin Tobler
2025-03-24 9:32 ` Phillip Wood
2025-03-23 19:38 ` [PATCH v2 0/3] clone: suppress unexpected advice message during clone Junio C Hamano
2025-03-25 0:51 ` [PATCH v3 " Justin Tobler
2025-03-25 0:51 ` [PATCH v3 1/3] remote: allow `guess_remote_head()` to suppress advice Justin Tobler
2025-03-25 0:51 ` [PATCH v3 2/3] builtin/clone: suppress unexpected default branch advice Justin Tobler
2025-03-25 0:51 ` [PATCH v3 3/3] advice: allow disabling default branch name advice Justin Tobler
2025-03-25 14:35 ` [PATCH v3 0/3] clone: suppress unexpected advice message during clone Phillip Wood
2025-03-20 4:05 ` bug: git shows hints that should be suppressed alan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=966aa1cc-fd4a-42b7-a241-0537767021ed@gmail.com \
--to=phillip.wood123@gmail.com \
--cc=alan@norbauer.com \
--cc=git@vger.kernel.org \
--cc=jltobler@gmail.com \
--cc=phillip.wood@dunelm.org.uk \
--cc=ps@pks.im \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).