]> git.ipfire.org Git - thirdparty/git.git/commitdiff
git-gui: break out a separate function git_read_nice
authorJohannes Sixt <j6t@kdbg.org>
Sat, 3 May 2025 11:11:21 +0000 (13:11 +0200)
committerTaylor Blau <me@ttaylorr.com>
Fri, 23 May 2025 21:04:23 +0000 (17:04 -0400)
There are two callers of git_read that request special treatment using
option --nice. Rewrite them to call a new function git_read_nice that
does the special treatment. Now we can remove all option treatment from
git_read.

git_write has the same capability, but there are no callers that
request --nice. Remove the feature without substitution.

This is a preparation for a later change where we want to make git_read
and friends non-variadic. Then it cannot have optional arguments.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
git-gui.sh
lib/blame.tcl
lib/diff.tcl

index 890a172fc49b335372ecd06a25c6b5d49957a277..28113220af8770686e16aad2c023383f698ef2d8 100755 (executable)
@@ -643,22 +643,16 @@ proc _open_stdout_stderr {cmd} {
 }
 
 proc git_read {args} {
-       set opt [list]
-
-       while {1} {
-               switch -- [lindex $args 0] {
-               --nice {
-                       _lappend_nice opt
-               }
+       set cmdp [_git_cmd [lindex $args 0]]
+       set args [lrange $args 1 end]
 
-               default {
-                       break
-               }
+       return [_open_stdout_stderr [concat $cmdp $args]]
+}
 
-               }
+proc git_read_nice {args} {
+       set opt [list]
 
-               set args [lrange $args 1 end]
-       }
+       _lappend_nice opt
 
        set cmdp [_git_cmd [lindex $args 0]]
        set args [lrange $args 1 end]
@@ -667,28 +661,11 @@ proc git_read {args} {
 }
 
 proc git_write {args} {
-       set opt [list]
-
-       while {1} {
-               switch -- [lindex $args 0] {
-               --nice {
-                       _lappend_nice opt
-               }
-
-               default {
-                       break
-               }
-
-               }
-
-               set args [lrange $args 1 end]
-       }
-
        set cmdp [_git_cmd [lindex $args 0]]
        set args [lrange $args 1 end]
 
-       _trace_exec [concat $opt $cmdp $args]
-       return [open [concat [list | ] $opt $cmdp $args] w]
+       _trace_exec [concat $cmdp $args]
+       return [open [concat [list | ] $cmdp $args] w]
 }
 
 proc githook_read {hook_name args} {
index e70a079fa76f8513765e154eca0245827e85313c..ceb2330266592b2b9a5cb8bab8bf9b0f5f7f6ca4 100644 (file)
@@ -617,7 +617,7 @@ method _exec_blame {cur_w cur_d options cur_s} {
        }
 
        lappend options -- $path
-       set fd [eval git_read --nice blame $options]
+       set fd [eval git_read_nice blame $options]
        fconfigure $fd -blocking 0 -translation lf -encoding utf-8
        fileevent $fd readable [cb _read_blame $fd $cur_w $cur_d]
        set current_fd $fd
index cfa8a414d30d1647086725ec300e04c794897dbc..ce1bad69007bae01e767eba0b50e6150ac3aac33 100644 (file)
@@ -338,7 +338,7 @@ proc start_show_diff {cont_info {add_opts {}}} {
                }
        }
 
-       if {[catch {set fd [eval git_read --nice $cmd]} err]} {
+       if {[catch {set fd [eval git_read_nice $cmd]} err]} {
                set diff_active 0
                unlock_index
                ui_status [mc "Unable to display %s" [escape_path $path]]