]> git.ipfire.org Git - thirdparty/git.git/commitdiff
git-gui: pass redirections as separate argument to git_read
authorJohannes Sixt <j6t@kdbg.org>
Sun, 4 May 2025 13:39:03 +0000 (15:39 +0200)
committerTaylor Blau <me@ttaylorr.com>
Fri, 23 May 2025 21:04:24 +0000 (17:04 -0400)
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 <j6t@kdbg.org>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
git-gui.sh
lib/checkout_op.tcl
lib/choose_repository.tcl
lib/console.tcl
lib/merge.tcl

index 408149b5309f68e5e0562620cefa8ee2bdd9eead..bbdbd35d269507c3b4560bb4dc4c1c9f7a1ef10f 100755 (executable)
@@ -642,11 +642,11 @@ proc safe_open_command {cmd {redir {}}} {
        return $fd
 }
 
-proc git_read {cmd} {
+proc git_read {cmd {redir {}}} {
        set cmdp [_git_cmd [lindex $cmd 0]]
        set cmd [lrange $cmd 1 end]
 
-       return [safe_open_command [concat $cmdp $cmd]]
+       return [safe_open_command [concat $cmdp $cmd] $redir]
 }
 
 proc git_read_nice {cmd} {
@@ -669,7 +669,7 @@ proc git_write {cmd} {
 }
 
 proc githook_read {hook_name args} {
-       git_read [concat [list hook run --ignore-missing $hook_name --] $args 2>@1]
+       git_read [concat [list hook run --ignore-missing $hook_name --] $args] [list 2>@1]
 }
 
 proc kill_file_process {fd} {
index 48fd1a3cacdca717e6c4b7674981288c40a7217b..87ed0b48585e055effb947694aaf196afe33afb5 100644 (file)
@@ -352,8 +352,8 @@ method _readtree {} {
                --exclude-per-directory=.gitignore \
                $HEAD \
                $new_hash \
-               2>@1 \
-               ]]
+               ] \
+               [list 2>@1]]
        fconfigure $fd -blocking 0 -translation binary
        fileevent $fd readable [cb _readtree_wait $fd $status_bar_operation]
 }
index 7b64a112395d68abd5d4401f03e0bc01603acbd8..5b361cc424a6f659b9a1a2d4915efe28769919cb 100644 (file)
@@ -959,8 +959,8 @@ method _do_clone_checkout {HEAD} {
                -v \
                HEAD \
                HEAD \
-               2>@1 \
-               ]]
+               ] \
+               [list 2>@1]]
        fconfigure $fd -blocking 0 -translation binary
        fileevent $fd readable [cb _readtree_wait $fd]
 }
index cc416d48119cf31db5e48798239dda1485f52066..4715ce91e678876e7c374e236677f929c1242b7c 100644 (file)
@@ -92,8 +92,7 @@ method _init {} {
 
 method exec {cmd {after {}}} {
        if {[lindex $cmd 0] eq {git}} {
-               lappend cmd 2>@1
-               set fd_f [git_read [lrange $cmd 1 end]]
+               set fd_f [git_read [lrange $cmd 1 end] [list 2>@1]]
        } else {
                set fd_f [safe_open_command $cmd [list 2>@1]]
        }
index 6317c32127b3991fa9808c79a150e1a61d472d14..55b4fc5ed3736d4fe44b2ce295b81e5fdd1a0ce9 100644 (file)
@@ -239,7 +239,7 @@ Continue with resetting the current changes?"]
        }
 
        if {[ask_popup $op_question] eq {yes}} {
-               set fd [git_read [list read-tree --reset -u -v HEAD 2>@1]]
+               set fd [git_read [list read-tree --reset -u -v HEAD] [list 2>@1]]
                fconfigure $fd -blocking 0 -translation binary
                set status_bar_operation [$::main_status \
                        start \