{"thread":{"id":"44943","subject":"[PATCH v3 0/4] git gui: allow for a long recentrepo list","startedAt":"2017-01-22T19:53:20Z","lastAt":"2017-02-11T12:48:45Z","messageCount":6,"participants":["Philip Oakley"],"isPatch":true,"patchVersion":3,"patchTotal":4},"messages":[{"id":"309940","messageId":"20170122195301.1784-1-philipoakley@iee.org","threadId":"44943","inReplyTo":null,"subject":"[PATCH v3 0/4] git gui: allow for a long recentrepo list","fromName":"Philip Oakley","fromEmail":"philipoakley@iee.org","sentAt":"2017-01-22T19:52:57Z","receivedAt":"2017-01-22T19:53:20Z","isPatch":true,"sender":{"key":"philipoakley@iee.email","avatar":"https://avatars.githubusercontent.com/u/914343?v=4"},"body":"Way back in December 2015 I made a couple of attempts to patch up\nthe git-gui's recentrepo list in the face of duplicate entries in\nthe .gitconfig\n\nThe series end at http://public-inbox.org/git/9731888BD4C348F5BFC82FA96D978034@PhilipOakley/\n\nA similar problem was reported recently on the Git for Windows list\nhttps://github.com/git-for-windows/git/issues/1014 were a full\nrecentrepo list also stopped the gui working.\n\nThis series applies to Pat Thoyt's upstream Github repo as a merge\nready Pull Request https://github.com/patthoyts/git-gui/pull/10.\nHence if applied here it should be into the sub-tree git/git-gui.\n\nI believe I've covered the points raised by Junio in the last review\nand allowed for cases where the recentrepo list is now longer than the\nmaximum (which can be configured, both up and down).\n\nI've cc'd just the cover letter to those involved previously, rather\nthan the series to avoid spamming.\n\nThere are various other low hanging fruit that the eager could look at\nwhich are detailed at the end of the GfW/issues/104 referenced above.\n\nPhilip Oakley (4):\n  git-gui: remove duplicate entries from .gitconfig's gui.recentrepo\n  git gui: cope with duplicates in _get_recentrepo\n  git gui: de-dup selected repo from recentrepo history\n  git gui: allow for a long recentrepo list\n\n lib/choose_repository.tcl | 17 ++++++++++-------\n 1 file changed, 10 insertions(+), 7 deletions(-)\n\n-- \n2.9.0.windows.1.323.g0305acf\n---\ncc: Junio C Hamano <gitster@pobox.com>\ncc: Pat Thoyts <patthoyts@users.sourceforge.net>,\ncc: Eric Sunshine <sunshine@sunshineco.com>,\ncc: Alexey Astakhov <asstv7@gmail.com>\ncc: Johannes Schindelin <johannes.schindelin@gmx.de>\n\n"},{"id":"309941","messageId":"20170122195301.1784-3-philipoakley@iee.org","threadId":"44943","inReplyTo":"20170122195301.1784-1-philipoakley@iee.org","subject":"[PATCH v3 2/4] git gui: cope with duplicates in _get_recentrepo","fromName":"Philip Oakley","fromEmail":"philipoakley@iee.org","sentAt":"2017-01-22T19:52:59Z","receivedAt":"2017-01-22T19:53:23Z","isPatch":true,"sender":{"key":"philipoakley@iee.email","avatar":"https://avatars.githubusercontent.com/u/914343?v=4"},"body":"_get_recentrepo will fail if duplicate invalid entries are present\nin the recentrepo config list. The previous commit fixed the\n'git config' limitations in _unset_recentrepo by unsetting all config\nentries, however this code would fail on the second attempt to unset it.\n\nRefactor the code to pre-sort and de-duplicate the recentrepo list to\navoid a potential second unset attempt.\n\nSigned-off-by: Philip Oakley <philipoakley@iee.org>\n---\n lib/choose_repository.tcl | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/lib/choose_repository.tcl b/lib/choose_repository.tcl\nindex 133ca0a..aa87bcc 100644\n--- a/lib/choose_repository.tcl\n+++ b/lib/choose_repository.tcl\n@@ -235,14 +235,14 @@ method _invoke_next {} {\n \n proc _get_recentrepos {} {\n \tset recent [list]\n-\tforeach p [get_config gui.recentrepo] {\n+\tforeach p [lsort -unique [get_config gui.recentrepo]] {\n \t\tif {[_is_git [file join $p .git]]} {\n \t\t\tlappend recent $p\n \t\t} else {\n \t\t\t_unset_recentrepo $p\n \t\t}\n \t}\n-\treturn [lsort $recent]\n+\treturn $recent\n }\n \n proc _unset_recentrepo {p} {\n-- \n2.9.0.windows.1.323.g0305acf\n\n"},{"id":"309942","messageId":"20170122195301.1784-4-philipoakley@iee.org","threadId":"44943","inReplyTo":"20170122195301.1784-1-philipoakley@iee.org","subject":"[PATCH v3 3/4] git gui: de-dup selected repo from recentrepo history","fromName":"Philip Oakley","fromEmail":"philipoakley@iee.org","sentAt":"2017-01-22T19:53:00Z","receivedAt":"2017-01-22T19:53:25Z","isPatch":true,"sender":{"key":"philipoakley@iee.email","avatar":"https://avatars.githubusercontent.com/u/914343?v=4"},"body":"When the gui/user selects a repo for display, that repo is brought to\nthe end of the recentrepo config list. The logic can fail if there are\nduplicate old entries for the repo (you cannot unset a single config\nentry when duplicates are present).\n\nSimilarly, the maxrecentrepo logic could fail if older duplicate entries\nare present.\n\nThe first commit of this series ({this}~2) fixed the config unsetting\nissue. Rather than manipulating a local copy of the $recent list (one\ncannot know how many entries were removed), simply re-read it.\n\nWe must also catch the error when the attempt to remove the second copy\nfrom the re-read list is performed.\n\nSigned-off-by: Philip Oakley <philipoakley@iee.org>\n---\n lib/choose_repository.tcl | 7 +++----\n 1 file changed, 3 insertions(+), 4 deletions(-)\n\ndiff --git a/lib/choose_repository.tcl b/lib/choose_repository.tcl\nindex aa87bcc..f39636f 100644\n--- a/lib/choose_repository.tcl\n+++ b/lib/choose_repository.tcl\n@@ -247,7 +247,7 @@ proc _get_recentrepos {} {\n \n proc _unset_recentrepo {p} {\n \tregsub -all -- {([()\\[\\]{}\\.^$+*?\\\\])} $p {\\\\\\1} p\n-\tgit config --global --unset-all gui.recentrepo \"^$p\\$\"\n+\tcatch {git config --global --unset-all gui.recentrepo \"^$p\\$\"}\n \tload_config 1\n }\n \n@@ -262,12 +262,11 @@ proc _append_recentrepos {path} {\n \tset i [lsearch $recent $path]\n \tif {$i >= 0} {\n \t\t_unset_recentrepo $path\n-\t\tset recent [lreplace $recent $i $i]\n \t}\n \n-\tlappend recent $path\n \tgit config --global --add gui.recentrepo $path\n \tload_config 1\n+\tset recent [get_config gui.recentrepo]\n \n \tif {[set maxrecent [get_config gui.maxrecentrepo]] eq {}} {\n \t\tset maxrecent 10\n@@ -275,7 +274,7 @@ proc _append_recentrepos {path} {\n \n \twhile {[llength $recent] > $maxrecent} {\n \t\t_unset_recentrepo [lindex $recent 0]\n-\t\tset recent [lrange $recent 1 end]\n+\t\tset recent [get_config gui.recentrepo]\n \t}\n }\n \n-- \n2.9.0.windows.1.323.g0305acf\n\n"},{"id":"309943","messageId":"20170122195301.1784-2-philipoakley@iee.org","threadId":"44943","inReplyTo":"20170122195301.1784-1-philipoakley@iee.org","subject":"[PATCH v3 1/4] git-gui: remove duplicate entries from .gitconfig's gui.recentrepo","fromName":"Philip Oakley","fromEmail":"philipoakley@iee.org","sentAt":"2017-01-22T19:52:58Z","receivedAt":"2017-01-22T19:53:26Z","isPatch":true,"sender":{"key":"philipoakley@iee.email","avatar":"https://avatars.githubusercontent.com/u/914343?v=4"},"body":"The git gui's recent repo list may become contaminated with duplicate\nentries. The git gui would barf when attempting to remove one entry.\nRemove them all - there is no option within 'git config' to selectively\nremove one of the entries.\n\nThis issue was reported on the 'Git User' list\n(https://groups.google.com/forum/#!topic/git-users/msev4KsQGFc,\nWarning: gui.recentrepo has multiply values while executing).\n\nAnd also by zosrothko as a Git-for-Windows issue\nhttps://github.com/git-for-windows/git/issues/1014.\n\nOn startup the gui checks that entries in the recentrepo list are still\nvalid repos and deletes thoses that are not. If duplicate entries are\npresent the 'git config --unset' will barf and this prevents the gui\nfrom starting.\n\nSubsequent patches fix other parts of recentrepo logic used for syncing\ninternal lists with the external .gitconfig.\n\nReported-by: Alexey Astakhov <asstv7@gmail.com>\nSigned-off-by: Philip Oakley <philipoakley@iee.org>\n---\n lib/choose_repository.tcl | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/lib/choose_repository.tcl b/lib/choose_repository.tcl\nindex 75d1da8..133ca0a 100644\n--- a/lib/choose_repository.tcl\n+++ b/lib/choose_repository.tcl\n@@ -247,7 +247,7 @@ proc _get_recentrepos {} {\n \n proc _unset_recentrepo {p} {\n \tregsub -all -- {([()\\[\\]{}\\.^$+*?\\\\])} $p {\\\\\\1} p\n-\tgit config --global --unset gui.recentrepo \"^$p\\$\"\n+\tgit config --global --unset-all gui.recentrepo \"^$p\\$\"\n \tload_config 1\n }\n \n-- \n2.9.0.windows.1.323.g0305acf\n\n"},{"id":"309944","messageId":"20170122195301.1784-5-philipoakley@iee.org","threadId":"44943","inReplyTo":"20170122195301.1784-1-philipoakley@iee.org","subject":"[PATCH v3 4/4] git gui: allow for a long recentrepo list","fromName":"Philip Oakley","fromEmail":"philipoakley@iee.org","sentAt":"2017-01-22T19:53:01Z","receivedAt":"2017-01-22T19:53:27Z","isPatch":true,"sender":{"key":"philipoakley@iee.email","avatar":"https://avatars.githubusercontent.com/u/914343?v=4"},"body":"The gui.recentrepo list may be longer than the maxrecent setting.\nAllow extra space to show any extra entries.\n\nIn an ideal world, the git gui would limit the number of entries\nto the maxrecent setting, however the recentrepo config list may\nhave been extended outwith the gui, or the maxrecent setting changed\nto a reduced value. Further, when testing the gui's recentrepo\nlogic it is useful to show these extra, but valid, entries.\n\nSigned-off-by: Philip Oakley <philipoakley@iee.org>\n---\n lib/choose_repository.tcl | 6 +++++-\n 1 file changed, 5 insertions(+), 1 deletion(-)\n\ndiff --git a/lib/choose_repository.tcl b/lib/choose_repository.tcl\nindex f39636f..80f5a59 100644\n--- a/lib/choose_repository.tcl\n+++ b/lib/choose_repository.tcl\n@@ -142,6 +142,10 @@ constructor pick {} {\n \t\t\t\t-label [mc \"Recent Repositories\"]\n \t\t}\n \n+\tif {[set lenrecent [llength $sorted_recent]] < $maxrecent} {\n+\t\tset lenrecent $maxrecent\n+\t}\n+\n \t\t${NS}::label $w_body.space\n \t\t${NS}::label $w_body.recentlabel \\\n \t\t\t-anchor w \\\n@@ -153,7 +157,7 @@ constructor pick {} {\n \t\t\t-background [get_bg_color $w_body.recentlabel] \\\n \t\t\t-wrap none \\\n \t\t\t-width 50 \\\n-\t\t\t-height $maxrecent\n+\t\t\t-height $lenrecent\n \t\t$w_recentlist tag conf link \\\n \t\t\t-foreground blue \\\n \t\t\t-underline 1\n-- \n2.9.0.windows.1.323.g0305acf\n\n"},{"id":"311336","messageId":"B8156313FCCD473C988E790F7ABEC224@PhilipOakley","threadId":"44943","inReplyTo":"20170122195301.1784-1-philipoakley@iee.org","subject":"Re: [PATCH v3 0/4] git gui: allow for a long recentrepo list","fromName":"Philip Oakley","fromEmail":"philipoakley@iee.org","sentAt":null,"receivedAt":"2017-02-11T12:48:45Z","isPatch":true,"sender":{"key":"philipoakley@iee.email","avatar":"https://avatars.githubusercontent.com/u/914343?v=4"},"body":"Ping\n\nAny comments anyone?\n(https://public-inbox.org/git/20170122195301.1784-1-philipoakley@iee.org/)\n\nI understand that the Git-for-Windows team is planning to include this in \ntheir next release, so additional eyes are welcomed.\n\nPhilip\n\nFrom: \"Philip Oakley\" <philipoakley@iee.org> date: Sunday, January 22, 2017 \n7:52 PM\n> Way back in December 2015 I made a couple of attempts to patch up\n> the git-gui's recentrepo list in the face of duplicate entries in\n> the .gitconfig\n>\n> The series end at \n> http://public-inbox.org/git/9731888BD4C348F5BFC82FA96D978034@PhilipOakley/\n>\n> A similar problem was reported recently on the Git for Windows list\n> https://github.com/git-for-windows/git/issues/1014 were a full\n> recentrepo list also stopped the gui working.\n>\n> This series applies to Pat Thoyt's upstream Github repo as a merge\n> ready Pull Request https://github.com/patthoyts/git-gui/pull/10.\n> Hence if applied here it should be into the sub-tree git/git-gui.\n>\n> I believe I've covered the points raised by Junio in the last review\n> and allowed for cases where the recentrepo list is now longer than the\n> maximum (which can be configured, both up and down).\n>\n> I've cc'd just the cover letter to those involved previously, rather\n> than the series to avoid spamming.\n>\n> There are various other low hanging fruit that the eager could look at\n> which are detailed at the end of the GfW/issues/104 referenced above.\n>\n> Philip Oakley (4):\n>  git-gui: remove duplicate entries from .gitconfig's gui.recentrepo\n>  git gui: cope with duplicates in _get_recentrepo\n>  git gui: de-dup selected repo from recentrepo history\n>  git gui: allow for a long recentrepo list\n>\n> lib/choose_repository.tcl | 17 ++++++++++-------\n> 1 file changed, 10 insertions(+), 7 deletions(-)\n>\n> -- \n> 2.9.0.windows.1.323.g0305acf\n> ---\n> cc: Junio C Hamano <gitster@pobox.com>\n> cc: Pat Thoyts <patthoyts@users.sourceforge.net>,\n> cc: Eric Sunshine <sunshine@sunshineco.com>,\n> cc: Alexey Astakhov <asstv7@gmail.com>\n> cc: Johannes Schindelin <johannes.schindelin@gmx.de>\n>\n> \n\n"}]}