aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Sixt <j6t@kdbg.org>2025-05-04 20:26:11 +0200
committerTaylor Blau <me@ttaylorr.com>2025-05-23 17:04:24 -0400
commit99f7bc1af65fabab907bf35e645241f714e7386e (patch)
treea8924f8deb0d5462d3391d57c814ee370352c6e5
parentgit-gui: pass redirections as separate argument to git_read (diff)
downloadgit-99f7bc1af65fabab907bf35e645241f714e7386e.tar.gz
git-99f7bc1af65fabab907bf35e645241f714e7386e.zip
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 <j6t@kdbg.org> Signed-off-by: Taylor Blau <me@ttaylorr.com>
Diffstat (limited to '')
-rwxr-xr-xgit-gui.sh8
-rw-r--r--lib/commit.tcl4
-rw-r--r--lib/merge.tcl2
3 files changed, 9 insertions, 5 deletions
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
}