Re: [PATCH] worktree add: improve message for ambiguous remote branch name
- From
Yoichi Nakayama <yoichi.nakayama@gmail.com>
- Date
- Aug 10, 2026, 21:36 UTC
- Message-ID
- <CAF5D8-u23Z=f02vF1yAHGKRED8DY-v5=BNf7w-yY3vEDmJChDg@mail.gmail.com>
- In-Reply-To
- <CALnO6CAdr0ft8KFgGCFX9ueKUdX9-2DwB+SNs3Q8ykw4ne=54Q@mail.gmail.com>
On Mon, Aug 10, 2026 at 10:08 PM D. Ben Knoble <ben.knoble@gmail.com> wrote:
Show 23 quoted lines
> > -static char *dwim_branch(const char *path, char **new_branch)
> > +static char *dwim_branch(const struct add_opts *opts, const char *path, char **new_branch)
> > {
> > int n;
> > int branch_exists;
> > @@ -781,8 +791,14 @@ static char *dwim_branch(const char *path, char **new_branch)
> >
> > *new_branch = branchname;
> > if (guess_remote) {
> > + int num_matches = 0;
> > struct object_id oid;
> > - char *remote = unique_tracking_name(*new_branch, &oid, NULL);
> > + char *remote = unique_tracking_name(*new_branch, &oid, &num_matches);
> > + if (!opts->quiet && !remote && num_matches > 1) {
> > + if (advice_enabled(ADVICE_CHECKOUT_AMBIGUOUS_REMOTE_BRANCH_NAME))
> > + advise(_(message_advice_ambiguous_remote_tracking_branch));
> > + warning(_("'%s' matched multiple (%d) remote tracking branches\n"), branchname, num_matches);
> > + }
> > return remote;
> > }
> > return NULL;
>
> I suppose the extra warning won't hurt anyone's workflow :) so that's good.I removed the change (advise and warn) here in the latest patch. But I am still wondering what I should do. I think a warning would be excessive if there is no match, but the user might want to know if there are multiple matches.
Thanks,
-- Yoichi NAKAYAMA