Subject: Re: [PATCH 2/2] fetch: add branch.*.merge to default ref-prefix extension

From: Junio C Hamano <[email-masked]>
Date: Thu, 08 Sep 2022 22:23:43 -0700

Jeff King <[email-masked]> writes:

> The code in fetch's add_merge_config() that does branch_merge_matches()
> comes from 85682c1903 (Correct handling of branch.$name.merge in
> builtin-fetch, 2007-09-18), but I don't see any indication there that
> non-qualified refs were intended.
>
> So I could either way: non-qualified refs in branch.*.merge has always
> worked, and we should continue to support it. Or it was never intended
> to work, and we are not obligated to continue supporting random things.

Yeah, it looks like it was working by accident.  I do not care too
deeply about folks who edit their configuration files to futz with
branch.<name>.merge, and "checkout -t -b" and "branch -t" commands
have been recording only full refs, so it is tempting to tighten
branch_merge_matches() to only allow full refname.  The only thing
that makes me hesitate to start writing code to do so is that some
third-party tools might have taken advantage of the fact that using
a branch-name was "working" by accident.

> I do think "continue supporting" would probably just mean using
> expand_ref_prefix() here as you suggest. It does increase the size of
> our request, and the work the server has to do when it matches the
> prefixes (which is inherently linear on the number of prefixes we give
> it).

Giving extra garbage to the set of prefixes does not hurt the
correctness, but we didn't add the extra prefix for
branch.<name>.merge before this fix, so not using
expand_ref_prefix() is not breaking anybody who weren't broken
before.  So I think it may be OK to support only the full refs at
first.  It's just that folks who didn't have full refname as the
value is not helped by our fix.

If enough folks complain that they have handcrafted (or prepared by
third-party tools) branch.<name>.merge that is not a full refname,
we could switch to expand_ref_prefix() and as long as the refnames
on the remote side is not ambiguous, things will still work
correctly, but I'd prefer to keep it tight until we actually hear
complaints.

Thanks.