Skip to content

Commit 36c598b

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 331fef4 commit 36c598b

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

gitk-git/gitk

Lines changed: 17 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
@@ -413,7 +423,9 @@ proc start_rev_list {view} {
413423

414424
if {[catch {
415425
set fd [open [concat | git log --no-color -z --pretty=raw $show_notes \
416-
--parents --boundary $args "--" $files] r]
426+
--parents --boundary $args --stdin \
427+
"<<[join [concat $revs "--" \
428+
[escape_filter_paths $files]] "\\n"]"] r]
417429
} err]} {
418430
error_popup "[mc "Error executing git log:"] $err"
419431
return 0
@@ -561,7 +573,10 @@ proc updatecommits {} {
561573
}
562574
if {[catch {
563575
set fd [open [concat | git log --no-color -z --pretty=raw $show_notes \
564-
--parents --boundary $args "--" $vfilelimit($view)] r]
576+
--parents --boundary $args --stdin \
577+
"<<[join [concat $revs "--" \
578+
[escape_filter_paths \
579+
$vfilelimit($view)]] "\\n"]"] r]
565580
} err]} {
566581
error_popup "[mc "Error executing git log:"] $err"
567582
return

0 commit comments

Comments
 (0)