git-gui: convert git_read*, git_write to be non-variadic
We are going to treat command arguments and redirections differently to avoid passing arguments that look like redirections to the command accidentally. To do so, it will be necessary to know which arguments are intentional redirections. As a preparation, convert git_read, git_read_nice, and git_write to take just a single argument that is the command in a list. Adjust all call sites accordingly. In the future, this argument will be the regular command arguments and a second argument will be the redirection operations. Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Taylor Blau <me@ttaylorr.com>maint
parent
074c2b9d7c
commit
dc9ecb1aab
48
git-gui.sh
48
git-gui.sh
|
|
@ -621,7 +621,7 @@ proc _lappend_nice {cmd_var} {
|
|||
}
|
||||
|
||||
proc git {args} {
|
||||
set fd [eval [list git_read] $args]
|
||||
set fd [git_read $args]
|
||||
fconfigure $fd -translation binary -encoding utf-8
|
||||
set result [string trimright [read $fd] "\n"]
|
||||
close $fd
|
||||
|
|
@ -642,34 +642,34 @@ proc _open_stdout_stderr {cmd} {
|
|||
return $fd
|
||||
}
|
||||
|
||||
proc git_read {args} {
|
||||
set cmdp [_git_cmd [lindex $args 0]]
|
||||
set args [lrange $args 1 end]
|
||||
proc git_read {cmd} {
|
||||
set cmdp [_git_cmd [lindex $cmd 0]]
|
||||
set cmd [lrange $cmd 1 end]
|
||||
|
||||
return [_open_stdout_stderr [concat $cmdp $args]]
|
||||
return [_open_stdout_stderr [concat $cmdp $cmd]]
|
||||
}
|
||||
|
||||
proc git_read_nice {args} {
|
||||
proc git_read_nice {cmd} {
|
||||
set opt [list]
|
||||
|
||||
_lappend_nice opt
|
||||
|
||||
set cmdp [_git_cmd [lindex $args 0]]
|
||||
set args [lrange $args 1 end]
|
||||
set cmdp [_git_cmd [lindex $cmd 0]]
|
||||
set cmd [lrange $cmd 1 end]
|
||||
|
||||
return [_open_stdout_stderr [concat $opt $cmdp $args]]
|
||||
return [_open_stdout_stderr [concat $opt $cmdp $cmd]]
|
||||
}
|
||||
|
||||
proc git_write {args} {
|
||||
set cmdp [_git_cmd [lindex $args 0]]
|
||||
set args [lrange $args 1 end]
|
||||
proc git_write {cmd} {
|
||||
set cmdp [_git_cmd [lindex $cmd 0]]
|
||||
set cmd [lrange $cmd 1 end]
|
||||
|
||||
_trace_exec [concat $cmdp $args]
|
||||
return [open [concat [list | ] $cmdp $args] w]
|
||||
_trace_exec [concat $cmdp $cmd]
|
||||
return [open [concat [list | ] $cmdp $cmd] w]
|
||||
}
|
||||
|
||||
proc githook_read {hook_name args} {
|
||||
git_read hook run --ignore-missing $hook_name -- $args 2>@1
|
||||
git_read [concat [list hook run --ignore-missing $hook_name --] $args 2>@1]
|
||||
}
|
||||
|
||||
proc kill_file_process {fd} {
|
||||
|
|
@ -1110,10 +1110,10 @@ proc _parse_config {arr_name args} {
|
|||
array unset arr
|
||||
set buf {}
|
||||
catch {
|
||||
set fd_rc [eval \
|
||||
[list git_read config] \
|
||||
set fd_rc [git_read \
|
||||
[concat config \
|
||||
$args \
|
||||
[list --null --list]]
|
||||
--null --list]]
|
||||
fconfigure $fd_rc -translation binary -encoding utf-8
|
||||
set buf [read $fd_rc]
|
||||
close $fd_rc
|
||||
|
|
@ -1482,12 +1482,12 @@ proc rescan {after {honor_trustmtime 1}} {
|
|||
} else {
|
||||
set rescan_active 1
|
||||
ui_status [mc "Refreshing file status..."]
|
||||
set fd_rf [git_read update-index \
|
||||
set fd_rf [git_read [list update-index \
|
||||
-q \
|
||||
--unmerged \
|
||||
--ignore-missing \
|
||||
--refresh \
|
||||
]
|
||||
]]
|
||||
fconfigure $fd_rf -blocking 0 -translation binary
|
||||
fileevent $fd_rf readable \
|
||||
[list rescan_stage2 $fd_rf $after]
|
||||
|
|
@ -1527,11 +1527,11 @@ proc rescan_stage2 {fd after} {
|
|||
set rescan_active 2
|
||||
ui_status [mc "Scanning for modified files ..."]
|
||||
if {[git-version >= "1.7.2"]} {
|
||||
set fd_di [git_read diff-index --cached --ignore-submodules=dirty -z [PARENT]]
|
||||
set fd_di [git_read [list diff-index --cached --ignore-submodules=dirty -z [PARENT]]]
|
||||
} else {
|
||||
set fd_di [git_read diff-index --cached -z [PARENT]]
|
||||
set fd_di [git_read [list diff-index --cached -z [PARENT]]]
|
||||
}
|
||||
set fd_df [git_read diff-files -z]
|
||||
set fd_df [git_read [list diff-files -z]]
|
||||
|
||||
fconfigure $fd_di -blocking 0 -translation binary -encoding binary
|
||||
fconfigure $fd_df -blocking 0 -translation binary -encoding binary
|
||||
|
|
@ -1540,7 +1540,7 @@ proc rescan_stage2 {fd after} {
|
|||
fileevent $fd_df readable [list read_diff_files $fd_df $after]
|
||||
|
||||
if {[is_config_true gui.displayuntracked]} {
|
||||
set fd_lo [eval git_read ls-files --others -z $ls_others]
|
||||
set fd_lo [git_read [concat ls-files --others -z $ls_others]]
|
||||
fconfigure $fd_lo -blocking 0 -translation binary -encoding binary
|
||||
fileevent $fd_lo readable [list read_ls_others $fd_lo $after]
|
||||
incr rescan_active
|
||||
|
|
|
|||
|
|
@ -486,9 +486,9 @@ method _load {jump} {
|
|||
fconfigure $fd -eofchar {}
|
||||
} else {
|
||||
if {$do_textconv ne 0} {
|
||||
set fd [git_read cat-file --textconv "$commit:$path"]
|
||||
set fd [git_read [list cat-file --textconv "$commit:$path"]]
|
||||
} else {
|
||||
set fd [git_read cat-file blob "$commit:$path"]
|
||||
set fd [git_read [list cat-file blob "$commit:$path"]]
|
||||
}
|
||||
}
|
||||
fconfigure $fd \
|
||||
|
|
@ -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 [git_read_nice [concat 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
|
||||
|
|
@ -986,7 +986,7 @@ method _showcommit {cur_w lno} {
|
|||
if {[catch {set msg $header($cmit,message)}]} {
|
||||
set msg {}
|
||||
catch {
|
||||
set fd [git_read cat-file commit $cmit]
|
||||
set fd [git_read [list cat-file commit $cmit]]
|
||||
fconfigure $fd -encoding binary -translation lf
|
||||
# By default commits are assumed to be in utf-8
|
||||
set enc utf-8
|
||||
|
|
@ -1134,7 +1134,7 @@ method _blameparent {} {
|
|||
} else {
|
||||
set diffcmd [list diff-tree --unified=0 $cparent $cmit -- $new_path]
|
||||
}
|
||||
if {[catch {set fd [eval git_read $diffcmd]} err]} {
|
||||
if {[catch {set fd [git_read $diffcmd]} err]} {
|
||||
$status_operation stop [mc "Unable to display parent"]
|
||||
error_popup [strcat [mc "Error loading diff:"] "\n\n$err"]
|
||||
return
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ proc load_all_heads {} {
|
|||
set rh refs/heads
|
||||
set rh_len [expr {[string length $rh] + 1}]
|
||||
set all_heads [list]
|
||||
set fd [git_read for-each-ref --format=%(refname) $rh]
|
||||
set fd [git_read [list for-each-ref --format=%(refname) $rh]]
|
||||
fconfigure $fd -translation binary -encoding utf-8
|
||||
while {[gets $fd line] > 0} {
|
||||
if {!$some_heads_tracking || ![is_tracking_branch $line]} {
|
||||
|
|
@ -21,10 +21,10 @@ proc load_all_heads {} {
|
|||
|
||||
proc load_all_tags {} {
|
||||
set all_tags [list]
|
||||
set fd [git_read for-each-ref \
|
||||
set fd [git_read [list for-each-ref \
|
||||
--sort=-taggerdate \
|
||||
--format=%(refname) \
|
||||
refs/tags]
|
||||
refs/tags]]
|
||||
fconfigure $fd -translation binary -encoding utf-8
|
||||
while {[gets $fd line] > 0} {
|
||||
if {![regsub ^refs/tags/ $line {} name]} continue
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@ method _ls {tree_id {name {}}} {
|
|||
lappend browser_stack [list $tree_id $name]
|
||||
$w conf -state disabled
|
||||
|
||||
set fd [git_read ls-tree -z $tree_id]
|
||||
set fd [git_read [list ls-tree -z $tree_id]]
|
||||
fconfigure $fd -blocking 0 -translation binary -encoding utf-8
|
||||
fileevent $fd readable [cb _read $fd]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -304,12 +304,12 @@ The rescan will be automatically started now.
|
|||
_readtree $this
|
||||
} else {
|
||||
ui_status [mc "Refreshing file status..."]
|
||||
set fd [git_read update-index \
|
||||
set fd [git_read [list update-index \
|
||||
-q \
|
||||
--unmerged \
|
||||
--ignore-missing \
|
||||
--refresh \
|
||||
]
|
||||
]]
|
||||
fconfigure $fd -blocking 0 -translation binary
|
||||
fileevent $fd readable [cb _refresh_wait $fd]
|
||||
}
|
||||
|
|
@ -345,7 +345,7 @@ method _readtree {} {
|
|||
[mc "Updating working directory to '%s'..." [_name $this]] \
|
||||
[mc "files checked out"]]
|
||||
|
||||
set fd [git_read read-tree \
|
||||
set fd [git_read [list read-tree \
|
||||
-m \
|
||||
-u \
|
||||
-v \
|
||||
|
|
@ -353,7 +353,7 @@ method _readtree {} {
|
|||
$HEAD \
|
||||
$new_hash \
|
||||
2>@1 \
|
||||
]
|
||||
]]
|
||||
fconfigure $fd -blocking 0 -translation binary
|
||||
fileevent $fd readable [cb _readtree_wait $fd $status_bar_operation]
|
||||
}
|
||||
|
|
@ -573,7 +573,7 @@ method _confirm_reset {cur} {
|
|||
pack $w.buttons.cancel -side right -padx 5
|
||||
pack $w.buttons -side bottom -fill x -pady 10 -padx 10
|
||||
|
||||
set fd [git_read rev-list --pretty=oneline $cur ^$new_hash]
|
||||
set fd [git_read [list rev-list --pretty=oneline $cur ^$new_hash]]
|
||||
while {[gets $fd line] > 0} {
|
||||
set abbr [string range $line 0 7]
|
||||
set subj [string range $line 41 end]
|
||||
|
|
|
|||
|
|
@ -818,9 +818,9 @@ method _clone_refs {} {
|
|||
error_popup [mc "Not a Git repository: %s" [file tail $origin_url]]
|
||||
return 0
|
||||
}
|
||||
set fd_in [git_read for-each-ref \
|
||||
set fd_in [git_read [list for-each-ref \
|
||||
--tcl \
|
||||
{--format=list %(refname) %(objectname) %(*objectname)}]
|
||||
{--format=list %(refname) %(objectname) %(*objectname)}]]
|
||||
cd $pwd
|
||||
|
||||
set fd [safe_open_file [gitdir packed-refs] w]
|
||||
|
|
@ -953,14 +953,14 @@ method _do_clone_checkout {HEAD} {
|
|||
[mc "files"]]
|
||||
|
||||
set readtree_err {}
|
||||
set fd [git_read read-tree \
|
||||
set fd [git_read [list read-tree \
|
||||
-m \
|
||||
-u \
|
||||
-v \
|
||||
HEAD \
|
||||
HEAD \
|
||||
2>@1 \
|
||||
]
|
||||
]]
|
||||
fconfigure $fd -blocking 0 -translation binary
|
||||
fileevent $fd readable [cb _readtree_wait $fd]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -146,14 +146,14 @@ constructor _new {path unmerged_only title} {
|
|||
append fmt { %(*subject)}
|
||||
append fmt {]}
|
||||
set all_refn [list]
|
||||
set fr_fd [git_read for-each-ref \
|
||||
set fr_fd [git_read [list for-each-ref \
|
||||
--tcl \
|
||||
--sort=-taggerdate \
|
||||
--format=$fmt \
|
||||
refs/heads \
|
||||
refs/remotes \
|
||||
refs/tags \
|
||||
]
|
||||
]]
|
||||
fconfigure $fr_fd -translation lf -encoding utf-8
|
||||
while {[gets $fr_fd line] > 0} {
|
||||
set line [eval $line]
|
||||
|
|
@ -176,7 +176,7 @@ constructor _new {path unmerged_only title} {
|
|||
close $fr_fd
|
||||
|
||||
if {$unmerged_only} {
|
||||
set fr_fd [git_read rev-list --all ^$::HEAD]
|
||||
set fr_fd [git_read [list rev-list --all ^$::HEAD]]
|
||||
while {[gets $fr_fd sha1] > 0} {
|
||||
if {[catch {set rlst $cmt_refn($sha1)}]} continue
|
||||
foreach refn $rlst {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ You are currently in the middle of a merge that has not been fully completed. Y
|
|||
if {[catch {
|
||||
set name ""
|
||||
set email ""
|
||||
set fd [git_read cat-file commit $curHEAD]
|
||||
set fd [git_read [list cat-file commit $curHEAD]]
|
||||
fconfigure $fd -encoding binary -translation lf
|
||||
# By default commits are assumed to be in utf-8
|
||||
set enc utf-8
|
||||
|
|
@ -325,7 +325,7 @@ proc commit_commitmsg_wait {fd_ph curHEAD msg_p} {
|
|||
|
||||
proc commit_writetree {curHEAD msg_p} {
|
||||
ui_status [mc "Committing changes..."]
|
||||
set fd_wt [git_read write-tree]
|
||||
set fd_wt [git_read [list write-tree]]
|
||||
fileevent $fd_wt readable \
|
||||
[list commit_committree $fd_wt $curHEAD $msg_p]
|
||||
}
|
||||
|
|
@ -350,7 +350,7 @@ proc commit_committree {fd_wt curHEAD msg_p} {
|
|||
# -- Verify this wasn't an empty change.
|
||||
#
|
||||
if {$commit_type eq {normal}} {
|
||||
set fd_ot [git_read cat-file commit $PARENT]
|
||||
set fd_ot [git_read [list cat-file commit $PARENT]]
|
||||
fconfigure $fd_ot -encoding binary -translation lf
|
||||
set old_tree [gets $fd_ot]
|
||||
close $fd_ot
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ method _init {} {
|
|||
method exec {cmd {after {}}} {
|
||||
lappend cmd 2>@1
|
||||
if {[lindex $cmd 0] eq {git}} {
|
||||
set fd_f [eval git_read [lrange $cmd 1 end]]
|
||||
set fd_f [git_read [lrange $cmd 1 end]]
|
||||
} else {
|
||||
set fd_f [_open_stdout_stderr $cmd]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
proc do_stats {} {
|
||||
global use_ttk NS
|
||||
set fd [git_read count-objects -v]
|
||||
set fd [git_read [list count-objects -v]]
|
||||
while {[gets $fd line] > 0} {
|
||||
if {[regexp {^([^:]+): (\d+)$} $line _ name value]} {
|
||||
set stats($name) $value
|
||||
|
|
|
|||
|
|
@ -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 [git_read_nice $cmd]} err]} {
|
||||
set diff_active 0
|
||||
unlock_index
|
||||
ui_status [mc "Unable to display %s" [escape_path $path]]
|
||||
|
|
@ -617,7 +617,7 @@ proc apply_or_revert_hunk {x y revert} {
|
|||
|
||||
if {[catch {
|
||||
set enc [get_path_encoding $current_diff_path]
|
||||
set p [eval git_write $apply_cmd]
|
||||
set p [git_write $apply_cmd]
|
||||
fconfigure $p -translation binary -encoding $enc
|
||||
puts -nonewline $p $wholepatch
|
||||
close $p} err]} {
|
||||
|
|
@ -853,7 +853,7 @@ proc apply_or_revert_range_or_line {x y revert} {
|
|||
|
||||
if {[catch {
|
||||
set enc [get_path_encoding $current_diff_path]
|
||||
set p [eval git_write $apply_cmd]
|
||||
set p [git_write $apply_cmd]
|
||||
fconfigure $p -translation binary -encoding $enc
|
||||
puts -nonewline $p $current_diff_header
|
||||
puts -nonewline $p $wholepatch
|
||||
|
|
@ -890,7 +890,7 @@ proc undo_last_revert {} {
|
|||
|
||||
if {[catch {
|
||||
set enc $last_revert_enc
|
||||
set p [eval git_write $apply_cmd]
|
||||
set p [git_write $apply_cmd]
|
||||
fconfigure $p -translation binary -encoding $enc
|
||||
puts -nonewline $p $last_revert
|
||||
close $p} err]} {
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ proc update_indexinfo {msg path_list after} {
|
|||
if {$batch > 25} {set batch 25}
|
||||
|
||||
set status_bar_operation [$::main_status start $msg [mc "files"]]
|
||||
set fd [git_write update-index -z --index-info]
|
||||
set fd [git_write [list update-index -z --index-info]]
|
||||
fconfigure $fd \
|
||||
-blocking 0 \
|
||||
-buffering full \
|
||||
|
|
@ -144,7 +144,7 @@ proc update_index {msg path_list after} {
|
|||
if {$batch > 25} {set batch 25}
|
||||
|
||||
set status_bar_operation [$::main_status start $msg [mc "files"]]
|
||||
set fd [git_write update-index --add --remove -z --stdin]
|
||||
set fd [git_write [list update-index --add --remove -z --stdin]]
|
||||
fconfigure $fd \
|
||||
-blocking 0 \
|
||||
-buffering full \
|
||||
|
|
@ -218,13 +218,13 @@ proc checkout_index {msg path_list after capture_error} {
|
|||
if {$batch > 25} {set batch 25}
|
||||
|
||||
set status_bar_operation [$::main_status start $msg [mc "files"]]
|
||||
set fd [git_write checkout-index \
|
||||
set fd [git_write [list checkout-index \
|
||||
--index \
|
||||
--quiet \
|
||||
--force \
|
||||
-z \
|
||||
--stdin \
|
||||
]
|
||||
]]
|
||||
fconfigure $fd \
|
||||
-blocking 0 \
|
||||
-buffering full \
|
||||
|
|
|
|||
|
|
@ -239,7 +239,7 @@ Continue with resetting the current changes?"]
|
|||
}
|
||||
|
||||
if {[ask_popup $op_question] eq {yes}} {
|
||||
set fd [git_read read-tree --reset -u -v HEAD 2>@1]
|
||||
set fd [git_read [list read-tree --reset -u -v HEAD 2>@1]]
|
||||
fconfigure $fd -blocking 0 -translation binary
|
||||
set status_bar_operation [$::main_status \
|
||||
start \
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ proc merge_load_stages {path cont} {
|
|||
set merge_stages(3) {}
|
||||
set merge_stages_buf {}
|
||||
|
||||
set merge_stages_fd [eval git_read ls-files -u -z -- {$path}]
|
||||
set merge_stages_fd [git_read [list ls-files -u -z -- $path]]
|
||||
|
||||
fconfigure $merge_stages_fd -blocking 0 -translation binary -encoding binary
|
||||
fileevent $merge_stages_fd readable [list read_merge_stages $merge_stages_fd $cont]
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ proc all_tracking_branches {} {
|
|||
}
|
||||
|
||||
if {$pat ne {}} {
|
||||
set fd [eval git_read for-each-ref --format=%(refname) $cmd]
|
||||
set fd [git_read [concat for-each-ref --format=%(refname) $cmd]]
|
||||
while {[gets $fd n] > 0} {
|
||||
foreach spec $pat {
|
||||
set dst [string range [lindex $spec 0] 0 end-2]
|
||||
|
|
|
|||
|
|
@ -308,7 +308,7 @@ method _load {cache uri} {
|
|||
set full_list [list]
|
||||
set head_cache($cache) [list]
|
||||
set full_cache($cache) [list]
|
||||
set active_ls [git_read ls-remote $uri]
|
||||
set active_ls [git_read [list ls-remote $uri]]
|
||||
fconfigure $active_ls \
|
||||
-blocking 0 \
|
||||
-translation lf \
|
||||
|
|
|
|||
Loading…
Reference in New Issue