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

[PATCH] git-gui: offer a list of recent repositories on startup

From
Steffen Prohaska <prohaska@zib.de>
Date
Oct 7, 2007, 21:28 UTC
Message-ID
<11917925011987-git-send-email-prohaska@zib.de>

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@zib.de>
---
 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
Next: Shawn O. Pearce
Message 1 of 10 in “git-gui: offer a list of recent repositories on startup”
  1. git-gui: offer a list of recent repositories on startupSteffen Prohaska, Oct 7, 2007
  2. Shawn O. PearceOct 7, 2007
  3. Steffen ProhaskaOct 8, 2007
  4. Johannes SchindelinOct 9, 2007
  5. Steffen ProhaskaOct 9, 2007
  6. Shawn O. PearceOct 10, 2007
  7. Johannes SchindelinOct 10, 2007
  8. Shawn O. PearceOct 10, 2007
  9. Steffen ProhaskaOct 10, 2007
  10. Shawn O. PearceOct 10, 2007

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.