If git-gui is started outside a work tree the repository chooser will offer a list of recently opend repositories. Clicking on an entry directly opens the repository. The list of recently opened repositories is stored in the config as gui.recentrepos. If the list grows beyond 10 entries it will be truncated. Note, only repositories that are opened through the repository chooser will get added to the recent list. Repositories opened from the shell will not yet be added. Signed-off-by: Steffen Prohaska <prohaska@xxxxxx> --- git-gui/lib/choose_repository.tcl | 47 +++++++++++++++++++++++++++++++++++++ 1 files changed, 47 insertions(+), 0 deletions(-) The commit is also available on branch steffen/git-gui-openrecent in 4msysgit. Shawn, I'd suggest to reduce the number of clicks needed to open or clone an existing directory that is not in the list of recent repositories. First choosing from the radiobuttons and then clicking next is one click to much. There are no options to combine. Choosing from the list should immediately trigger the action. We could either put 'Create/Clone/Open New Repository' into the Repository menu and only present the recent repository list. Or we could offer push buttons for the other actions. Steffen diff --git a/git-gui/lib/choose_repository.tcl b/git-gui/lib/choose_repository.tcl index 16bf67c..bfc8780 100644 --- a/git-gui/lib/choose_repository.tcl +++ b/git-gui/lib/choose_repository.tcl @@ -116,9 +116,26 @@ constructor pick {} { -text [mc "Open Existing Repository"] \ -variable @action \ -value open + label $w_body.space + label $w_body.recentlabel \ + -anchor w \ + -text "Select Recent Repository:" + listbox $w_body.recentlist \ + -relief flat \ + -width 50 \ + -height 10 \ + -exportselection false \ + -selectmode select + foreach p [_get_recentrepos] { + $w_body.recentlist insert end $p + } + bind $w_body.recentlist <<ListboxSelect>> [cb _open_recent] pack $w_body.new -anchor w -fill x pack $w_body.clone -anchor w -fill x pack $w_body.open -anchor w -fill x + pack $w_body.space -anchor w -fill x + pack $w_body.recentlabel -anchor w -fill x + pack $w_body.recentlist -anchor w -fill x pack $w_body -fill x -padx 10 -pady 10 frame $w.buttons @@ -171,6 +188,34 @@ method _invoke_next {} { } } +proc _get_recentrepos {} { + set recent [list] + foreach p [get_config gui.recentrepos] { + if {[file isdirectory [file join $p .git]]} { + lappend recent $p + } + } + return [lsort $recent] +} + +proc _append_recentrepos {path} { + set recent [get_config gui.recentrepos] + if {[lsearch $recent $path] < 0} { + lappend recent $path + } + if {[llength $recent] > 10} { + set recent [lrange $recent 1 end] + } + regsub -all "\[{}\]" $recent {"} recent + git config --global gui.recentrepos $recent +} + +method _open_recent {} { + set id [$w_body.recentlist curselection] + set local_path [$w_body.recentlist get $id] + _do_open2 $this +} + method _next {} { destroy $w_body _do_$action $this @@ -893,6 +938,8 @@ method _do_open2 {} { return } + _append_recentrepos $local_path + set ::_gitdir .git set ::_prefix {} set done 1 -- 1.5.3.mingw.1.110.gef4c8 - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html