Skip to content

Commit 99f7bc1

Browse files
j6tttaylorr
authored andcommitted
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 <[email protected]> Signed-off-by: Taylor Blau <[email protected]>
1 parent 60b0ba0 commit 99f7bc1

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

git-gui.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,11 @@ proc _lappend_nice {cmd_var} {
621621
}
622622

623623
proc git {args} {
624-
set fd [git_read $args]
624+
git_redir $args {}
625+
}
626+
627+
proc git_redir {cmd redir} {
628+
set fd [git_read $cmd $redir]
625629
fconfigure $fd -translation binary -encoding utf-8
626630
set result [string trimright [read $fd] "\n"]
627631
close $fd
@@ -1423,7 +1427,7 @@ proc PARENT {} {
14231427
return $p
14241428
}
14251429
if {$empty_tree eq {}} {
1426-
set empty_tree [git mktree << {}]
1430+
set empty_tree [git_redir [list mktree] [list << {}]]
14271431
}
14281432
return $empty_tree
14291433
}

lib/commit.tcl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,8 @@ A rescan will be automatically started now.
388388
foreach p [concat $PARENT $MERGE_HEAD] {
389389
lappend cmd -p $p
390390
}
391-
lappend cmd <$msg_p
392-
if {[catch {set cmt_id [eval git $cmd]} err]} {
391+
set msgtxt [list <$msg_p]
392+
if {[catch {set cmt_id [git_redir $cmd $msgtxt]} err]} {
393393
catch {file delete $msg_p}
394394
error_popup [strcat [mc "commit-tree failed:"] "\n\n$err"]
395395
ui_status [mc "Commit failed."]

lib/merge.tcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ method _start {} {
118118
set cmd [list git]
119119
lappend cmd merge
120120
lappend cmd --strategy=recursive
121-
lappend cmd [git fmt-merge-msg <[gitdir FETCH_HEAD]]
121+
lappend cmd [git_redir [list fmt-merge-msg] [list <[gitdir FETCH_HEAD]]]
122122
lappend cmd HEAD
123123
lappend cmd $name
124124
}

0 commit comments

Comments
 (0)