Skip to content

Commit 60b0ba0

Browse files
j6tttaylorr
authored andcommitted
git-gui: pass redirections as separate argument to git_read
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. Rewrite direct call sites of git_read to pass intentional redirections as a second (optional) argument. git_read defers to safe_open_command, but we cannot make it safe, yet, because one of the callers of git_read is proc git, which does not yet know which of its arguments are redirections. This is the topic of the next commit. Signed-off-by: Johannes Sixt <[email protected]> Signed-off-by: Taylor Blau <[email protected]>
1 parent 1e0a93c commit 60b0ba0

File tree

5 files changed

+9
-10
lines changed

5 files changed

+9
-10
lines changed

git-gui.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -642,11 +642,11 @@ proc safe_open_command {cmd {redir {}}} {
642642
return $fd
643643
}
644644

645-
proc git_read {cmd} {
645+
proc git_read {cmd {redir {}}} {
646646
set cmdp [_git_cmd [lindex $cmd 0]]
647647
set cmd [lrange $cmd 1 end]
648648

649-
return [safe_open_command [concat $cmdp $cmd]]
649+
return [safe_open_command [concat $cmdp $cmd] $redir]
650650
}
651651

652652
proc git_read_nice {cmd} {
@@ -669,7 +669,7 @@ proc git_write {cmd} {
669669
}
670670

671671
proc githook_read {hook_name args} {
672-
git_read [concat [list hook run --ignore-missing $hook_name --] $args 2>@1]
672+
git_read [concat [list hook run --ignore-missing $hook_name --] $args] [list 2>@1]
673673
}
674674

675675
proc kill_file_process {fd} {

lib/checkout_op.tcl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,8 @@ method _readtree {} {
352352
--exclude-per-directory=.gitignore \
353353
$HEAD \
354354
$new_hash \
355-
2>@1 \
356-
]]
355+
] \
356+
[list 2>@1]]
357357
fconfigure $fd -blocking 0 -translation binary
358358
fileevent $fd readable [cb _readtree_wait $fd $status_bar_operation]
359359
}

lib/choose_repository.tcl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -959,8 +959,8 @@ method _do_clone_checkout {HEAD} {
959959
-v \
960960
HEAD \
961961
HEAD \
962-
2>@1 \
963-
]]
962+
] \
963+
[list 2>@1]]
964964
fconfigure $fd -blocking 0 -translation binary
965965
fileevent $fd readable [cb _readtree_wait $fd]
966966
}

lib/console.tcl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ method _init {} {
9292

9393
method exec {cmd {after {}}} {
9494
if {[lindex $cmd 0] eq {git}} {
95-
lappend cmd 2>@1
96-
set fd_f [git_read [lrange $cmd 1 end]]
95+
set fd_f [git_read [lrange $cmd 1 end] [list 2>@1]]
9796
} else {
9897
set fd_f [safe_open_command $cmd [list 2>@1]]
9998
}

lib/merge.tcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ Continue with resetting the current changes?"]
239239
}
240240

241241
if {[ask_popup $op_question] eq {yes}} {
242-
set fd [git_read [list read-tree --reset -u -v HEAD 2>@1]]
242+
set fd [git_read [list read-tree --reset -u -v HEAD] [list 2>@1]]
243243
fconfigure $fd -blocking 0 -translation binary
244244
set status_bar_operation [$::main_status \
245245
start \

0 commit comments

Comments
 (0)