Skip to content

Commit 3c6a287

Browse files
Christopher Beelbyspearce
authored andcommitted
git-gui: Keep repo_config(gui.recentrepos) and .gitconfig in sync
When the number of recent repo's gets to ten there can be a situation where an item is removed from the .gitconfig file via a call to git config --unset, but the internal representation of that file (repo_config(gui.recentrepo)) is not updated. Then a subsequent attempt to remove an item from the list fails because git-gui attempts to call --unset on a value that has already been removed. This leads to duplicates in the .gitconfig file, which then also cause errors if the git-gui tries to --unset them (rather than using --unset-all. --unset-all is not used because it is not expected that duplicates should ever be allowed to exist.) When loading the list of recent repositories (proc _get_recentrepos) if a repo in the list is not considered a valid git reposoitory then we should go ahead and remove it so it doesn't take up a slot in the list (since we limit to 10 items). This will prevent a bunch of invalid entries in the list (which are not shown) from making valid entries dissapear off the list even when there are less than ten valid entries. See: http://code.google.com/p/msysgit/issues/detail?id=362 Signed-off-by: Shawn O. Pearce <[email protected]>
1 parent ea888f8 commit 3c6a287

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/choose_repository.tcl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,8 @@ proc _get_recentrepos {} {
235235
foreach p [get_config gui.recentrepo] {
236236
if {[_is_git [file join $p .git]]} {
237237
lappend recent $p
238+
} else {
239+
_unset_recentrepo $p
238240
}
239241
}
240242
return [lsort $recent]
@@ -243,6 +245,7 @@ proc _get_recentrepos {} {
243245
proc _unset_recentrepo {p} {
244246
regsub -all -- {([()\[\]{}\.^$+*?\\])} $p {\\\1} p
245247
git config --global --unset gui.recentrepo "^$p\$"
248+
load_config 1
246249
}
247250

248251
proc _append_recentrepos {path} {
@@ -261,6 +264,7 @@ proc _append_recentrepos {path} {
261264

262265
lappend recent $path
263266
git config --global --add gui.recentrepo $path
267+
load_config 1
264268

265269
while {[llength $recent] > 10} {
266270
_unset_recentrepo [lindex $recent 0]

0 commit comments

Comments
 (0)