From e369dbeb794a21c381dd7b06dac880763140bfb3 Mon Sep 17 00:00:00 2001 From: Mark Levedahl Date: Wed, 20 Aug 2025 11:31:43 -0400 Subject: [PATCH 1/2] git-gui: simplify PATH de-duplication git-gui since 8fe7861c51 ("git-gui: assure PATH has only absolute elements.", 2025-04-11) uses a list to maintain order and a dict to detect duplicated elements without quadratic complexity. But, Tcl's dict explicitly maintains keys in the order first added, thus the list is not needed. Simplify the code. Signed-off-by: Mark Levedahl Signed-off-by: Johannes Sixt --- git-gui.sh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/git-gui.sh b/git-gui.sh index a931d7f7c9..9e0c47f842 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -103,7 +103,6 @@ if {[is_Windows]} { set _path_sep {:} } -set _search_path {} set _path_seen [dict create] foreach p [split $env(PATH) $_path_sep] { # Keep only absolute paths, getting rid of ., empty, etc. @@ -112,12 +111,9 @@ foreach p [split $env(PATH) $_path_sep] { } # Keep only the first occurence of any duplicates. set norm_p [file normalize $p] - if {[dict exists $_path_seen $norm_p]} { - continue - } dict set _path_seen $norm_p 1 - lappend _search_path $norm_p } +set _search_path [dict keys $_path_seen] unset _path_seen set env(PATH) [join $_search_path $_path_sep] From 1def7b5705885f8cf11afac1d37000c0c88c6c3f Mon Sep 17 00:00:00 2001 From: Mark Levedahl Date: Wed, 20 Aug 2025 12:50:21 -0400 Subject: [PATCH 2/2] git-gui: simplify using nice(1) git-gui invokes some long running commands using "nice git $cmd" if nice is found and works, otherwise just "git $cmd". The current code is more complex than needed; let's simplify it. Signed-off-by: Mark Levedahl Signed-off-by: Johannes Sixt --- git-gui.sh | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/git-gui.sh b/git-gui.sh index 9e0c47f842..c827d9d3b8 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -579,21 +579,6 @@ proc open_cmd_pipe {cmd path} { return [open |$run r] } -proc _lappend_nice {cmd_var} { - global _nice - upvar $cmd_var cmd - - if {![info exists _nice]} { - set _nice [_which nice] - if {[catch {safe_exec [list $_nice git version]}]} { - set _nice {} - } - } - if {$_nice ne {}} { - lappend cmd $_nice - } -} - proc git {args} { git_redir $args {} } @@ -627,15 +612,14 @@ proc git_read {cmd {redir {}}} { return [safe_open_command $cmdp $redir] } +set _nice [list [_which nice]] +if {[catch {safe_exec [list {*}$_nice git version]}]} { + set _nice {} +} + proc git_read_nice {cmd} { - global _git - set opt [list] - - _lappend_nice opt - - set cmdp [concat [list $_git] $cmd] - - return [safe_open_command [concat $opt $cmdp]] + set cmdp [list {*}$::_nice $::_git {*}$cmd] + return [safe_open_command $cmdp] } proc git_write {cmd} {