3

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
Steve Almond
  • 413
  • 4
  • 12

1 Answers1

3

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]
        }
patthoyts
  • 32,320
  • 3
  • 62
  • 93
  • 1
    Looks great, and works fine. The missing step was how to set gui.maxrecentrepo => by opening C:\Users\{user}\.gitconfig in an editor, finding a line saying [gui], and adding a new line saying maxrecentrepo = {number} – Steve Almond Jul 22 '13 at 08:10
  • You can also set this config value using 'git config --global gui.maxrecentrepo 20' -- but manually editing the config file work the same way. – patthoyts Jul 22 '13 at 11:12
  • that command works for me in Ubuntu, but not in Windows7 (via cmd.exe): "'git' is not recognized as an internal or external command, operable program or batch file." I suspect that you're missing a step. – Steve Almond Jul 22 '13 at 16:01
  • maybe the step we were missing was to add git to the PATH: http://stackoverflow.com/questions/4492979/git-is-not-recognized-as-an-internal-or-external-command – Steve Almond Aug 19 '13 at 08:19
  • I was looking for a way to change this limit. I see this patch has been [applied](https://github.com/git/git/commit/a86560453ba8a81527d5d119ea8985a3269af1fa) to git. So in current git builds changing `gui.maxrecentrepo` is sufficient. – Martin Oct 21 '20 at 20:56