gitk: Escape file paths before piping to git log

Fixes https://github.com/git-for-windows/git/issues/2293

Signed-off-by: Nico Rieck <nico.rieck@gmail.com>
This commit is contained in:
Nico Rieck 2019-08-19 20:46:12 +02:00 коммит произвёл Johannes Schindelin
Родитель 2a234250ba
Коммит 7fcd628637
1 изменённых файлов: 14 добавлений и 2 удалений

Просмотреть файл

@ -353,6 +353,16 @@ proc parseviewrevs {view revs} {
return $ret
}
# Escapes a list of filter paths to be passed to git log via stdin. Note that
# paths must not be quoted.
proc escape_filter_paths {paths} {
set escaped [list]
foreach path $paths {
lappend escaped [string map {\\ \\\\ "\ " "\\\ "} $path]
}
return $escaped
}
# Start off a git log process and arrange to read its output
proc start_rev_list {view} {
global startmsecs commitidx viewcomplete curview
@ -414,7 +424,8 @@ proc start_rev_list {view} {
if {[catch {
set fd [open [concat | git log --no-color -z --pretty=raw $show_notes \
--parents --boundary $args --stdin \
"<<[join [concat $revs "--" $files] "\\n"]"] r]
"<<[join [concat $revs "--" \
[escape_filter_paths $files]] "\\n"]"] r]
} err]} {
error_popup "[mc "Error executing git log:"] $err"
return 0
@ -568,7 +579,8 @@ proc updatecommits {} {
set fd [open [concat | git log --no-color -z --pretty=raw $show_notes \
--parents --boundary $args --stdin \
"<<[join [concat $revs "--" \
$vfilelimit($view)] "\\n"]"] r]
[escape_filter_paths \
$vfilelimit($view)]] "\\n"]"] r]
} err]} {
error_popup "[mc "Error executing git log:"] $err"
return