Re: [GSoC][RFC PATCH v4 3/5] builtin/refs: add list subcommand

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 01/08/2025 16:49, Phillip Wood wrote:
On 01/08/2025 15:43, Junio C Hamano wrote:
Phillip Wood <phillip.wood123@xxxxxxxxx> writes:

What does a double-asterisk currently do in these patterns?

refs/heads/m** seems to behave like refs/heads/m*. I'm a bit surprised by that as for-each-ref seems to set WM_PATHNAME and I thought that our wildmatch code used '**' to match any character in that case.

I'd forgotten the rules for '**' - it must come after a slash and be followed by a slash if it is not at the end of a pattern otherwise it is silently converted to '*'. I wish our wildmatch code at least warned when it did that. So one can query all the branches beginning with "m" by passing

    'refs/heads/m*' 'refs/heads/m*/**'

which isn't as convenient as it could be but it is possible.

If it
is not doing anything useful, perhaps we should make it match any
letter, without getting constrained by hierarchy boundaries?  IOW,
a "fix" might be to make sure the following happens?

  - "refs/heads/m*" matches all local branches whose name starts with
    'm' like 'morning', but not the ones inside subhierarchies that
    start with 'm' like 'mid/night'.

  - "refs/heads/m**" matches all local branches whose name starts
    with 'm' and in the ones inside subhierarchies that start with
    'm'.

That sounds like a good idea

Now I'm not so sure. We could add a flag to wildmatch() that allows ** to match any character anywhere in a pattern (I think that is how the code behaved when it was first imported from rsync and it also rejected invalid patterns) but it if we use that flag in for-each-ref we'd be changing the behavior.

Thanks

Phillip





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux