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

git gui: fail on dual entries in recent repo list

From
Philip Oakley <philipoakley@iee.org>
Date
Dec 13, 2015, 09:31 UTC
Message-ID
<3453668A49C94C2AA39911FC594AE151@PhilipOakley>

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
Next: Philip Oakley
Message 1 of 11 in “git gui: fail on dual entries in recent repo list”
  1. Philip OakleyDec 13, 2015
  2. 0/4 Fix git-gui when recentrepo list has duplicatesPhilip Oakley, Dec 14, 2015
  3. 1/4 git-gui: remove duplicate entries from .gitconfig's gui.recentrepoPhilip Oakley, Dec 14, 2015
  4. Eric SunshineDec 14, 2015
  5. Philip OakleyDec 16, 2015
  6. Eric SunshineDec 17, 2015
  7. 2/4 git gui: cope with duplicates in _get_recentrepoPhilip Oakley, Dec 14, 2015
  8. 3/4 git gui: de-dup selected repo from recentrepo historyPhilip Oakley, Dec 14, 2015
  9. 4/4 git gui: allow for a long recentrepo listPhilip Oakley, Dec 14, 2015
  10. Eric SunshineDec 14, 2015
  11. Philip OakleyDec 14, 2015

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.