git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: jepler@unpythonic.net
To: Linus Torvalds <torvalds@osdl.org>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: gitk "hyperlinks" (was Re: Display of merges in gitk)
Date: Fri, 5 Aug 2005 13:51:00 -0500	[thread overview]
Message-ID: <20050805185056.GF19009@unpythonic.net> (raw)
In-Reply-To: <Pine.LNX.4.58.0508050710460.3258@g5.osdl.org>

[-- Attachment #1: Type: text/plain, Size: 2305 bytes --]

On Fri, Aug 05, 2005 at 07:37:41AM -0700, Linus Torvalds wrote:
> For 2.6.13 we've been reverting some stuff lately, to make sure we get a 
> stable release. That's fine, and when I revert something I try to mention 
> the commit ID of the thing I revert in the message. Apparently others do 
> too, as indicated by a patch I just got from Petr Vandovec. So we've got 
> for example:
[snipped]

The following code worked for me on a toy commit.  I'm not sure the regular
expression in linkcommits is right if the SHA1 is followed by a colon or a comma,
as I noticed it was in your examples.  If it doesn, then removing the [[:<:]]
and [[:>:]] will probably fix it.

Things that look like SHA1s are highlighted even if they don't actually exist.

There is probably a "more right" place to do the '$ctext tag bind Commit' commands
but I didn't find it right away.

diff --git a/gitk b/gitk
--- a/gitk
+++ b/gitk
@@ -1753,6 +1753,11 @@ proc selectline {l} {
     $ctext conf -state disabled
     set commentend [$ctext index "end - 1c"]
 
+    linkcommits $ctext 0.0 $commentend
+    $ctext tag configure Commit -underline yes -foreground blue
+    $ctext tag bind Commit <Enter> { %W configure -cursor hand2 }
+    $ctext tag bind Commit <Leave> { %W configure -cursor {} }
+    $ctext tag bind Commit <Button-1><ButtonRelease-1> { linkclick %W %x %y }
     $cflist delete 0 end
     $cflist insert end "Comments"
     if {$nparents($id) == 1} {
@@ -1762,6 +1767,30 @@ proc selectline {l} {
     }
 }
 
+proc linkclick {w x y} {
+    set index [$w index @$x,$y]
+    set tags [$w tag names $index]
+    foreach c $tags {
+        if {![string match {C_*} $c]} { continue; }
+        global sha1string
+        set sha1string [string range $c 2 end]
+        gotocommit
+    }
+}
+
+proc linkcommits {w start end} {
+    while {1} {
+        set pos [$w search -regexp {[[:<:]][0-9a-fA-F]{40}[[:>:]]} $start $end]
+        if {$pos == {}} {break}
+        
+        set commit [$w get $pos "$pos+40c"]
+
+        $w tag add Commit $pos "$pos+40c"
+        $w tag add C_$commit $pos "$pos+40c"
+        set start [$w index "$pos+40c"]
+    }
+}
+
 proc selnextline {dir} {
     global selectedline
     if {![info exists selectedline]} return


[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

  reply	other threads:[~2005-08-05 19:20 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-30  1:51 Display of merges in gitk Paul Mackerras
2005-07-30  4:25 ` Junio C Hamano
2005-07-30 21:36   ` Shipping gitk as part of core git Junio C Hamano
2005-07-31 12:00     ` Paul Mackerras
2005-07-31 18:48       ` Junio C Hamano
2005-07-30 14:32 ` gitk merge display bugs (was: Re: Display of merges in gitk) Sergey Vlasov
2005-08-05 14:10 ` Display of merges in gitk Linus Torvalds
2005-08-05 14:37   ` gitk "hyperlinks" (was Re: Display of merges in gitk) Linus Torvalds
2005-08-05 18:51     ` jepler [this message]
2005-08-06  3:36     ` Kay Sievers
2005-08-06 15:44       ` Linus Torvalds
2005-08-07  5:51         ` Kay Sievers
2005-08-06 18:27       ` gitweb "tag" display Junio C Hamano
2005-08-06 18:49         ` Junio C Hamano
2005-08-19 23:21           ` Paul Mackerras
2005-08-19 23:43             ` Johannes Schindelin
2005-08-20 19:09             ` Junio C Hamano
2005-08-07  5:50         ` Kay Sievers
2005-08-06 13:16     ` gitk "hyperlinks" (was Re: Display of merges in gitk) Paul Mackerras
2005-08-06 16:20       ` Linus Torvalds
2005-08-06 17:07         ` jepler
2005-08-06 17:59         ` gitk SHA link hovers Linus Torvalds
2005-08-07 12:04           ` Paul Mackerras
2005-08-06 16:31       ` gitk "hyperlinks" Junio C Hamano
2005-08-07 12:05         ` Paul Mackerras

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050805185056.GF19009@unpythonic.net \
    --to=jepler@unpythonic.net \
    --cc=git@vger.kernel.org \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).