Re: [PATCH 2/2] clone: suppress unexpected default branch advice
- From
Justin Tobler <jltobler@gmail.com>
- Date
- Mar 20, 2025, 23:36 UTC
- Message-ID
- <7id72d5g7glcp3xbsvhl4p2tpavs6dfisxhz7xvvdavdnkd5gp@nqznubj7rnbr>
- In-Reply-To
- <Z9ukEUvuiPUQ3eiI@pks.im>
On 25/03/20 06:13AM, Patrick Steinhardt wrote:
Show 20 quoted lines
> On Wed, Mar 19, 2025 at 08:46:46PM -0500, Justin Tobler wrote:
> > diff --git a/builtin/clone.c b/builtin/clone.c
> > index 9eb66234bc..3b166b05e3 100644
> > --- a/builtin/clone.c
> > +++ b/builtin/clone.c
> > @@ -1523,7 +1523,7 @@ 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, 0);
> > + remote_head_points_at = guess_remote_head(remote_head, mapped_refs, 0, 1);
> >
> > if (option_branch) {
> > our_head_points_at = find_remote_branch(mapped_refs, option_branch);
>
> Makes sense. You don't have control over the branch name anyway when
> cloning, so it's nonsensical to print that advise. Another subsequent
> step could be to turn the `advise()` into `advise_if_enabled()`, but
> that change isn't really needed for git-clone(1) because there wouldn't
> ever be a reason to print it.As you mentioned, in this specific situation printing the advice doesn't make much sense. It would probably be a good idea to allow this message to be suppressed from other call sites if requested to do so though. I'll add another patch that turns it into `advise_if_enabled()` to support this.
> Do we want to add a test somewhere that demonstrates that we don't print > the advise anymore?
Ya, I'll go ahead and include this in my next version.
Thanks, -Justin