Re: [PATCH 3/3] gitweb: Link to "git describe"'d commits in log messages
- From
Jakub Narębski <jnareb@gmail.com>
- Date
- Sep 21, 2016, 19:13 UTC
- Message-ID
- <f6cceb0a-9224-70ef-4592-ce34fe8704fd@gmail.com>
- In-Reply-To
- <CACBZZX5QF7FztmU-mqOEx40kC-PpQ9SqcL8+3HtuntcRZ1tWzA@mail.gmail.com>
W dniu 21.09.2016 o 19:58, Ævar Arnfjörð Bjarmason pisze:
> On Wed, Sep 21, 2016 at 7:09 PM, Jakub Narębski <jnareb@gmail.com> wrote: >> W dniu 21.09.2016 o 13:44, Ævar Arnfjörð Bjarmason napisał:
Show 20 quoted lines
>>> + (?<!-) # see strbuf_check_tag_ref(). Tags can't start with - >>> + [A-Za-z0-9.-]+ >>> + (?!\.) # refs can't end with ".", see check_refname_format() >> >> If we can assume that tag name is at least two characters (instead of >> at least one character), we could get rid of those extended regexp >> lookaround assertions: >> >> (?<!pattern) - zero-width negative lookbehind assertion >> (?!pattern) - zero-width negative lookahead assertion >> >> That is: >> >> + [A-Za-z0-9.] # see strbuf_check_tag_ref(). Tags can't start with - >> + [A-Za-z0-9.-]* >> + [A-Za-z0-9-] # refs can't end with ".", see check_refname_format() > > Why get rid of them? I'm all for improving the regex, there's bound to > be lots of bugs in it, but since it's perl we can freely use its > extended features.
Ah, all right. I was wondering how zero width assertions / patterns interact with each other, but zero-width negative lookaround assertions are really quite simple.
Show 6 quoted lines
> >> Also, the canonical documentation for what is allowed in refnames >> is git-check-ref-format(1)... though it does not look like it includes >> "tags cannot start with '-'". > > Yeah, looks like that manpage needs to be patched.
Right.
>
>> Anyway, perhaps 'is it valid refname' could be passed to a subroutine,
>> or a named regexp (which might be more involved, like disallowing two
>> consecutive dots, e.g. "(?!.*\.{2})" at beginning).I wonder if rules for valid tag name can be described in extended regexp, and if it is, how readable would it be.
Regards,
-- Jakub Narębski