{"thread":{"id":"63997","subject":"[PATCH] git-gui: simplify PATH de-duplication","startedAt":"2025-08-20T15:31:51Z","lastAt":"2025-08-21T18:39:27Z","messageCount":2,"participants":["Mark Levedahl","Johannes Sixt"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"524532","messageId":"20250820153143.21181-1-mlevedahl@gmail.com","threadId":"63997","inReplyTo":null,"subject":"[PATCH] git-gui: simplify PATH de-duplication","fromName":"Mark Levedahl","fromEmail":"mlevedahl@gmail.com","sentAt":"2025-08-20T15:31:43Z","receivedAt":"2025-08-20T15:31:51Z","isPatch":true,"sender":{"key":"mdl123@verizon.net","avatar":"https://avatars.githubusercontent.com/u/5302462?v=4"},"body":"git-gui since 8fe7861c51 (\"git-gui: assure PATH has only absolute\nelements.\", 2025-04-11) uses a list to maintain order and a dict to\ndetect duplicated elements without quadratic complexity.  But, Tcl's\ndict explicitly maintains keys in the order first added, thus the list\nis not needed.  Simplify the code.\n\nSigned-off-by: Mark Levedahl <mlevedahl@gmail.com>\n---\n git-gui.sh | 7 +------\n 1 file changed, 1 insertion(+), 6 deletions(-)\n\ndiff --git a/git-gui.sh b/git-gui.sh\nindex b64d065..4528b22 100755\n--- a/git-gui.sh\n+++ b/git-gui.sh\n@@ -103,21 +103,16 @@ if {[is_Windows]} {\n \tset _path_sep {:}\n }\n \n-set _search_path {}\n set _path_seen [dict create]\n foreach p [split $env(PATH) $_path_sep] {\n \t# Keep only absolute paths, getting rid of ., empty, etc.\n \tif {[file pathtype $p] ne {absolute}} {\n \t\tcontinue\n \t}\n-\t# Keep only the first occurence of any duplicates.\n \tset norm_p [file normalize $p]\n-\tif {[dict exists $_path_seen $norm_p]} {\n-\t\tcontinue\n-\t}\n \tdict set _path_seen $norm_p 1\n-\tlappend _search_path $norm_p\n }\n+set _search_path [dict keys $_path_seen]\n unset _path_seen\n \n set env(PATH) [join $_search_path $_path_sep]\n-- \n2.51.0.99.15\n\n"},{"id":"524675","messageId":"db481d03-1ebb-4e85-8b82-21ff3945289d@kdbg.org","threadId":"63997","inReplyTo":"20250820153143.21181-1-mlevedahl@gmail.com","subject":"Re: [PATCH] git-gui: simplify PATH de-duplication","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2025-08-21T18:39:17Z","receivedAt":"2025-08-21T18:39:27Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 20.08.25 um 17:31 schrieb Mark Levedahl:\n> git-gui since 8fe7861c51 (\"git-gui: assure PATH has only absolute\n> elements.\", 2025-04-11) uses a list to maintain order and a dict to\n> detect duplicated elements without quadratic complexity.  But, Tcl's\n> dict explicitly maintains keys in the order first added, thus the list\n> is not needed.  Simplify the code.\n> \n> Signed-off-by: Mark Levedahl <mlevedahl@gmail.com>\n> ---\n>  git-gui.sh | 7 +------\n>  1 file changed, 1 insertion(+), 6 deletions(-)\n> \n> diff --git a/git-gui.sh b/git-gui.sh\n> index b64d065..4528b22 100755\n> --- a/git-gui.sh\n> +++ b/git-gui.sh\n> @@ -103,21 +103,16 @@ if {[is_Windows]} {\n>  \tset _path_sep {:}\n>  }\n>  \n> -set _search_path {}\n>  set _path_seen [dict create]\n>  foreach p [split $env(PATH) $_path_sep] {\n>  \t# Keep only absolute paths, getting rid of ., empty, etc.\n>  \tif {[file pathtype $p] ne {absolute}} {\n>  \t\tcontinue\n>  \t}\n> -\t# Keep only the first occurence of any duplicates.\n>  \tset norm_p [file normalize $p]\n> -\tif {[dict exists $_path_seen $norm_p]} {\n> -\t\tcontinue\n> -\t}\n>  \tdict set _path_seen $norm_p 1\n> -\tlappend _search_path $norm_p\n>  }\n> +set _search_path [dict keys $_path_seen]\n>  unset _path_seen\n>  \n>  set env(PATH) [join $_search_path $_path_sep]\n\nThanks, this looks good; queued. I tweaked it to keep the comment.\n\n-- Hannes\n\n"}]}