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

Re: gitk: Turn short SHA1 names into links too

From
MMMikael Magnusson <mikachu@gmail.com>
Date
Sep 26, 2008, 08:21 UTC
Message-ID
<237967ef0809260121w1c7cc516tceb3be2cbebb85bc@mail.gmail.com>
In-Reply-To
<BD7D0F18-32BD-4059-9190-A2C1B101B4C1@wincent.com>
2008/9/26 Wincent Colaiuta <win@wincent.com>:
Show 40 quoted lines
> El 26/9/2008, a las 2:37, Linus Torvalds escribió:
>
>> On Thu, 25 Sep 2008, Linus Torvalds wrote:
>>>
>>> And the thing I wanted to work was to have the abbreviated SHA1's that
>>> have started to get more common in the kernel commit logs work as links
>>> in
>>> gitk too, just the way a full 40-character SHA1 link works.
>>
>> For a test-case, I just pushed out my current top-of-tree that finally
>> pushed me over the edge. I've seen this before, but I couldn't really
>> force me to do anything about it until now.
>>
>> So to see this in action, do
>>
>>        gitk v2.6.26..6ef190c
>>
>> on the current kernel repo, and notice that "Commit ee1e2c82 ("IPoIB:
>> Refresh paths .." thing, where we want that 'ee1e2c82' to be a link even
>> though it's not a full SHA1.
>>
>> Of course, the matching could be better, it will now accept any random 6+
>> character sequence of hex characters, even if they are surrounded by
>> characters that make it clear that it's not a SHA1 ("Haahahhaaaaaa!"
>> would find the 'aaaaaa' and if you have a commit that starts with that,
>> link to it ;)
>
> I know nothing about tcl/tk, but will comment anyway:
>
> It's a shame that tcl/tk regular expressions don't appear to support
> anchoring matches against word boundaries (ie. "\b").
>
> If so, a regexp like:
>
>  [regexp {\b[0-9a-f]{4,39}\b} $id]
>
> would mostly eliminate that kind of false positive. But from my reading of
> the wiki[1], looks like there's no "\b" escape sequence. Nor does it look
> like tcl/tk has support for lookahead/lookbehind assertions which could be
> used to the same effect.
\y appears to achieve this;

% regexp {abc\y} 'abc' 1 % regexp {abc\y} 'abcd' 0 % regexp {\yabc\y} 'uabc,d' 0 % regexp {\yabc\y} 'u+abc,d' 1

I have tcl/tk 8.5 so I cannot promise that isn't a new addition, I didn't look it up anywhere, but it's \y in some other implementations too, so I tried it.

-- 
Mikael Magnusson
Previous: Wincent ColaiutaNext: Brad King
Message 6 of 12 in “gitk: Turn short SHA1 names into links too”
  1. Linus TorvaldsSep 26, 2008
  2. Linus TorvaldsSep 26, 2008
  3. Wincent ColaiutaSep 26, 2008
  4. Andreas EricssonSep 26, 2008
  5. Wincent ColaiutaSep 26, 2008
  6. Mikael MagnussonSep 26, 2008
  7. Brad KingSep 26, 2008
  8. Marco CostalbaSep 26, 2008
  9. Paul MackerrasSep 27, 2008
  10. Paul MackerrasSep 27, 2008
  11. Paul MackerrasOct 20, 2008
  12. Junio C HamanoOct 21, 2008

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.