threads / patch / 2029

patchgitk: Add "Refs" menu

Subject: [PATCH] gitk: Add "Refs" menu

## tl;dr

9 messages between Oct 6, 2005 and Oct 12, 2005. Diffs are folded; open one to read it.

replies: 8people: 5as markdown or json

Pavel Roskin· Oct 6, 2005, 00:38 UTC · lore
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>
Show changes to gitk +57 −0
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
Pavel Roskin· Oct 6, 2005, 04:11 UTC · re: Pavel Roskin · lore

[PATCH] gitk: Add "Refs" menu - revised

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

Show changes to gitk +60 −0
+++ 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
Paul Mackerras· Oct 11, 2005, 12:17 UTC · re: Pavel Roskin · lore

Re: [PATCH] gitk: Add "Refs" menu

Pavel Roskin writes:
> 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.

Sorry I haven't responded before - I have got way behind with my email due to a vacation and to concentrating on the merge of the ppc32 and ppc64 kernel sources. It will probably be a bit longer before I can get to look at this.

Thanks, Paul.

Pavel Roskin· Oct 12, 2005, 01:26 UTC · re: Paul Mackerras · lore

Re: [PATCH] gitk: Add "Refs" menu

Hi, Paul!
On Tue, 2005-10-11 at 22:17 +1000, Paul Mackerras wrote:
Show 10 quoted lines
> Pavel Roskin writes:
> 
> > 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.
> 
> Sorry I haven't responded before - I have got way behind with my email
> due to a vacation and to concentrating on the merge of the ppc32 and
> ppc64 kernel sources.  It will probably be a bit longer before I can
> get to look at this.
No problem.  Thank you for letting me know.

I'm not a GUI designer and I'm not experienced in Tcl/Tk, so I'll appreciate critical look at the patches.

I think that gitk should move away from being just a frontend to git-rev-list. There is more information in the repository, such as tags, branches, stgit patches etc. All this information needs to be represented in some way, and using the menu was just the first approach.

Browsing trees and opening files for a given commit would be great and helpful from developers migrating from CVS.

And making gitk cooperate with stgit would be a killer application not just for gitk and stgit, but for git itself (i.e. it could be the reason why git is chosen for development over e.g. Mercurial for new projects).

I don't want to distract you from PPC work, but your return to gitk development would be very welcome :-)

-- 
Regards,
Pavel Roskin
Sven Verdoolaege· Oct 12, 2005, 07:31 UTC · re: Pavel Roskin · lore

Re: [PATCH] gitk: Add "Refs" menu

On Tue, Oct 11, 2005 at 09:26:20PM -0400, Pavel Roskin wrote:
> Browsing trees and opening files for a given commit would be great and
> helpful from developers migrating from CVS.
Something like this ?
    From: Ingo Bormuth <ibormuth@efil.de>
    To: git@vger.kernel.org
    Cc: paulus@samba.org
    Subject: [PATCH] Gitk tree view (correction)
    Message-ID: <20050824223550.GA23693@kruemel>
skimo
Pavel Roskin· Oct 12, 2005, 14:34 UTC · re: Sven Verdoolaege · lore

Re: [PATCH] gitk: Add "Refs" menu

On Wed, 2005-10-12 at 09:31 +0200, Sven Verdoolaege wrote:
Show 11 quoted lines
> On Tue, Oct 11, 2005 at 09:26:20PM -0400, Pavel Roskin wrote:
> > Browsing trees and opening files for a given commit would be great and
> > helpful from developers migrating from CVS.
> 
> Something like this ?
> 
>     From: Ingo Bormuth <ibormuth@efil.de>
>     To: git@vger.kernel.org
>     Cc: paulus@samba.org
>     Subject: [PATCH] Gitk tree view (correction)
>     Message-ID: <20050824223550.GA23693@kruemel>

That's pretty good, thank you. Although I think "Tree" and "Commit" should be links on top of the view pane rather than a button. "Commit" button is especially confusing - one could think that it would commit something.

Also, it would be really great to put line numbers in a separate widget so that they are never selected with the text. When done correctly, most users will never want to turn the line numbers off.

-- 
Regards,
Pavel Roskin
Marco Costalba· Oct 12, 2005, 11:55 UTC · re: Pavel Roskin · lore

Re: [PATCH] gitk: Add "Refs" menu

> And making gitk cooperate with stgit would be a killer application not
> just for gitk and stgit, but for git itself (i.e. it could be the reason
> why git is chosen for development over e.g. Mercurial for new projects).
> 

Not to advertise, but qgit (http://digilander.libero.it/mcostalba/) already offers stgit integration, among other things.

I plan to release a new version implementing various suggestion from the list this week, there are also important stgit fixes and upgrades.

To have a look at new features check the git arcihve: cg-clone http://digilander.libero.it/mcostalba/qgit.git

  Marco
		
__________________________________ 
Yahoo! Music Unlimited 
Access over 1 million songs. Try it free.
http://music.yahoo.com/unlimited/
Pavel Roskin· Oct 12, 2005, 16:03 UTC · re: Marco Costalba · lore

Re: [PATCH] gitk: Add "Refs" menu

On Wed, 2005-10-12 at 04:55 -0700, Marco Costalba wrote:
Show 7 quoted lines
>  > And making gitk cooperate with stgit would be a killer application not
> > just for gitk and stgit, but for git itself (i.e. it could be the reason
> > why git is chosen for development over e.g. Mercurial for new projects).
> > 
> 
> Not to advertise, but qgit (http://digilander.libero.it/mcostalba/) already offers 
> stgit integration, among other things.
Very nice.

But it doesn't show correctly in the qt theme I was using (which must be the default theme in Fedora Core 4 because I never changed it):

http://red-bean.com/proski/qgit.png

The blame for the ugly default gray background should be on Qt or on Fedora, but it seems to me that qgit is hardcoding white and light gray (see ODD_LINE_COL and EVEN_LINE_COL in src/mainimpl.cpp).

The style selector in kcontrol has "Standard Background" and "Alternate Background for Lists". I don't know if it has an equivalent in qt. Maybe you could use the standard background and a slightly darkened version.

Also, please use months names on the homepage. I thought qgit 0.94 was released on October 9th.

-- 
Regards,
Pavel Roskin
H. Peter Anvin· Oct 12, 2005, 17:47 UTC · re: Marco Costalba · lore

Re: [PATCH] gitk: Add "Refs" menu

Marco Costalba wrote:
Show 17 quoted lines
>  
> 
>>And making gitk cooperate with stgit would be a killer application not
>>just for gitk and stgit, but for git itself (i.e. it could be the reason
>>why git is chosen for development over e.g. Mercurial for new projects).
>>
> 
> 
> Not to advertise, but qgit (http://digilander.libero.it/mcostalba/) already offers 
> stgit integration, among other things.
> 
> I plan to release a new version implementing various suggestion from the list this week, there are
> also important stgit fixes and upgrades. 
> 
> To have a look at new features check the git arcihve: cg-clone
> http://digilander.libero.it/mcostalba/qgit.git
> 

I looked at qgit at one time, and I find its UI to be much less pleasant to look at that gitk, which is unfortunate, because it's much faster. Both the graph and the color scheme are much less pleasant, which distracts from the information conveyed.

	-hpa

← back to recent threads