Message ID | pull.1287.v2.git.1657809063728.gitgitgadget@gmail.com (mailing list archive) |
---|---|
State | Accepted |
Commit | ccc7b5148bdd9deb33f3cfa5a872a74634105021 |
Headers | show |
Series | [v2] mergetool(vimdiff): allow paths to contain spaces again | expand |
"Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com> writes: > 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 If there were another syntactic fix we need in the future, we may by mistake fix one but not the other, and the test we add in this patch checks only one side but not the other. In a follow-up we may want to unify the two eval invocations to make the testing of this part more robust. But as a minimum and obvious fix, stopping at the above is appropriate for this patch. > + ... > + diff -u expect actual || at_least_one_ko=true I wonder if we still should care about platforms that need to set GIT_TEST_CMP_USE_COPIED_CONTEXT while running our tests. If we use "diff -u" hardcoded like this here, we are declaring that they are now unwelcome to run our tests. It might be just the matter of using "cmp -s" here (or run "diff" without any option). Do we care about emitting the difference in the output? I doubt it. > if test "$at_least_one_ko" = "true" > then > return 255 Thanks.
diff --git a/mergetools/vimdiff b/mergetools/vimdiff index 461a89b6f98..f7e7f270285 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 | 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