Skip to content

Commit 62f9a63

Browse files
moypatthoyts
authored andcommitted
git-gui: use shell to launch textconv filter in "blame"
The textconv filters may include multiple arguments and may make use of unix shell features. To maintain compatibility with 'git blame' ensure these commands are passed through bash. Reported-by: Kirill Smelkov <[email protected]> Signed-off-by: Matthieu Moy <[email protected]> Signed-off-by: Pat Thoyts <[email protected]>
1 parent 7807777 commit 62f9a63

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ endif
215215
$(GITGUI_MAIN): git-gui.sh GIT-VERSION-FILE GIT-GUI-VARS
216216
$(QUIET_GEN)rm -f $@ $@+ && \
217217
sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
218+
-e 's|@@SHELL_PATH@@|$(SHELL_PATH_SQ)|' \
218219
-e '1,30s|^ argv0=$$0| argv0=$(GITGUI_SCRIPT)|' \
219220
-e '1,30s|^ exec wish | exec '\''$(TCLTK_PATH_SED)'\'' |' \
220221
-e 's/@@GITGUI_VERSION@@/$(GITGUI_VERSION)/g' \

git-gui.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ set _githtmldir {}
128128
set _reponame {}
129129
set _iscygwin {}
130130
set _search_path {}
131+
set _shellpath {@@SHELL_PATH@@}
131132

132133
set _trace [lsearch -exact $argv --trace]
133134
if {$_trace >= 0} {
@@ -137,6 +138,11 @@ if {$_trace >= 0} {
137138
set _trace 0
138139
}
139140

141+
proc shellpath {} {
142+
global _shellpath
143+
return $_shellpath
144+
}
145+
140146
proc appname {} {
141147
global _appname
142148
return $_appname

lib/blame.tcl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,9 @@ method _load {jump} {
460460
}
461461
if {$commit eq {}} {
462462
if {$do_textconv ne 0} {
463-
set fd [open |[list $textconv $path] r]
463+
# Run textconv with sh -c "..." to allow it to
464+
# contain command + arguments.
465+
set fd [open |[list [shellpath] -c "$textconv \"\$0\"" $path] r]
464466
} else {
465467
set fd [open $path r]
466468
}

0 commit comments

Comments
 (0)