Thread (329 messages) 329 messages, 12 authors, 2018-03-14

Re: [PATCH v3 13/35] ls-refs: introduce ls-refs server command

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2018-02-27 00:02:40

On Sat, Feb 24 2018, Jeff King jotted:
On Thu, Feb 22, 2018 at 04:45:14PM -0800, Brandon Williams wrote:
quoted
quoted
Does the client have to be aware that we're using wildmatch? I think
they'd need "refs/heads/**" to actually implement what we usually
specify in refspecs as "refs/heads/*". Or does the lack of WM_PATHNAME
make this work with just "*"?

Do we anticipate that the client would left-anchor the refspec like
"/refs/heads/*" so that in theory the server could avoid looking outside
of /refs/heads/?
Yeah we may want to anchor it by providing the leading '/' instead of
just "refs/<blah>".
I actually wonder if we should just specify that the patterns must
_always_ be fully-qualified, but may end with a single "/*" to iterate
over wildcards. Or even simpler, that "refs/heads/foo" would find that
ref itself, and anything under it.
I agree that this is a very good trade-off for now, but I think having
an escape hatch makes sense. It looks like the protocol is implicitly
extendible since another parameter could be added, but maybe having such
a parameter from the get-go would make sense:

    pattern-type [simple|wildmatch|pcre|...]
    ref-pattern <pattern>

E.g.:

    pattern-type simple
    ref-pattern refs/tags/*
    ref-pattern refs/pull/*
    pattern-type wildmatch
    ref-pattern refs/**/2018
    pattern-type pcre
    ref-pattern ^refs/release/v-201[56789]-\d+$

I.e. each ref-pattern is typed by the pattern-type in play, with just
"simple" (with the behavior being discussed here) for now, anything else
(wildmatch, pcre etc.) would be an error.

But it allows for adding more patterns down the line, and in
e.g. in-house setups of git where you control both the server & clients
to make the trade-off that we'd like a bit more work on the server
(e.g. to match dated tags created in the last 3 months) by setting some
config option.

The discussion upthread about:
The other problem with tail-matching is that it's inefficient on the
server[...]
Is also something that's only true in the current implementation, but
doesn't need to be, so it would be unfortunate to not work in an escape
hatch for that limtiation.

E.g. if the refs were stored indexed using the method described at
https://swtch.com/~rsc/regexp/regexp4.html tail matching becomes no less
efficient than prefix matching, but a function of how many trigrams in
your index match the pattern given.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help