From: Johannes Sixt Date: Sun, 4 May 2025 18:26:11 +0000 (+0200) Subject: git-gui: introduce function git_redir for git calls with redirections X-Git-Tag: v2.43.7~4^2^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=99f7bc1af65fabab907bf35e645241f714e7386e;p=thirdparty%2Fgit.git git-gui: introduce function git_redir for git calls with redirections 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 Signed-off-by: Taylor Blau --- diff --git a/git-gui.sh b/git-gui.sh index bbdbd35d26..75d7b9b9fc 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -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 } diff --git a/lib/commit.tcl b/lib/commit.tcl index b27e37d385..bb6056d0ad 100644 --- a/lib/commit.tcl +++ b/lib/commit.tcl @@ -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."] diff --git a/lib/merge.tcl b/lib/merge.tcl index 55b4fc5ed3..44c3f93584 100644 --- a/lib/merge.tcl +++ b/lib/merge.tcl @@ -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 }