Subject: Re: Unexpected (bug-like) behavior in `git ls-remote` matching.

From: Junio C Hamano <[email-masked]>
Date: Wed, 08 Feb 2023 09:46:59 -0800

Jeff King <[email-masked]> writes:

> Oh, and I forgot to mention: the documentation for ls-remote is quite
> weak here, and simply says "matching" without defining it. So the most
> obvious improvement is fixing that documentation to describe the current
> rules (which AFAIK is basically matching the pattern as a glob, but with
> an implicit "/" anchor, but somebody should double check the code before
> writing a documentation patch).

Very much.  

On the pattern side we add */ in front of the given pattern (so,
'master' becomes "*/master", and 'refs/heads/master' becomes
'*/refs/heads/master), and run wildmatch() against refs prefixed
with '/' (so 'refs/heads/master' becomes '/refs/heads/master' and
matches '*/master', and it also matches '*/refs/heads/master').

THanks.