git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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
Previous: Ævar Arnfjörð BjarmasonNext: Jakub Narębski
Message 13 of 17 in “gitweb: Fix an ancient typo in v1.7.7-rc1-1-g0866786”
  1. 1/3 gitweb: Fix an ancient typo in v1.7.7-rc1-1-g0866786Ævar Arnfjörð Bjarmason, Sep 21, 2016
  2. 2/3 gitweb: Link to 7-character SHA1SUMS in commit messagesÆvar Arnfjörð Bjarmason, Sep 21, 2016
  3. Jakub NarębskiSep 21, 2016
  4. Ævar Arnfjörð BjarmasonSep 21, 2016
  5. Jakub NarębskiSep 21, 2016
  6. Ævar Arnfjörð BjarmasonSep 21, 2016
  7. 3/3 gitweb: Link to "git describe"'d commits in log messagesÆvar Arnfjörð Bjarmason, Sep 21, 2016
  8. Junio C HamanoSep 21, 2016
  9. Jakub NarębskiSep 21, 2016
  10. Junio C HamanoSep 21, 2016
  11. Jakub NarębskiSep 21, 2016
  12. Ævar Arnfjörð BjarmasonSep 21, 2016
  13. Jakub NarębskiSep 21, 2016
  14. Jakub NarębskiSep 21, 2016
  15. Ævar Arnfjörð BjarmasonSep 21, 2016
  16. Jakub NarębskiSep 21, 2016
  17. Ævar Arnfjörð BjarmasonSep 21, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.