git gui: cope with duplicates in _get_recentrepo
authorPhilip Oakley <philipoakley@iee.org>
Mon, 14 Dec 2015 11:19:32 +0000 (11:19 +0000)
committerPhilip Oakley <philipoakley@iee.org>
Fri, 20 Jan 2017 21:03:34 +0000 (21:03 +0000)
_get_recentrepo will fail if duplicate invalid entries are present
in the recentrepo config list. The previous commit fixed the
'git config' limitations in _unset_recentrepo by unsetting all config
entries, however this code would fail on the second attempt to unset it.

Refactor the code to pre-sort and de-duplicate the recentrepo list to
avoid a potential second unset attempt.

Signed-off-by: Philip Oakley <philipoakley@iee.org>
lib/choose_repository.tcl
index 133ca0ac351b16f737dc7d4a3d1ccdc19db510ad..aa87bcc3441b7fdba200062e97b56fd422b5b68a 100644 (file)
@@ -235,14 +235,14 @@ method _invoke_next {} {
 
 proc _get_recentrepos {} {
        set recent [list]
-       foreach p [get_config gui.recentrepo] {
+       foreach p [lsort -unique [get_config gui.recentrepo]] {
                if {[_is_git [file join $p .git]]} {
                        lappend recent $p
                } else {
                        _unset_recentrepo $p
                }
        }
-       return [lsort $recent]
+       return $recent
 }
 
 proc _unset_recentrepo {p} {