Show 30 quoted lines
> > @@ -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;
> > }
>
> The worktree.guessremote configuration is set. dwim_branch() is
> called when "git worktree add A/B/X" is run with a single argument
> "A/B/X", which comes here as "path", and that is munged into the
> branchname "X".
>
> We used to pass NULL as the second parameter to unique_tracking_name(),
> so we were only interested in the case where we have exactly one
> matching remote, and if there is 0 or multiple remotes with the
> named branch, we returned NULL from here.
>
> The patch does not change that, but using the branch name, we try to
> see if there are multiple matches, in that case, we give the advice
> message to say "hey, don't be so lazy, as X appears in more than one
> remote, so tell me which one you mean".I thought the problem here was that it was impossible to distinguish whether
the guess was successful, but it was not true. We can distinguish by
the message:
branch 'name' set up to track 'remote/name'.
I will not make changes to this part.Thanks,