summaryrefslogtreecommitdiff
path: root/mergetools
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2022-07-22 22:04:02 (GMT)
committerJunio C Hamano <gitster@pobox.com>2022-07-22 22:04:02 (GMT)
commit4483ea9a01d2a03641ce3c4e3723ea0bfeac705c (patch)
treef04c502496de48c08b96bc80401f850422ec29e2 /mergetools
parent18bbc795fc52dc543e279c213fd1bfe27afc6092 (diff)
parentccc7b5148bdd9deb33f3cfa5a872a74634105021 (diff)
downloadgit-4483ea9a01d2a03641ce3c4e3723ea0bfeac705c.zip
git-4483ea9a01d2a03641ce3c4e3723ea0bfeac705c.tar.gz
git-4483ea9a01d2a03641ce3c4e3723ea0bfeac705c.tar.bz2
Merge branch 'js/vimdiff-quotepath-fix'
Variable quoting fix in the vimdiff driver of "git mergetool" * js/vimdiff-quotepath-fix: mergetool(vimdiff): allow paths to contain spaces again
Diffstat (limited to 'mergetools')
-rw-r--r--mergetools/vimdiff39
1 files changed, 35 insertions, 4 deletions
diff --git a/mergetools/vimdiff b/mergetools/vimdiff
index b045b10..f770b8f 100644
--- a/mergetools/vimdiff
+++ b/mergetools/vimdiff
@@ -414,8 +414,8 @@ merge_cmd () {
if $base_present
then
- eval "$merge_tool_path" \
- -f "$FINAL_CMD" "$LOCAL" "$BASE" "$REMOTE" "$MERGED"
+ eval '"$merge_tool_path"' \
+ -f "$FINAL_CMD" '"$LOCAL"' '"$BASE"' '"$REMOTE"' '"$MERGED"'
else
# If there is no BASE (example: a merge conflict in a new file
# with the same name created in both braches which didn't exist
@@ -424,8 +424,8 @@ merge_cmd () {
FINAL_CMD=$(echo "$FINAL_CMD" | \
sed -e 's:2b:quit:g' -e 's:3b:2b:g' -e 's:4b:3b:g')
- eval "$merge_tool_path" \
- -f "$FINAL_CMD" "$LOCAL" "$REMOTE" "$MERGED"
+ eval '"$merge_tool_path"' \
+ -f "$FINAL_CMD" '"$LOCAL"' '"$REMOTE"' '"$MERGED"'
fi
ret="$?"
@@ -614,6 +614,37 @@ run_unit_tests () {
fi
done
+ # verify that `merge_cmd` handles paths with spaces
+ record_parameters () {
+ >actual
+ for arg
+ do
+ echo "$arg" >>actual
+ done
+ }
+
+ base_present=false
+ LOCAL='lo cal'
+ BASE='ba se'
+ REMOTE="' '"
+ MERGED='mer ged'
+ merge_tool_path=record_parameters
+
+ merge_cmd vimdiff || at_least_one_ko=true
+
+ cat >expect <<-\EOF
+ -f
+ -c
+ echo | leftabove split | leftabove vertical split | 1b | wincmd l | leftabove vertical split | quit | wincmd l | 2b | wincmd j | 3b | tabdo windo diffthis
+ -c
+ tabfirst
+ lo cal
+ ' '
+ mer ged
+ EOF
+
+ diff -u expect actual || at_least_one_ko=true
+
if test "$at_least_one_ko" = "true"
then
return 255