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

Re: [PATCH 3/6] Add a tree view to the local branches, remote branches and tags, where / is treated as a directory seperator.

From
Paul Mackerras <paulus@ozlabs.org>
Date
Dec 31, 2016, 09:08 UTC
Message-ID
<20161231090859.GC21019@fergus.ozlabs.ibm.com>
In-Reply-To
<20161215112847.14719-3-pmdumuid@gmail.com>
On Thu, Dec 15, 2016 at 09:58:44PM +1030, Pierre Dumuid wrote:
> Signed-off-by: Pierre Dumuid <pmdumuid@gmail.com>
> ---
>  gitk | 117 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 117 insertions(+)

Nice idea in general... a few comments below. Also, please don't put the entire commit message in the subject line. :)

Show 68 quoted lines
> diff --git a/gitk b/gitk
> index 36cba49..a894f1d 100755
> --- a/gitk
> +++ b/gitk
> @@ -2089,6 +2089,10 @@ proc makewindow {} {
>  	    {mc "Reread re&ferences" command rereadrefs}
>  	    {mc "&List references" command showrefs -accelerator F2}
>  	    {xx "" separator}
> +	    {mc "List Local Branches"  command {show_tree_of_references_dialog "localBranches"}  -accelerator F6}
> +	    {mc "List Remote Branches" command {show_tree_of_references_dialog "remoteBranches"} -accelerator F7}
> +	    {mc "List Tags"            command {show_tree_of_references_dialog "tags"}           -accelerator F8}
> +	    {xx "" separator}
>  	    {mc "Start git &gui" command {exec git gui &}}
>  	    {xx "" separator}
>  	    {mc "&Quit" command doquit -accelerator Meta1-Q}
> @@ -2601,6 +2605,9 @@ proc makewindow {} {
>      bind . <F5> updatecommits
>      bindmodfunctionkey Shift 5 reloadcommits
>      bind . <F2> showrefs
> +    bind . <F6> {show_tree_of_references_dialog "localBranches"}
> +    bind . <F7> {show_tree_of_references_dialog "remoteBranches"}
> +    bind . <F8> {show_tree_of_references_dialog "tags"}
>      bindmodfunctionkey Shift 4 {newview 0}
>      bind . <F4> edit_or_newview
>      bind . <$M1B-q> doquit
> @@ -10146,6 +10153,116 @@ proc rmbranch {} {
>      run refill_reflist
>  }
>  
> +# Display a tree view of local branches, remote branches, and tags according to view_type.
> +#
> +# @param string view_type
> +#    Must be one of "localBranches", "remoteBranches", or "tags".
> +#
> +proc show_tree_of_references_dialog {view_type} {
> +    global NS
> +    global treefilelist
> +    global headids tagids
> +
> +    switch -- $view_type {
> +	"localBranches" {
> +	    set dialogName "Local Branches"
> +	    set top .show_tree_of_local_branches
> +	    set listOfReferences [lsort [array names headids -regexp {^(?!remotes/)} ]]
> +	    set truncateFrom 0
> +	}
> +	"remoteBranches" {
> +	    set dialogName "Remote Branches"
> +	    set top .show_tree_of_remote_branches
> +	    set listOfReferences [lsort [array names headids -regexp {^remotes/} ]]
> +	    set truncateFrom 8
> +	}
> +	"tags" {
> +	    set dialogName "Tags"
> +	    set top .show_tree_of_tags
> +	    set listOfReferences [lsort [array names tagids]]
> +	    set truncateFrom 0
> +	}
> +    }
> +
> +    if {[winfo exists $top]} {
> +	raise $top
> +	return
> +    }
> +
> +    ttk_toplevel $top
> +    wm title $top [mc "$dialogName: %s" [file tail [pwd]]]
> +    wm geometry $top "600x900"

Do you really need to do this? A fixed size like this is inevitably going to be too big for some users and too small for others.

Show 5 quoted lines
> +
> +    make_transient $top .
> +
> +    ## See http://www.tkdocs.com/tutorial/tree.html
> +    ttk::treeview $top.referenceList -xscrollcommand "$top.horizontalScrollBar set" -yscrollcommand "$top.verticalScrollBar set"

We still have the option for people to run without ttk, in case someone is still using an old Tcl/Tk version or just doesn't like the ttk widgets. However, there isn't an equivalent of ttk::treeview in the older Tk widget set. It would be OK to omit the new menu entries or to disable them if $use_ttk is false, but I don't want to have menu entries that will always cause gitk to blow up when $use_ttk is false.

We possibly should consider converting the file list view to use a ttk::treeview when $use_ttk is true.

Paul.
Previous: Pierre DumuidNext: Pierre Dumuid
Message 5 of 9 in “Enable ability to visualise the results of git cherry C1 C2”
  1. 1/6 Enable ability to visualise the results of git cherry C1 C2Pierre Dumuid, Dec 15, 2016
  2. 2/6 Add ability to follow a remote branch with a dialogPierre Dumuid, Dec 15, 2016
  3. Paul MackerrasDec 31, 2016
  4. 3/6 Add a tree view to the local branches, remote branches and tags, where / is treated as a directory seperator.Pierre Dumuid, Dec 15, 2016
  5. Paul MackerrasDec 31, 2016
  6. 5/6 gitk: Add a "Save file as" menu itemPierre Dumuid, Dec 15, 2016
  7. 6/6 Rename 'remotes/' to 'r../' in headsPierre Dumuid, Dec 15, 2016
  8. 4/6 Add DirDiffTool as additional optionPierre Dumuid, Dec 15, 2016
  9. Paul MackerrasDec 31, 2016

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.