]> rtime.felk.cvut.cz Git - sojka/git-gui.git/commitdiff
git-gui: Keep repo_config(gui.recentrepos) and .gitconfig in sync
authorChristopher Beelby <chris@celabs.com>
Sat, 23 Jan 2010 22:37:17 +0000 (14:37 -0800)
committerShawn O. Pearce <spearce@spearce.org>
Sat, 23 Jan 2010 22:46:12 +0000 (14:46 -0800)
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 <spearce@spearce.org>
lib/choose_repository.tcl

index 633cc572bbd076ff957c0b8194b6645e899e53ad..3f8f3030fadf4f438dd04b41ed75cfda1478f2de 100644 (file)
@@ -235,6 +235,8 @@ proc _get_recentrepos {} {
        foreach p [get_config gui.recentrepo] {
                if {[_is_git [file join $p .git]]} {
                        lappend recent $p
+               } else {
+                       _unset_recentrepo $p
                }
        }
        return [lsort $recent]
@@ -243,6 +245,7 @@ proc _get_recentrepos {} {
 proc _unset_recentrepo {p} {
        regsub -all -- {([()\[\]{}\.^$+*?\\])} $p {\\\1} p
        git config --global --unset gui.recentrepo "^$p\$"
+       load_config 1
 }
 
 proc _append_recentrepos {path} {
@@ -261,6 +264,7 @@ proc _append_recentrepos {path} {
 
        lappend recent $path
        git config --global --add gui.recentrepo $path
+       load_config 1
 
        while {[llength $recent] > 10} {
                _unset_recentrepo [lindex $recent 0]