A user, Alexey A, reported (https://groups.google.com/forum/#!topic/git-users/msev4KsQGFc, Warning: gui.recentrepo has multiply values while executing) on the Git User list that the Git Gui start-up could barf if there were duplicate entries in the user's recent repo list within their --global .gitconfig, but found no fix on the internet.
Alexey had posted a screenshot of the script error, which, with a little digging, got down to the _unset_recentrepo procedure in the choose_repository.tcl file where the line https://github.com/git/git/blob/master/git-gui/lib/choose_repository.tcl#L250
git config --global --unset gui.recentrepo "^$p\$"
should read
git config --global --unset-all gui.recentrepo "^$p\$"
for the case where duplicate entries are present.
This fix resolved Alexey's problem.
So far, so good.
Unfortunately this doesn't explain how duplicate entries are created, and if the fix will affect other code, which I need some help on.
The 'proc _append_recentrepos {path}' code https://github.com/git/git/blob/master/git-gui/lib/choose_repository.tcl#L254 has some code to avoid both duplicate entries and to limit the number of entries in the recent repo list.
A web search to understand the code got me to the lreplace function (http://wiki.tcl.tk/1485 #Performance: Modifying a List In-Place), which suggest that the de-dup may (randomly) fail in some cases. In addition it looks like the code may fail if there are multiple entries returned from the earlier search of the recentrepo list, whereby the following lreplace would have more args in the arg list (4 rather than two) and so confusing it, though my ignorance of tcl precedes me here.
Even if all that tcl works fine, my proposed update will still have issues for that code, because the append_recentrepos de-dup code keeps its own list of the recent repos, and thinks that it removed entries one at a time, yet the change can remove multiple entries if duplicates are present, completely confusing the counting of entries in the local copy '$recent'.
So, have I understood the code correctly? Are more fixes needed for the append_recentrepos code to refactor the re-ordering of the recent repos list and limiting the list to 10 entries once the --unset-all fix is added? --
Philip