]> git.ipfire.org Git - thirdparty/git.git/blame - mergetools/vimdiff
mergetools: vimdiff: fix single window layouts
[thirdparty/git.git] / mergetools / vimdiff
CommitLineData
00417974
FR
1# This script can be run in two different contexts:
2#
3# - From git, when the user invokes the "vimdiff" merge tool. In this context
4# this script expects the following environment variables (among others) to
5# be defined (which is something "git" takes care of):
6#
7# - $BASE
8# - $LOCAL
9# - $REMOTE
10# - $MERGED
11#
12# In this mode, all this script does is to run the next command:
13#
14# vim -f -c ... $LOCAL $BASE $REMOTE $MERGED
15#
16# ...where the "..." string depends on the value of the
17# "mergetool.vimdiff.layout" configuration variable and is used to open vim
18# with a certain layout of buffers, windows and tabs.
19#
20# - From a script inside the unit tests framework folder ("t" folder) by
21# sourcing this script and then manually calling "run_unit_tests", which
22# will run a battery of unit tests to make sure nothing breaks.
23# In this context this script does not expect any particular environment
24# variable to be set.
25
26
27################################################################################
28## Internal functions (not meant to be used outside this script)
29################################################################################
30
31debug_print () {
d6191837
FC
32 # Send message to stderr if global variable GIT_MERGETOOL_VIMDIFF_DEBUG
33 # is set.
00417974
FR
34
35 if test -n "$GIT_MERGETOOL_VIMDIFF_DEBUG"
36 then
37 >&2 echo "$@"
38 fi
39}
40
41substring () {
42 # Return a substring of $1 containing $3 characters starting at
43 # zero-based offset $2.
44 #
45 # Examples:
46 #
47 # substring "Hello world" 0 4 --> "Hell"
48 # substring "Hello world" 3 4 --> "lo w"
49 # substring "Hello world" 3 10 --> "lo world"
50
51 STRING=$1
52 START=$2
53 LEN=$3
54
55 echo "$STRING" | cut -c$(( START + 1 ))-$(( START + $LEN ))
56}
57
58gen_cmd_aux () {
59 # Auxiliary function used from "gen_cmd()".
60 # Read that other function documentation for more details.
61
62 LAYOUT=$1
63 CMD=$2 # This is a second (hidden) argument used for recursion
64
65 debug_print
66 debug_print "LAYOUT : $LAYOUT"
67 debug_print "CMD : $CMD"
68
00417974
FR
69 start=0
70 end=${#LAYOUT}
71
72 nested=0
73 nested_min=100
74
75
76 # Step 1:
77 #
78 # Increase/decrease "start"/"end" indices respectively to get rid of
79 # outer parenthesis.
80 #
81 # Example:
82 #
83 # - BEFORE: (( LOCAL , BASE ) / MERGED )
84 # - AFTER : ( LOCAL , BASE ) / MERGED
85
86 oldIFS=$IFS
87 IFS=#
88 for c in $(echo "$LAYOUT" | sed 's:.:&#:g')
89 do
90 if test "$c" = " "
91 then
92 continue
93 fi
94
95 if test "$c" = "("
96 then
97 nested=$(( nested + 1 ))
98 continue
99 fi
100
101 if test "$c" = ")"
102 then
103 nested=$(( nested - 1 ))
104 continue
105 fi
106
107 if test "$nested" -lt "$nested_min"
108 then
109 nested_min=$nested
110 fi
111 done
112 IFS=$oldIFS
113
114 debug_print "NESTED MIN: $nested_min"
115
116 while test "$nested_min" -gt "0"
117 do
118 start=$(( start + 1 ))
119 end=$(( end - 1 ))
120
121 start_minus_one=$(( start - 1 ))
122
123 while ! test "$(substring "$LAYOUT" "$start_minus_one" 1)" = "("
124 do
125 start=$(( start + 1 ))
126 start_minus_one=$(( start_minus_one + 1 ))
127 done
128
129 while ! test "$(substring "$LAYOUT" "$end" 1)" = ")"
130 do
131 end=$(( end - 1 ))
132 done
133
134 nested_min=$(( nested_min - 1 ))
135 done
136
137 debug_print "CLEAN : $(substring "$LAYOUT" "$start" "$(( end - start ))")"
138
139
140 # Step 2:
141 #
ffcc33f6 142 # Search for all valid separators ("/" or ",") which are *not*
00417974
FR
143 # inside parenthesis. Save the index at which each of them makes the
144 # first appearance.
145
00417974
FR
146 index_horizontal_split=""
147 index_vertical_split=""
148
149 nested=0
150 i=$(( start - 1 ))
151
152 oldIFS=$IFS
153 IFS=#
154 for c in $(substring "$LAYOUT" "$start" "$(( end - start ))" | sed 's:.:&#:g');
155 do
156 i=$(( i + 1 ))
157
158 if test "$c" = " "
159 then
160 continue
161 fi
162
163 if test "$c" = "("
164 then
165 nested=$(( nested + 1 ))
166 continue
167 fi
168
169 if test "$c" = ")"
170 then
171 nested=$(( nested - 1 ))
172 continue
173 fi
174
175 if test "$nested" = 0
176 then
177 current=$c
178
ffcc33f6 179 if test "$current" = "/"
00417974
FR
180 then
181 if test -z "$index_horizontal_split"
182 then
183 index_horizontal_split=$i
184 fi
185
186 elif test "$current" = ","
187 then
188 if test -z "$index_vertical_split"
189 then
190 index_vertical_split=$i
191 fi
192 fi
193 fi
194 done
195 IFS=$oldIFS
196
197
198 # Step 3:
199 #
200 # Process the separator with the highest order of precedence
201 # (";" has the highest precedence and "|" the lowest one).
202 #
203 # By "process" I mean recursively call this function twice: the first
204 # one with the substring at the left of the separator and the second one
205 # with the one at its right.
206
207 terminate="false"
208
ffcc33f6 209 if ! test -z "$index_horizontal_split"
00417974 210 then
f3d7623a 211 before="leftabove split"
00417974
FR
212 after="wincmd j"
213 index=$index_horizontal_split
214 terminate="true"
215
216 elif ! test -z "$index_vertical_split"
217 then
f3d7623a 218 before="leftabove vertical split"
00417974
FR
219 after="wincmd l"
220 index=$index_vertical_split
221 terminate="true"
222 fi
223
224 if test "$terminate" = "true"
225 then
226 CMD="$CMD | $before"
227 CMD=$(gen_cmd_aux "$(substring "$LAYOUT" "$start" "$(( index - start ))")" "$CMD")
228 CMD="$CMD | $after"
229 CMD=$(gen_cmd_aux "$(substring "$LAYOUT" "$(( index + 1 ))" "$(( ${#LAYOUT} - index ))")" "$CMD")
230 echo "$CMD"
231 return
232 fi
233
234
235 # Step 4:
236 #
237 # If we reach this point, it means there are no separators and we just
238 # need to print the command to display the specified buffer
239
240 target=$(substring "$LAYOUT" "$start" "$(( end - start ))" | sed 's:[ @();|-]::g')
241
242 if test "$target" = "LOCAL"
243 then
244 CMD="$CMD | 1b"
245
246 elif test "$target" = "BASE"
247 then
248 CMD="$CMD | 2b"
249
250 elif test "$target" = "REMOTE"
251 then
252 CMD="$CMD | 3b"
253
254 elif test "$target" = "MERGED"
255 then
256 CMD="$CMD | 4b"
257
258 else
259 CMD="$CMD | ERROR: >$target<"
260 fi
261
262 echo "$CMD"
263 return
264}
265
266
267gen_cmd () {
268 # This function returns (in global variable FINAL_CMD) the string that
269 # you can use when invoking "vim" (as shown next) to obtain a given
270 # layout:
271 #
272 # $ vim -f $FINAL_CMD "$LOCAL" "$BASE" "$REMOTE" "$MERGED"
273 #
274 # It takes one single argument: a string containing the desired layout
275 # definition.
276 #
277 # The syntax of the "layout definitions" is explained in "Documentation/
278 # mergetools/vimdiff.txt" but you can already intuitively understand how
279 # it works by knowing that...
280 #
281 # * "+" means "a new vim tab"
282 # * "/" means "a new vim horizontal split"
283 # * "," means "a new vim vertical split"
284 #
285 # It also returns (in global variable FINAL_TARGET) the name ("LOCAL",
286 # "BASE", "REMOTE" or "MERGED") of the file that is marked with an "@",
287 # or "MERGED" if none of them is.
288 #
289 # Example:
290 #
291 # gen_cmd "@LOCAL , REMOTE"
292 # |
f3d7623a 293 # `-> FINAL_CMD == "-c \"echo | leftabove vertical split | 1b | wincmd l | 3b | tabdo windo diffthis\" -c \"tabfirst\""
00417974
FR
294 # FINAL_TARGET == "LOCAL"
295
296 LAYOUT=$1
297
298
299 # Search for a "@" in one of the files identifiers ("LOCAL", "BASE",
300 # "REMOTE", "MERGED"). If not found, use "MERGE" as the default file
301 # where changes will be saved.
302
303 if echo "$LAYOUT" | grep @LOCAL >/dev/null
304 then
305 FINAL_TARGET="LOCAL"
306 elif echo "$LAYOUT" | grep @BASE >/dev/null
307 then
308 FINAL_TARGET="BASE"
309 else
310 FINAL_TARGET="MERGED"
311 fi
312
313
314 # Obtain the first part of vim "-c" option to obtain the desired layout
315
ffcc33f6
FC
316 CMD=
317 oldIFS=$IFS
318 IFS=+
319 for tab in $LAYOUT
320 do
321 if test -z "$CMD"
322 then
323 CMD="echo" # vim "nop" operator
324 else
325 CMD="$CMD | tabnew"
326 fi
327
b6014eea
FC
328 # If this is a single window diff with all the buffers
329 if ! echo "$tab" | grep ",\|/" >/dev/null
330 then
331 CMD="$CMD | silent execute 'bufdo diffthis'"
332 fi
333
ffcc33f6
FC
334 CMD=$(gen_cmd_aux "$tab" "$CMD")
335 done
336 IFS=$oldIFS
00417974 337
b6014eea 338 CMD="$CMD | tabdo windo diffthis"
00417974
FR
339
340 # Add an extra "-c" option to move to the first tab (notice that we
341 # can't simply append the command to the previous "-c" string as
342 # explained here: https://github.com/vim/vim/issues/9076
343
60184ab4 344 FINAL_CMD="-c \"set hidden diffopt-=hiddenoff | $CMD\" -c \"tabfirst\""
00417974
FR
345}
346
347
348################################################################################
349## API functions (called from "git-mergetool--lib.sh")
350################################################################################
351
bc7a96a8 352diff_cmd () {
b2a6b712
DA
353 "$merge_tool_path" -R -f -d \
354 -c 'wincmd l' -c 'cd $GIT_PREFIX' "$LOCAL" "$REMOTE"
bc7a96a8
DA
355}
356
00417974 357
7b5cf8be
FR
358diff_cmd_help () {
359 TOOL=$1
360
361 case "$TOOL" in
362 nvimdiff*)
363 printf "Use Neovim"
364 ;;
365 gvimdiff*)
366 printf "Use gVim (requires a graphical session)"
367 ;;
368 vimdiff*)
369 printf "Use Vim"
370 ;;
371 esac
372
373 return 0
374}
375
376
bc7a96a8 377merge_cmd () {
00417974
FR
378 layout=$(git config mergetool.vimdiff.layout)
379
bc7a96a8 380 case "$1" in
11868978 381 *vimdiff)
00417974 382 if test -z "$layout"
bc7a96a8 383 then
00417974
FR
384 # Default layout when none is specified
385 layout="(LOCAL,BASE,REMOTE)/MERGED"
bc7a96a8
DA
386 fi
387 ;;
30bb8088 388 *vimdiff1)
00417974 389 layout="@LOCAL,REMOTE"
30bb8088 390 ;;
11868978 391 *vimdiff2)
00417974 392 layout="LOCAL,MERGED,REMOTE"
bc7a96a8 393 ;;
11868978 394 *vimdiff3)
00417974 395 layout="MERGED"
7c147b77 396 ;;
bc7a96a8 397 esac
00417974
FR
398
399 gen_cmd "$layout"
400
401 debug_print ""
402 debug_print "FINAL CMD : $FINAL_CMD"
403 debug_print "FINAL TAR : $FINAL_TARGET"
404
405 if $base_present
406 then
ccc7b514
JS
407 eval '"$merge_tool_path"' \
408 -f "$FINAL_CMD" '"$LOCAL"' '"$BASE"' '"$REMOTE"' '"$MERGED"'
00417974
FR
409 else
410 # If there is no BASE (example: a merge conflict in a new file
411 # with the same name created in both braches which didn't exist
412 # before), close all BASE windows using vim's "quit" command
413
414 FINAL_CMD=$(echo "$FINAL_CMD" | \
415 sed -e 's:2b:quit:g' -e 's:3b:2b:g' -e 's:4b:3b:g')
416
ccc7b514
JS
417 eval '"$merge_tool_path"' \
418 -f "$FINAL_CMD" '"$LOCAL"' '"$REMOTE"' '"$MERGED"'
00417974
FR
419 fi
420
421 ret="$?"
422
423 if test "$ret" -eq 0
424 then
425 case "$FINAL_TARGET" in
426 LOCAL)
427 source_path="$LOCAL"
428 ;;
429 REMOTE)
430 source_path="$REMOTE"
431 ;;
432 MERGED|*)
433 # Do nothing
434 source_path=
435 ;;
436 esac
437
438 if test -n "$source_path"
439 then
440 cp "$source_path" "$MERGED"
441 fi
442 fi
443
444 return "$ret"
bc7a96a8
DA
445}
446
00417974 447
7b5cf8be
FR
448merge_cmd_help () {
449 TOOL=$1
450
451 case "$TOOL" in
452 nvimdiff*)
453 printf "Use Neovim "
454 ;;
455 gvimdiff*)
456 printf "Use gVim (requires a graphical session) "
457 ;;
458 vimdiff*)
459 printf "Use Vim "
460 ;;
461 esac
462
463 case "$TOOL" in
464 *1)
465 echo "with a 2 panes layout (LOCAL and REMOTE)"
466 ;;
467 *2)
468 echo "with a 3 panes layout (LOCAL, MERGED and REMOTE)"
469 ;;
470 *3)
471 echo "where only the MERGED file is shown"
472 ;;
473 *)
474 echo "with a custom layout (see \`git help mergetool\`'s \`BACKEND SPECIFIC HINTS\` section)"
475 ;;
476 esac
477
478 return 0
479}
480
481
00417974 482translate_merge_tool_path () {
bc7a96a8 483 case "$1" in
11868978 484 nvimdiff*)
485 echo nvim
486 ;;
487 gvimdiff*)
bc7a96a8
DA
488 echo gvim
489 ;;
11868978 490 vimdiff*)
bc7a96a8
DA
491 echo vim
492 ;;
493 esac
494}
29672844 495
00417974 496
29672844
DA
497exit_code_trustable () {
498 true
499}
83bbf9b9 500
00417974 501
83bbf9b9 502list_tool_variants () {
00417974
FR
503 if test "$TOOL_MODE" = "diff"
504 then
505 for prefix in '' g n
506 do
507 echo "${prefix}vimdiff"
83bbf9b9 508 done
00417974
FR
509 else
510 for prefix in '' g n
511 do
512 for suffix in '' 1 2 3
513 do
514 echo "${prefix}vimdiff${suffix}"
515 done
516 done
517 fi
518}
519
520
521################################################################################
522## Unit tests (called from scripts inside the "t" folder)
523################################################################################
524
525run_unit_tests () {
526 # Function to make sure that we don't break anything when modifying this
527 # script.
528
529 NUMBER_OF_TEST_CASES=16
530
531 TEST_CASE_01="(LOCAL,BASE,REMOTE)/MERGED" # default behaviour
532 TEST_CASE_02="@LOCAL,REMOTE" # when using vimdiff1
533 TEST_CASE_03="LOCAL,MERGED,REMOTE" # when using vimdiff2
534 TEST_CASE_04="MERGED" # when using vimdiff3
535 TEST_CASE_05="LOCAL/MERGED/REMOTE"
536 TEST_CASE_06="(LOCAL/REMOTE),MERGED"
537 TEST_CASE_07="MERGED,(LOCAL/REMOTE)"
538 TEST_CASE_08="(LOCAL,REMOTE)/MERGED"
539 TEST_CASE_09="MERGED/(LOCAL,REMOTE)"
540 TEST_CASE_10="(LOCAL/BASE/REMOTE),MERGED"
541 TEST_CASE_11="(LOCAL,BASE,REMOTE)/MERGED+BASE,LOCAL+BASE,REMOTE+(LOCAL/BASE/REMOTE),MERGED"
542 TEST_CASE_12="((LOCAL,REMOTE)/BASE),MERGED"
543 TEST_CASE_13="((LOCAL,REMOTE)/BASE),((LOCAL/REMOTE),MERGED)"
544 TEST_CASE_14="BASE,REMOTE+BASE,LOCAL"
545 TEST_CASE_15=" (( (LOCAL , BASE , REMOTE) / MERGED)) +(BASE) , LOCAL+ BASE , REMOTE+ (((LOCAL / BASE / REMOTE)) , MERGED ) "
546 TEST_CASE_16="LOCAL,BASE,REMOTE / MERGED + BASE,LOCAL + BASE,REMOTE + (LOCAL / BASE / REMOTE),MERGED"
547
60184ab4
FC
548 EXPECTED_CMD_01="-c \"set hidden diffopt-=hiddenoff | echo | leftabove split | leftabove vertical split | 1b | wincmd l | leftabove vertical split | 2b | wincmd l | 3b | wincmd j | 4b | tabdo windo diffthis\" -c \"tabfirst\""
549 EXPECTED_CMD_02="-c \"set hidden diffopt-=hiddenoff | echo | leftabove vertical split | 1b | wincmd l | 3b | tabdo windo diffthis\" -c \"tabfirst\""
550 EXPECTED_CMD_03="-c \"set hidden diffopt-=hiddenoff | echo | leftabove vertical split | 1b | wincmd l | leftabove vertical split | 4b | wincmd l | 3b | tabdo windo diffthis\" -c \"tabfirst\""
b6014eea 551 EXPECTED_CMD_04="-c \"set hidden diffopt-=hiddenoff | echo | silent execute 'bufdo diffthis' | 4b | tabdo windo diffthis\" -c \"tabfirst\""
60184ab4
FC
552 EXPECTED_CMD_05="-c \"set hidden diffopt-=hiddenoff | echo | leftabove split | 1b | wincmd j | leftabove split | 4b | wincmd j | 3b | tabdo windo diffthis\" -c \"tabfirst\""
553 EXPECTED_CMD_06="-c \"set hidden diffopt-=hiddenoff | echo | leftabove vertical split | leftabove split | 1b | wincmd j | 3b | wincmd l | 4b | tabdo windo diffthis\" -c \"tabfirst\""
554 EXPECTED_CMD_07="-c \"set hidden diffopt-=hiddenoff | echo | leftabove vertical split | 4b | wincmd l | leftabove split | 1b | wincmd j | 3b | tabdo windo diffthis\" -c \"tabfirst\""
555 EXPECTED_CMD_08="-c \"set hidden diffopt-=hiddenoff | echo | leftabove split | leftabove vertical split | 1b | wincmd l | 3b | wincmd j | 4b | tabdo windo diffthis\" -c \"tabfirst\""
556 EXPECTED_CMD_09="-c \"set hidden diffopt-=hiddenoff | echo | leftabove split | 4b | wincmd j | leftabove vertical split | 1b | wincmd l | 3b | tabdo windo diffthis\" -c \"tabfirst\""
557 EXPECTED_CMD_10="-c \"set hidden diffopt-=hiddenoff | echo | leftabove vertical split | leftabove split | 1b | wincmd j | leftabove split | 2b | wincmd j | 3b | wincmd l | 4b | tabdo windo diffthis\" -c \"tabfirst\""
ffcc33f6 558 EXPECTED_CMD_11="-c \"set hidden diffopt-=hiddenoff | echo | leftabove split | leftabove vertical split | 1b | wincmd l | leftabove vertical split | 2b | wincmd l | 3b | wincmd j | 4b | tabnew | leftabove vertical split | 2b | wincmd l | 1b | tabnew | leftabove vertical split | 2b | wincmd l | 3b | tabnew | leftabove vertical split | leftabove split | 1b | wincmd j | leftabove split | 2b | wincmd j | 3b | wincmd l | 4b | tabdo windo diffthis\" -c \"tabfirst\""
60184ab4
FC
559 EXPECTED_CMD_12="-c \"set hidden diffopt-=hiddenoff | echo | leftabove vertical split | leftabove split | leftabove vertical split | 1b | wincmd l | 3b | wincmd j | 2b | wincmd l | 4b | tabdo windo diffthis\" -c \"tabfirst\""
560 EXPECTED_CMD_13="-c \"set hidden diffopt-=hiddenoff | echo | leftabove vertical split | leftabove split | leftabove vertical split | 1b | wincmd l | 3b | wincmd j | 2b | wincmd l | leftabove vertical split | leftabove split | 1b | wincmd j | 3b | wincmd l | 4b | tabdo windo diffthis\" -c \"tabfirst\""
ffcc33f6
FC
561 EXPECTED_CMD_14="-c \"set hidden diffopt-=hiddenoff | echo | leftabove vertical split | 2b | wincmd l | 3b | tabnew | leftabove vertical split | 2b | wincmd l | 1b | tabdo windo diffthis\" -c \"tabfirst\""
562 EXPECTED_CMD_15="-c \"set hidden diffopt-=hiddenoff | echo | leftabove split | leftabove vertical split | 1b | wincmd l | leftabove vertical split | 2b | wincmd l | 3b | wincmd j | 4b | tabnew | leftabove vertical split | 2b | wincmd l | 1b | tabnew | leftabove vertical split | 2b | wincmd l | 3b | tabnew | leftabove vertical split | leftabove split | 1b | wincmd j | leftabove split | 2b | wincmd j | 3b | wincmd l | 4b | tabdo windo diffthis\" -c \"tabfirst\""
563 EXPECTED_CMD_16="-c \"set hidden diffopt-=hiddenoff | echo | leftabove split | leftabove vertical split | 1b | wincmd l | leftabove vertical split | 2b | wincmd l | 3b | wincmd j | 4b | tabnew | leftabove vertical split | 2b | wincmd l | 1b | tabnew | leftabove vertical split | 2b | wincmd l | 3b | tabnew | leftabove vertical split | leftabove split | 1b | wincmd j | leftabove split | 2b | wincmd j | 3b | wincmd l | 4b | tabdo windo diffthis\" -c \"tabfirst\""
00417974
FR
564
565 EXPECTED_TARGET_01="MERGED"
566 EXPECTED_TARGET_02="LOCAL"
567 EXPECTED_TARGET_03="MERGED"
568 EXPECTED_TARGET_04="MERGED"
569 EXPECTED_TARGET_05="MERGED"
570 EXPECTED_TARGET_06="MERGED"
571 EXPECTED_TARGET_07="MERGED"
572 EXPECTED_TARGET_08="MERGED"
573 EXPECTED_TARGET_09="MERGED"
574 EXPECTED_TARGET_10="MERGED"
575 EXPECTED_TARGET_11="MERGED"
576 EXPECTED_TARGET_12="MERGED"
577 EXPECTED_TARGET_13="MERGED"
578 EXPECTED_TARGET_14="MERGED"
579 EXPECTED_TARGET_15="MERGED"
580 EXPECTED_TARGET_16="MERGED"
581
582 at_least_one_ko="false"
583
584 for i in $(seq -w 1 99)
585 do
586 if test "$i" -gt $NUMBER_OF_TEST_CASES
587 then
588 break
589 fi
590
591 gen_cmd "$(eval echo \${TEST_CASE_"$i"})"
592
593 if test "$FINAL_CMD" = "$(eval echo \${EXPECTED_CMD_"$i"})" \
594 && test "$FINAL_TARGET" = "$(eval echo \${EXPECTED_TARGET_"$i"})"
595 then
596 printf "Test Case #%02d: OK\n" "$(echo "$i" | sed 's/^0*//')"
597 else
598 printf "Test Case #%02d: KO !!!!\n" "$(echo "$i" | sed 's/^0*//')"
599 echo " FINAL_CMD : $FINAL_CMD"
600 echo " FINAL_CMD (expected) : $(eval echo \${EXPECTED_CMD_"$i"})"
601 echo " FINAL_TARGET : $FINAL_TARGET"
602 echo " FINAL_TARGET (expected): $(eval echo \${EXPECTED_TARGET_"$i"})"
603 at_least_one_ko="true"
604 fi
83bbf9b9 605 done
00417974 606
ccc7b514
JS
607 # verify that `merge_cmd` handles paths with spaces
608 record_parameters () {
609 >actual
610 for arg
611 do
612 echo "$arg" >>actual
613 done
614 }
615
616 base_present=false
617 LOCAL='lo cal'
618 BASE='ba se'
619 REMOTE="' '"
620 MERGED='mer ged'
621 merge_tool_path=record_parameters
622
623 merge_cmd vimdiff || at_least_one_ko=true
624
625 cat >expect <<-\EOF
626 -f
627 -c
60184ab4 628 set hidden diffopt-=hiddenoff | echo | leftabove split | leftabove vertical split | 1b | wincmd l | leftabove vertical split | quit | wincmd l | 2b | wincmd j | 3b | tabdo windo diffthis
ccc7b514
JS
629 -c
630 tabfirst
631 lo cal
632 ' '
633 mer ged
634 EOF
635
636 diff -u expect actual || at_least_one_ko=true
637
00417974
FR
638 if test "$at_least_one_ko" = "true"
639 then
640 return 255
641 else
642 return 0
643 fi
83bbf9b9 644}