Search code examples
gitgit-gui

How do I show more 'recent repositories' in Git GUI?


My copy of Git-GUI shows 10 entries under the "Open Recent Repository" list. How do I change this to e.g. 20? Currently, whenever I open an 11th repo, the alphabetically-last on the list disappears - a right pain when the list is full and I'm alternating between repos Zed and Alpha {not their real names!}

I don't read TCL all that well, but I think the relevant line is #267, in C:/Program Files (x86)/Git/share/git-gui/lib/choose_repository.tcl. I've tried opening my favourite editor as Administrator, changing that line to "> 20", restarting Git-GUI, and opening another repository, but that didn't help - the bottom entry got pushed off the list again. My edit's still there when I re-open choose_repository.tcl, so it's definitely being saved.

while {[llength $recent] > 10} {

What should I be doing?

Software in use:

  • Windows 7
  • git-gui version 0.17.GITGUI
  • git version 1.8.3.msysgit.0
  • TCl/TK version 8.5.13
  • git-gui lib: C:/Program Files (x86)/Git/share/git-gui/lib

Solution

  • You are nearly there. You have found the place to cause git-gui to record more than 10 previously opened repositories. However, the text widget used to show the list of repositories is only 10 lines high - so if you change that as well at line 151 you will get to both record and see them.

    Here is a patch that lets you set gui.maxrecentrepo and will fix the maximum number of recent repositories to this value (defaulting to 10):

    diff --git a/lib/choose_repository.tcl b/lib/choose_repository.tcl
    index 657f7d5..c8d8517 100644
    --- a/lib/choose_repository.tcl
    +++ b/lib/choose_repository.tcl
    @@ -24,6 +24,10 @@ field sorted_recent       ; # recent repositories (sorted)
     constructor pick {} {
            global M1T M1B use_ttk NS
    
    +       if {[set maxrecent [get_config gui.maxrecentrepo]] eq {}} {
    +               set maxrecent 10
    +       }
    +
            make_dialog top w
            wm title $top [mc "Git Gui"]
    
    @@ -148,7 +152,7 @@ constructor pick {} {
                            -background [get_bg_color $w_body.recentlabel] \
                            -wrap none \
                            -width 50 \
    -                       -height 10
    +                       -height $maxrecent
                    $w_recentlist tag conf link \
                            -foreground blue \
                            -underline 1
    @@ -264,7 +268,11 @@ proc _append_recentrepos {path} {
            git config --global --add gui.recentrepo $path
            load_config 1
    
    -       while {[llength $recent] > 10} {
    +       if {[set maxrecent [get_config gui.maxrecentrepo]] eq {}} {
    +               set maxrecent 10
    +       }
    +
    +       while {[llength $recent] > $maxrecent} {
                    _unset_recentrepo [lindex $recent 0]
                    set recent [lrange $recent 1 end]
            }