Skip to content

Commit 11d3bd9

Browse files
gixGit for Windows Build Agent
authored and
Git for Windows Build Agent
committed
gitk: Escape file paths before piping to git log
Fixes #2293 Signed-off-by: Nico Rieck <[email protected]>
1 parent dfd6300 commit 11d3bd9

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

gitk-git/gitk

+14-2
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,16 @@ proc parseviewrevs {view revs} {
488488
return $ret
489489
}
490490
491+
# Escapes a list of filter paths to be passed to git log via stdin. Note that
492+
# paths must not be quoted.
493+
proc escape_filter_paths {paths} {
494+
set escaped [list]
495+
foreach path $paths {
496+
lappend escaped [string map {\\ \\\\ "\ " "\\\ "} $path]
497+
}
498+
return $escaped
499+
}
500+
491501
# Start off a git log process and arrange to read its output
492502
proc start_rev_list {view} {
493503
global startmsecs commitidx viewcomplete curview
@@ -549,7 +559,8 @@ proc start_rev_list {view} {
549559
if {[catch {
550560
set fd [open [concat | git log --no-color -z --pretty=raw $show_notes \
551561
--parents --boundary $args --stdin \
552-
"<<[join [concat $revs "--" $files] "\\n"]"] r]
562+
"<<[join [concat $revs "--" \
563+
[escape_filter_paths $files]] "\\n"]"] r]
553564
} err]} {
554565
error_popup "[mc "Error executing git log:"] $err"
555566
return 0
@@ -703,7 +714,8 @@ proc updatecommits {} {
703714
set fd [open [concat | git log --no-color -z --pretty=raw $show_notes \
704715
--parents --boundary $args --stdin \
705716
"<<[join [concat $revs "--" \
706-
$vfilelimit($view)] "\\n"]"] r]
717+
[escape_filter_paths \
718+
$vfilelimit($view)]] "\\n"]"] r]
707719
} err]} {
708720
error_popup "[mc "Error executing git log:"] $err"
709721
return

0 commit comments

Comments
 (0)