Skip to contentSkip to conversation

git-gui: simplify using nice

PATCH Superseded Mark Levedahl 3 participants 5 messages Aug 20, 2025 – Aug 21, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 git-gui: simplify using nice

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, lets simplify it.

---
 git-gui.sh | 30 +++++++-----------------------
 1 file changed, 7 insertions(+), 23 deletions(-)
git-gui.sh +7 -23
index 4528b22..5ee08d5 100755
@@ -578,21 +578,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 {}
 }
@@ -626,15 +611,14 @@ proc git_read {cmd {redir {}}} {
 	return [safe_open_command $cmdp $redir]
 }
 
-proc git_read_nice {cmd} {
-	global _git
-	set opt [list]
-
-	_lappend_nice opt
-
-	set cmdp [concat [list $_git] $cmd]
+set _nice [_which nice]
+if {[catch {safe_exec [list $_nice git version]}]} {
+	set _nice {}
+}
 
-	return [safe_open_command [concat $opt $cmdp]]
+proc git_read_nice {cmd} {
+	set cmdp [list {*}$::_nice $::_git {*}$cmd]
+	return [safe_open_command $cmdp]
 }
 
 proc git_write {cmd} {
Signature · 1 line
2.51.0.99.15
#1 lore raw
Quoted 1 line

Re: [PATCH] git-gui: simplify using nice

s/using nice/using nice(1)/ ?

Quoted 3 lines · Mark Levedahl

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, lets simplify it.

s/, lets simplify it/; let's simplify it/

Quoted 2 lines
Signature · 1 line
Kristoffer Haugsbakk
#2 lore raw

PATCH v2 1/1 git-gui: simplify using nice(1)

In reply to Mark Levedahl

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; lets simplify it.

---
updates from v1:
- _which does not return a list, _nice must be a list to handle path with spaces (should have been in v1, was in another patch - oops)
- Address Kristoffer Haugsbakk's comments

 git-gui.sh | 30 +++++++-----------------------
 1 file changed, 7 insertions(+), 23 deletions(-)
git-gui.sh +7 -23
index 4528b22..be0b8d9 100755
@@ -578,21 +578,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 {}
 }
@@ -626,15 +611,14 @@ proc git_read {cmd {redir {}}} {
 	return [safe_open_command $cmdp $redir]
 }
 
-proc git_read_nice {cmd} {
-	global _git
-	set opt [list]
-
-	_lappend_nice opt
-
-	set cmdp [concat [list $_git] $cmd]
+set _nice [list [_which nice]]
+if {[catch {safe_exec [list {*}$_nice git version]}]} {
+	set _nice {}
+}
 
-	return [safe_open_command [concat $opt $cmdp]]
+proc git_read_nice {cmd} {
+	set cmdp [list {*}$::_nice $::_git {*}$cmd]
+	return [safe_open_command $cmdp]
 }
 
 proc git_write {cmd} {
Signature · 1 line
2.51.0.99.15
#3 lore raw

Re: [PATCH v2] git-gui: simplify using nice(1)

Am 20.08.25 um 18:50 schrieb Mark Levedahl:

Quoted 53 lines

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; lets simplify it.

---
updates from v1:
- _which does not return a list, _nice must be a list to handle path with spaces (should have been in v1, was in another patch - oops)
- Address Kristoffer Haugsbakk's comments

 git-gui.sh | 30 +++++++-----------------------
 1 file changed, 7 insertions(+), 23 deletions(-)
git-gui.sh +2 -22
index 4528b22..be0b8d9 100755
@@ -578,21 +578,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 {}
 }
@@ -626,15 +611,14 @@ proc git_read {cmd {redir {}}} {
 	return [safe_open_command $cmdp $redir]
 }
 
-proc git_read_nice {cmd} {
-	global _git
-	set opt [list]
-
-	_lappend_nice opt
-
-	set cmdp [concat [list $_git] $cmd]
+set _nice [list [_which nice]]
+if {[catch {safe_exec [list {*}$_nice git version]}]} {

git-gui.sh proc git_read {cmd {redir {}}} { · line 624

Quoted 10 lines
git-gui.sh +5 -1
+	set _nice {}
+}
 
-	return [safe_open_command [concat $opt $cmdp]]
+proc git_read_nice {cmd} {
+	set cmdp [list {*}$::_nice $::_git {*}$cmd]
+	return [safe_open_command $cmdp]
 }
 
 proc git_write {cmd} {

Thank you, that saves quite a few lines. A difference is that nice was looked up only when needed and now it's on every startup. Personally, I don't mind this change. It should not have a noticable effect on the responsiveness.

Queued with an apostrophe in "let's".

-- Hannes

#4 lore raw

Re: [PATCH v2] git-gui: simplify using nice(1)

Quoted 9 lines · Johannes Sixt

Thank you, that saves quite a few lines. A difference is that nice was looked up only when needed and now it's on every startup. Personally, I don't mind this change. It should not have a noticable effect on the responsiveness.

Queued with an apostrophe in "let's".

-- Hannes

And, nice was always looked up on startup if a diff on anything was needed, or if running git-blame was asked for, which for me means always so I see no difference in startup.

Mark