summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNico Rieck <nico.rieck@gmail.com>2023-01-24 11:23:17 +0000
committerJunio C Hamano <gitster@pobox.com>2023-05-08 09:15:24 -0700
commit7dd272eca153058da2e8d5b9960bbbf0b4f0cbaa (patch)
tree321b4ea87c8c94b4b2977c5ccbb2553a393dc13f
parentbb5cb23daf751790950ff9f761f8884e21c88d00 (diff)
downloadgit-7dd272eca153058da2e8d5b9960bbbf0b4f0cbaa.tar.gz
gitk: escape file paths before piping to git log
We just started piping the file paths via `stdin` instead of passing them via the command-line, to avoid running into command-line limitations. However, since we now pipe the file paths, we need to take care of special characters. This fixes https://github.com/git-for-windows/git/issues/2293 Signed-off-by: Nico Rieck <nico.rieck@gmail.com> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rwxr-xr-xgitk16
1 files changed, 14 insertions, 2 deletions
diff --git a/gitk b/gitk
index 92375ca6a2..df3ba2ea99 100755
--- a/gitk
+++ b/gitk
@@ -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