Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mergetool(vimdiff): allow paths to contain spaces again #3960

Merged
merged 1 commit into from
Jul 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 35 additions & 4 deletions mergetools/vimdiff
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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="$?"
Expand Down Expand Up @@ -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=1
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 | split | vertical split | 1b | wincmd l | 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
Expand Down