зеркало из https://github.com/microsoft/git.git
Merge branch 'fc/vimdiff-layout-vimdiff3-fix' into maint
"vimdiff3" regression fix. source: <20220810154618.307275-1-felipe.contreras@gmail.com> * fc/vimdiff-layout-vimdiff3-fix: mergetools: vimdiff: simplify tabfirst mergetools: vimdiff: fix single window layouts mergetools: vimdiff: rework tab logic mergetools: vimdiff: fix for diffopt mergetools: vimdiff: silence annoying messages mergetools: vimdiff: make vimdiff3 actually work mergetools: vimdiff: fix comment
This commit is contained in:
Коммит
222f953777
|
@ -29,8 +29,8 @@
|
|||
################################################################################
|
||||
|
||||
debug_print () {
|
||||
# Send message to stderr if global variable GIT_MERGETOOL_VIMDIFF is set
|
||||
# to "true"
|
||||
# Send message to stderr if global variable GIT_MERGETOOL_VIMDIFF_DEBUG
|
||||
# is set.
|
||||
|
||||
if test -n "$GIT_MERGETOOL_VIMDIFF_DEBUG"
|
||||
then
|
||||
|
@ -66,11 +66,6 @@ gen_cmd_aux () {
|
|||
debug_print "LAYOUT : $LAYOUT"
|
||||
debug_print "CMD : $CMD"
|
||||
|
||||
if test -z "$CMD"
|
||||
then
|
||||
CMD="echo" # vim "nop" operator
|
||||
fi
|
||||
|
||||
start=0
|
||||
end=${#LAYOUT}
|
||||
|
||||
|
@ -144,11 +139,10 @@ gen_cmd_aux () {
|
|||
|
||||
# Step 2:
|
||||
#
|
||||
# Search for all valid separators ("+", "/" or ",") which are *not*
|
||||
# Search for all valid separators ("/" or ",") which are *not*
|
||||
# inside parenthesis. Save the index at which each of them makes the
|
||||
# first appearance.
|
||||
|
||||
index_new_tab=""
|
||||
index_horizontal_split=""
|
||||
index_vertical_split=""
|
||||
|
||||
|
@ -182,14 +176,7 @@ gen_cmd_aux () {
|
|||
then
|
||||
current=$c
|
||||
|
||||
if test "$current" = "+"
|
||||
then
|
||||
if test -z "$index_new_tab"
|
||||
then
|
||||
index_new_tab=$i
|
||||
fi
|
||||
|
||||
elif test "$current" = "/"
|
||||
if test "$current" = "/"
|
||||
then
|
||||
if test -z "$index_horizontal_split"
|
||||
then
|
||||
|
@ -219,14 +206,7 @@ gen_cmd_aux () {
|
|||
|
||||
terminate="false"
|
||||
|
||||
if ! test -z "$index_new_tab"
|
||||
then
|
||||
before="-tabnew"
|
||||
after="tabnext"
|
||||
index=$index_new_tab
|
||||
terminate="true"
|
||||
|
||||
elif ! test -z "$index_horizontal_split"
|
||||
if ! test -z "$index_horizontal_split"
|
||||
then
|
||||
before="leftabove split"
|
||||
after="wincmd j"
|
||||
|
@ -333,25 +313,31 @@ gen_cmd () {
|
|||
|
||||
# Obtain the first part of vim "-c" option to obtain the desired layout
|
||||
|
||||
CMD=$(gen_cmd_aux "$LAYOUT")
|
||||
CMD=
|
||||
oldIFS=$IFS
|
||||
IFS=+
|
||||
for tab in $LAYOUT
|
||||
do
|
||||
if test -z "$CMD"
|
||||
then
|
||||
CMD="echo" # vim "nop" operator
|
||||
else
|
||||
CMD="$CMD | tabnew"
|
||||
fi
|
||||
|
||||
# If this is a single window diff with all the buffers
|
||||
if ! echo "$tab" | grep ",\|/" >/dev/null
|
||||
then
|
||||
CMD="$CMD | silent execute 'bufdo diffthis'"
|
||||
fi
|
||||
|
||||
# Adjust the just obtained script depending on whether more than one
|
||||
# windows are visible or not
|
||||
CMD=$(gen_cmd_aux "$tab" "$CMD")
|
||||
done
|
||||
IFS=$oldIFS
|
||||
|
||||
if echo "$LAYOUT" | grep ",\|/" >/dev/null
|
||||
then
|
||||
CMD="$CMD | tabdo windo diffthis"
|
||||
else
|
||||
CMD="$CMD | bufdo diffthis"
|
||||
fi
|
||||
CMD="$CMD | execute 'tabdo windo diffthis'"
|
||||
|
||||
|
||||
# Add an extra "-c" option to move to the first tab (notice that we
|
||||
# can't simply append the command to the previous "-c" string as
|
||||
# explained here: https://github.com/vim/vim/issues/9076
|
||||
|
||||
FINAL_CMD="-c \"$CMD\" -c \"tabfirst\""
|
||||
FINAL_CMD="-c \"set hidden diffopt-=hiddenoff | $CMD | tabfirst\""
|
||||
}
|
||||
|
||||
|
||||
|
@ -555,22 +541,22 @@ run_unit_tests () {
|
|||
TEST_CASE_15=" (( (LOCAL , BASE , REMOTE) / MERGED)) +(BASE) , LOCAL+ BASE , REMOTE+ (((LOCAL / BASE / REMOTE)) , MERGED ) "
|
||||
TEST_CASE_16="LOCAL,BASE,REMOTE / MERGED + BASE,LOCAL + BASE,REMOTE + (LOCAL / BASE / REMOTE),MERGED"
|
||||
|
||||
EXPECTED_CMD_01="-c \"echo | leftabove split | leftabove vertical split | 1b | wincmd l | leftabove vertical split | 2b | wincmd l | 3b | wincmd j | 4b | tabdo windo diffthis\" -c \"tabfirst\""
|
||||
EXPECTED_CMD_02="-c \"echo | leftabove vertical split | 1b | wincmd l | 3b | tabdo windo diffthis\" -c \"tabfirst\""
|
||||
EXPECTED_CMD_03="-c \"echo | leftabove vertical split | 1b | wincmd l | leftabove vertical split | 4b | wincmd l | 3b | tabdo windo diffthis\" -c \"tabfirst\""
|
||||
EXPECTED_CMD_04="-c \"echo | 4b | bufdo diffthis\" -c \"tabfirst\""
|
||||
EXPECTED_CMD_05="-c \"echo | leftabove split | 1b | wincmd j | leftabove split | 4b | wincmd j | 3b | tabdo windo diffthis\" -c \"tabfirst\""
|
||||
EXPECTED_CMD_06="-c \"echo | leftabove vertical split | leftabove split | 1b | wincmd j | 3b | wincmd l | 4b | tabdo windo diffthis\" -c \"tabfirst\""
|
||||
EXPECTED_CMD_07="-c \"echo | leftabove vertical split | 4b | wincmd l | leftabove split | 1b | wincmd j | 3b | tabdo windo diffthis\" -c \"tabfirst\""
|
||||
EXPECTED_CMD_08="-c \"echo | leftabove split | leftabove vertical split | 1b | wincmd l | 3b | wincmd j | 4b | tabdo windo diffthis\" -c \"tabfirst\""
|
||||
EXPECTED_CMD_09="-c \"echo | leftabove split | 4b | wincmd j | leftabove vertical split | 1b | wincmd l | 3b | tabdo windo diffthis\" -c \"tabfirst\""
|
||||
EXPECTED_CMD_10="-c \"echo | leftabove vertical split | leftabove split | 1b | wincmd j | leftabove split | 2b | wincmd j | 3b | wincmd l | 4b | tabdo windo diffthis\" -c \"tabfirst\""
|
||||
EXPECTED_CMD_11="-c \"echo | -tabnew | leftabove split | leftabove vertical split | 1b | wincmd l | leftabove vertical split | 2b | wincmd l | 3b | wincmd j | 4b | tabnext | -tabnew | leftabove vertical split | 2b | wincmd l | 1b | tabnext | -tabnew | leftabove vertical split | 2b | wincmd l | 3b | tabnext | leftabove vertical split | leftabove split | 1b | wincmd j | leftabove split | 2b | wincmd j | 3b | wincmd l | 4b | tabdo windo diffthis\" -c \"tabfirst\""
|
||||
EXPECTED_CMD_12="-c \"echo | leftabove vertical split | leftabove split | leftabove vertical split | 1b | wincmd l | 3b | wincmd j | 2b | wincmd l | 4b | tabdo windo diffthis\" -c \"tabfirst\""
|
||||
EXPECTED_CMD_13="-c \"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\""
|
||||
EXPECTED_CMD_14="-c \"echo | -tabnew | leftabove vertical split | 2b | wincmd l | 3b | tabnext | leftabove vertical split | 2b | wincmd l | 1b | tabdo windo diffthis\" -c \"tabfirst\""
|
||||
EXPECTED_CMD_15="-c \"echo | -tabnew | leftabove split | leftabove vertical split | 1b | wincmd l | leftabove vertical split | 2b | wincmd l | 3b | wincmd j | 4b | tabnext | -tabnew | leftabove vertical split | 2b | wincmd l | 1b | tabnext | -tabnew | leftabove vertical split | 2b | wincmd l | 3b | tabnext | leftabove vertical split | leftabove split | 1b | wincmd j | leftabove split | 2b | wincmd j | 3b | wincmd l | 4b | tabdo windo diffthis\" -c \"tabfirst\""
|
||||
EXPECTED_CMD_16="-c \"echo | -tabnew | leftabove split | leftabove vertical split | 1b | wincmd l | leftabove vertical split | 2b | wincmd l | 3b | wincmd j | 4b | tabnext | -tabnew | leftabove vertical split | 2b | wincmd l | 1b | tabnext | -tabnew | leftabove vertical split | 2b | wincmd l | 3b | tabnext | leftabove vertical split | leftabove split | 1b | wincmd j | leftabove split | 2b | wincmd j | 3b | wincmd l | 4b | tabdo windo diffthis\" -c \"tabfirst\""
|
||||
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 | execute 'tabdo windo diffthis' | tabfirst\""
|
||||
EXPECTED_CMD_02="-c \"set hidden diffopt-=hiddenoff | echo | leftabove vertical split | 1b | wincmd l | 3b | execute 'tabdo windo diffthis' | tabfirst\""
|
||||
EXPECTED_CMD_03="-c \"set hidden diffopt-=hiddenoff | echo | leftabove vertical split | 1b | wincmd l | leftabove vertical split | 4b | wincmd l | 3b | execute 'tabdo windo diffthis' | tabfirst\""
|
||||
EXPECTED_CMD_04="-c \"set hidden diffopt-=hiddenoff | echo | silent execute 'bufdo diffthis' | 4b | execute 'tabdo windo diffthis' | tabfirst\""
|
||||
EXPECTED_CMD_05="-c \"set hidden diffopt-=hiddenoff | echo | leftabove split | 1b | wincmd j | leftabove split | 4b | wincmd j | 3b | execute 'tabdo windo diffthis' | tabfirst\""
|
||||
EXPECTED_CMD_06="-c \"set hidden diffopt-=hiddenoff | echo | leftabove vertical split | leftabove split | 1b | wincmd j | 3b | wincmd l | 4b | execute 'tabdo windo diffthis' | tabfirst\""
|
||||
EXPECTED_CMD_07="-c \"set hidden diffopt-=hiddenoff | echo | leftabove vertical split | 4b | wincmd l | leftabove split | 1b | wincmd j | 3b | execute 'tabdo windo diffthis' | tabfirst\""
|
||||
EXPECTED_CMD_08="-c \"set hidden diffopt-=hiddenoff | echo | leftabove split | leftabove vertical split | 1b | wincmd l | 3b | wincmd j | 4b | execute 'tabdo windo diffthis' | tabfirst\""
|
||||
EXPECTED_CMD_09="-c \"set hidden diffopt-=hiddenoff | echo | leftabove split | 4b | wincmd j | leftabove vertical split | 1b | wincmd l | 3b | execute 'tabdo windo diffthis' | tabfirst\""
|
||||
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 | execute 'tabdo windo diffthis' | tabfirst\""
|
||||
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 | execute 'tabdo windo diffthis' | tabfirst\""
|
||||
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 | execute 'tabdo windo diffthis' | tabfirst\""
|
||||
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 | execute 'tabdo windo diffthis' | tabfirst\""
|
||||
EXPECTED_CMD_14="-c \"set hidden diffopt-=hiddenoff | echo | leftabove vertical split | 2b | wincmd l | 3b | tabnew | leftabove vertical split | 2b | wincmd l | 1b | execute 'tabdo windo diffthis' | tabfirst\""
|
||||
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 | execute 'tabdo windo diffthis' | tabfirst\""
|
||||
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 | execute 'tabdo windo diffthis' | tabfirst\""
|
||||
|
||||
EXPECTED_TARGET_01="MERGED"
|
||||
EXPECTED_TARGET_02="LOCAL"
|
||||
|
@ -635,9 +621,7 @@ run_unit_tests () {
|
|||
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
|
||||
set hidden diffopt-=hiddenoff | echo | leftabove split | leftabove vertical split | 1b | wincmd l | leftabove vertical split | quit | wincmd l | 2b | wincmd j | 3b | execute 'tabdo windo diffthis' | tabfirst
|
||||
lo cal
|
||||
' '
|
||||
mer ged
|
||||
|
|
Загрузка…
Ссылка в новой задаче