git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Roskin <proski@gnu.org>
To: git <git@vger.kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Subject: [PATCH] gitk: Add "Refs" menu - revised
Date: Thu, 06 Oct 2005 00:11:23 -0400	[thread overview]
Message-ID: <1128571883.32103.48.camel@dv> (raw)
In-Reply-To: <1128559088.32103.8.camel@dv>

Hello!

This is an updated revision of the original patch.  Unneeded concat has
been removed.  Error message uses name, not SHA1 ID.  If there is
information for the tag, it's displayed even in the ID is not in the
list.  Thanks to Brett Schwarz for help.

---------------------------------

This patch adds "Refs" menu to gitk.  It makes all branches, tags and
other ref objects appear as menu items.  Selecting one of the items
selects the corresponding line in the view.

It's only possible to go to the refs present in the current view.
However, information for tags is shown even if the corresponding ID is
not available.

Signed-off-by: Pavel Roskin <proski@gnu.org>

diff -u b/gitk b/gitk
--- b/gitk
+++ b/gitk
@@ -285,6 +285,7 @@
 	}
     }
     readotherrefs refs {} {tags heads}
+    setrefsmenu
 }
 
 proc readotherrefs {base dname excl} {
@@ -538,6 +539,65 @@
     $rowctxmenu add command -label "Write commit to file" -command writecommit
 }
 
+proc gotocommit_menu {sha1 name} {
+    global idline tagids tagcontents
+
+    if {[info exists idline($sha1)]} {
+	selectline $idline($sha1) 1
+    } else {
+	# Should we re-run git-rev-list?
+	error_popup "$name is not in the current view"
+    }
+
+    if {[info exists tagcontents($name)]} {
+	showtag $name 1
+    }
+}
+
+proc setrefsmenu {} {
+    global headids tagids otherrefids
+
+    if {[winfo exists .bar.refs]} {
+	foreach w [winfo children .bar.refs] {
+	    destroy $w
+	}
+	.bar.refs delete 1 3
+    } else {
+	.bar add cascade -label "Refs" -menu .bar.refs
+	menu .bar.refs
+    }
+
+    set refids [lsort -unique [array names headids]]
+    if {[llength $refids] > 0} {
+	.bar.refs add cascade -label "Branches" -menu .bar.refs.heads
+	menu .bar.refs.heads
+	foreach v $refids {
+	    .bar.refs.heads add command -label $v \
+		-command [list gotocommit_menu $headids($v) $v]
+	}
+    }
+
+    set refids [lsort -unique [array names tagids]]
+    if {[llength $refids] > 0} {
+	.bar.refs add cascade -label "Tags" -menu .bar.refs.tags
+	menu .bar.refs.tags
+	foreach v $refids {
+	    .bar.refs.tags add command -label $v \
+		-command [list gotocommit_menu $tagids($v) $v]
+	}
+    }
+
+    set refids [lsort -unique [array names otherrefids]]
+    if {[llength $refids] > 0} {
+	.bar.refs add cascade -label "Other" -menu .bar.refs.other
+	menu .bar.refs.other
+	foreach v $refids {
+	    .bar.refs.other add command -label $v \
+		-command [list gotocommit_menu $otherrefids($v) $v]
+	}
+    }
+}
+
 # when we make a key binding for the toplevel, make sure
 # it doesn't get triggered when that key is pressed in the
 # find string entry widget.


-- 
Regards,
Pavel Roskin

  reply	other threads:[~2005-10-06  4:12 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-06  0:38 [PATCH] gitk: Add "Refs" menu Pavel Roskin
2005-10-06  4:11 ` Pavel Roskin [this message]
2005-10-11 12:17 ` Paul Mackerras
2005-10-12  1:26   ` Pavel Roskin
2005-10-12  7:31     ` Sven Verdoolaege
2005-10-12 14:34       ` Pavel Roskin
2005-10-12 11:55     ` Marco Costalba
2005-10-12 16:03       ` Pavel Roskin
2005-10-12 17:47       ` H. Peter Anvin

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=1128571883.32103.48.camel@dv \
    --to=proski@gnu.org \
    --cc=git@vger.kernel.org \
    --cc=paulus@samba.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).