]> git.ipfire.org Git - thirdparty/git.git/commitdiff
git-gui: introduce function git_redir for git calls with redirections
authorJohannes Sixt <j6t@kdbg.org>
Sun, 4 May 2025 18:26:11 +0000 (20:26 +0200)
committerTaylor Blau <me@ttaylorr.com>
Fri, 23 May 2025 21:04:24 +0000 (17:04 -0400)
Proc git invokes git and collects all output, which is it returns.
We are going to treat command arguments and redirections differently to
avoid passing arguments that look like redirections to the command
accidentally. A few invocations also pass redirection operators as
command arguments deliberately. Rewrite these cases to use a new
function git_redir that takes two lists, one for the regular command
arguments and one for the redirection operations.

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

index bbdbd35d269507c3b4560bb4dc4c1c9f7a1ef10f..75d7b9b9fc81bcf7784a7f3b07ae9da361268efd 100755 (executable)
@@ -621,7 +621,11 @@ proc _lappend_nice {cmd_var} {
 }
 
 proc git {args} {
-       set fd [git_read $args]
+       git_redir $args {}
+}
+
+proc git_redir {cmd redir} {
+       set fd [git_read $cmd $redir]
        fconfigure $fd -translation binary -encoding utf-8
        set result [string trimright [read $fd] "\n"]
        close $fd
@@ -1423,7 +1427,7 @@ proc PARENT {} {
                return $p
        }
        if {$empty_tree eq {}} {
-               set empty_tree [git mktree << {}]
+               set empty_tree [git_redir [list mktree] [list << {}]]
        }
        return $empty_tree
 }
index b27e37d38514e0907ca09c8e76da60e6f9bd826f..bb6056d0adb992e9c596dc460d26aba97cd2511a 100644 (file)
@@ -388,8 +388,8 @@ A rescan will be automatically started now.
        foreach p [concat $PARENT $MERGE_HEAD] {
                lappend cmd -p $p
        }
-       lappend cmd <$msg_p
-       if {[catch {set cmt_id [eval git $cmd]} err]} {
+       set msgtxt [list <$msg_p]
+       if {[catch {set cmt_id [git_redir $cmd $msgtxt]} err]} {
                catch {file delete $msg_p}
                error_popup [strcat [mc "commit-tree failed:"] "\n\n$err"]
                ui_status [mc "Commit failed."]
index 55b4fc5ed3736d4fe44b2ce295b81e5fdd1a0ce9..44c3f93584224cdd5d2f6f746f16bbffaace5db0 100644 (file)
@@ -118,7 +118,7 @@ method _start {} {
                set cmd [list git]
                lappend cmd merge
                lappend cmd --strategy=recursive
-               lappend cmd [git fmt-merge-msg <[gitdir FETCH_HEAD]]
+               lappend cmd [git_redir [list fmt-merge-msg] [list <[gitdir FETCH_HEAD]]]
                lappend cmd HEAD
                lappend cmd $name
        }