git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gitk: Add "Refs" menu
@ 2005-10-06  0:38 Pavel Roskin
  2005-10-06  4:11 ` [PATCH] gitk: Add "Refs" menu - revised Pavel Roskin
  2005-10-11 12:17 ` [PATCH] gitk: Add "Refs" menu Paul Mackerras
  0 siblings, 2 replies; 9+ messages in thread
From: Pavel Roskin @ 2005-10-06  0:38 UTC (permalink / raw)
  To: git, Paul Mackerras

Hello, Paul!

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.

Known limitation: it's only possible to go to the refs present in the
current view.  Otherwise, gitk would have to re-run git-rev-list.

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

diff --git a/gitk b/gitk
--- a/gitk
+++ b/gitk
@@ -285,6 +285,7 @@ proc readrefs {} {
 	}
     }
     readotherrefs refs {} {tags heads}
+    setrefsmenu
 }
 
 proc readotherrefs {base dname excl} {
@@ -538,6 +539,62 @@ proc makewindow {} {
     $rowctxmenu add command -label "Write commit to file" -command writecommit
 }
 
+proc gotocommit_menu {sha1} {
+    global idline
+
+    if {[info exists idline($sha1)]} {
+	selectline $idline($sha1) 1
+	return
+    } else {
+	# Should we re-run git-rev-list?
+	error_popup "$sha1 is not in the current view"
+    }
+}
+
+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 [concat [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 "gotocommit_menu $headids($v)"
+	}
+    }
+
+    set refids [lsort -unique [concat [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 "gotocommit_menu $tagids($v)"
+	}
+    }
+
+    set refids [lsort -unique [concat [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 "gotocommit_menu $otherrefids($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

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2005-10-12 17:48 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-06  0:38 [PATCH] gitk: Add "Refs" menu Pavel Roskin
2005-10-06  4:11 ` [PATCH] gitk: Add "Refs" menu - revised Pavel Roskin
2005-10-11 12:17 ` [PATCH] gitk: Add "Refs" menu 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

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).