Skip to content

Commit aa42e87

Browse files
j6tttaylorr
authored andcommitted
git-gui: break out a separate function git_read_nice
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 <[email protected]> Signed-off-by: Taylor Blau <[email protected]>
1 parent 23ba432 commit aa42e87

File tree

3 files changed

+11
-34
lines changed

3 files changed

+11
-34
lines changed

git-gui.sh

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -643,22 +643,16 @@ proc _open_stdout_stderr {cmd} {
643643
}
644644

645645
proc git_read {args} {
646-
set opt [list]
647-
648-
while {1} {
649-
switch -- [lindex $args 0] {
650-
--nice {
651-
_lappend_nice opt
652-
}
646+
set cmdp [_git_cmd [lindex $args 0]]
647+
set args [lrange $args 1 end]
653648

654-
default {
655-
break
656-
}
649+
return [_open_stdout_stderr [concat $cmdp $args]]
650+
}
657651

658-
}
652+
proc git_read_nice {args} {
653+
set opt [list]
659654

660-
set args [lrange $args 1 end]
661-
}
655+
_lappend_nice opt
662656

663657
set cmdp [_git_cmd [lindex $args 0]]
664658
set args [lrange $args 1 end]
@@ -667,28 +661,11 @@ proc git_read {args} {
667661
}
668662

669663
proc git_write {args} {
670-
set opt [list]
671-
672-
while {1} {
673-
switch -- [lindex $args 0] {
674-
--nice {
675-
_lappend_nice opt
676-
}
677-
678-
default {
679-
break
680-
}
681-
682-
}
683-
684-
set args [lrange $args 1 end]
685-
}
686-
687664
set cmdp [_git_cmd [lindex $args 0]]
688665
set args [lrange $args 1 end]
689666

690-
_trace_exec [concat $opt $cmdp $args]
691-
return [open [concat [list | ] $opt $cmdp $args] w]
667+
_trace_exec [concat $cmdp $args]
668+
return [open [concat [list | ] $cmdp $args] w]
692669
}
693670

694671
proc githook_read {hook_name args} {

lib/blame.tcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ method _exec_blame {cur_w cur_d options cur_s} {
617617
}
618618

619619
lappend options -- $path
620-
set fd [eval git_read --nice blame $options]
620+
set fd [eval git_read_nice blame $options]
621621
fconfigure $fd -blocking 0 -translation lf -encoding utf-8
622622
fileevent $fd readable [cb _read_blame $fd $cur_w $cur_d]
623623
set current_fd $fd

lib/diff.tcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ proc start_show_diff {cont_info {add_opts {}}} {
338338
}
339339
}
340340

341-
if {[catch {set fd [eval git_read --nice $cmd]} err]} {
341+
if {[catch {set fd [eval git_read_nice $cmd]} err]} {
342342
set diff_active 0
343343
unlock_index
344344
ui_status [mc "Unable to display %s" [escape_path $path]]

0 commit comments

Comments
 (0)