Skip to content

Commit 530c5f0

Browse files
committed
Merge branch 'ml/misc-simplifications'
* ml/misc-simplifications: git-gui: simplify using nice(1) git-gui: simplify PATH de-duplication
2 parents c242b89 + 1def7b5 commit 530c5f0

File tree

1 file changed

+8
-28
lines changed

1 file changed

+8
-28
lines changed

git-gui.sh

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ if {[is_Windows]} {
103103
set _path_sep {:}
104104
}
105105

106-
set _search_path {}
107106
set _path_seen [dict create]
108107
foreach p [split $env(PATH) $_path_sep] {
109108
# Keep only absolute paths, getting rid of ., empty, etc.
@@ -112,12 +111,9 @@ foreach p [split $env(PATH) $_path_sep] {
112111
}
113112
# Keep only the first occurence of any duplicates.
114113
set norm_p [file normalize $p]
115-
if {[dict exists $_path_seen $norm_p]} {
116-
continue
117-
}
118114
dict set _path_seen $norm_p 1
119-
lappend _search_path $norm_p
120115
}
116+
set _search_path [dict keys $_path_seen]
121117
unset _path_seen
122118

123119
set env(PATH) [join $_search_path $_path_sep]
@@ -583,21 +579,6 @@ proc open_cmd_pipe {cmd path} {
583579
return [open |$run r]
584580
}
585581

586-
proc _lappend_nice {cmd_var} {
587-
global _nice
588-
upvar $cmd_var cmd
589-
590-
if {![info exists _nice]} {
591-
set _nice [_which nice]
592-
if {[catch {safe_exec [list $_nice git version]}]} {
593-
set _nice {}
594-
}
595-
}
596-
if {$_nice ne {}} {
597-
lappend cmd $_nice
598-
}
599-
}
600-
601582
proc git {args} {
602583
git_redir $args {}
603584
}
@@ -631,15 +612,14 @@ proc git_read {cmd {redir {}}} {
631612
return [safe_open_command $cmdp $redir]
632613
}
633614

634-
proc git_read_nice {cmd} {
635-
global _git
636-
set opt [list]
637-
638-
_lappend_nice opt
639-
640-
set cmdp [concat [list $_git] $cmd]
615+
set _nice [list [_which nice]]
616+
if {[catch {safe_exec [list {*}$_nice git version]}]} {
617+
set _nice {}
618+
}
641619

642-
return [safe_open_command [concat $opt $cmdp]]
620+
proc git_read_nice {cmd} {
621+
set cmdp [list {*}$::_nice $::_git {*}$cmd]
622+
return [safe_open_command $cmdp]
643623
}
644624

645625
proc git_write {cmd} {

0 commit comments

Comments
 (0)