Skip to content

Commit 0fe7b01

Browse files
dschoGit for Windows Build Agent
authored and
Git for Windows Build Agent
committed
Merge pull request #2297 from gix/fix/gitk-escape-paths
gitk: Escape file paths before piping to git log
2 parents 71fcf7a + a023b9c commit 0fe7b01

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

gitk-git/gitk

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,16 @@ proc parseviewrevs {view revs} {
354354
return $ret
355355
}
356356

357+
# Escapes a list of filter paths to be passed to git log via stdin. Note that
358+
# paths must not be quoted.
359+
proc escape_filter_paths {paths} {
360+
set escaped [list]
361+
foreach path $paths {
362+
lappend escaped [string map {\\ \\\\ "\ " "\\\ "} $path]
363+
}
364+
return $escaped
365+
}
366+
357367
# Start off a git log process and arrange to read its output
358368
proc start_rev_list {view} {
359369
global startmsecs commitidx viewcomplete curview
@@ -415,7 +425,8 @@ proc start_rev_list {view} {
415425
if {[catch {
416426
set fd [open [concat | git log --no-color -z --pretty=raw $show_notes \
417427
--parents --boundary $args --stdin \
418-
"<<[join [concat $revs "--" $files] "\\n"]"] r]
428+
"<<[join [concat $revs "--" \
429+
[escape_filter_paths $files]] "\\n"]"] r]
419430
} err]} {
420431
error_popup "[mc "Error executing git log:"] $err"
421432
return 0
@@ -569,7 +580,8 @@ proc updatecommits {} {
569580
set fd [open [concat | git log --no-color -z --pretty=raw $show_notes \
570581
--parents --boundary $args --stdin \
571582
"<<[join [concat $revs "--" \
572-
$vfilelimit($view)] "\\n"]"] r]
583+
[escape_filter_paths
584+
$vfilelimit($view)]] "\\n"]"] r]
573585
} err]} {
574586
error_popup "[mc "Error executing git log:"] $err"
575587
return

0 commit comments

Comments
 (0)