Skip to content

Commit 321e3f9

Browse files
gixdscho
authored andcommitted
gitk: Escape file paths before piping to git log
Fixes #2293 Signed-off-by: Nico Rieck <[email protected]>
1 parent fd690c3 commit 321e3f9

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
@@ -353,6 +353,16 @@ proc parseviewrevs {view revs} {
353353
return $ret
354354
}
355355

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

0 commit comments

Comments
 (0)