summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Contreras <felipe.contreras@gmail.com>2022-08-10 15:46:17 (GMT)
committerJunio C Hamano <gitster@pobox.com>2022-08-10 19:39:35 (GMT)
commitb6014eeac0963ccad3f769fc6cdd09a4a64f478d (patch)
tree3be147341bcb7c8791ab0cf2862dc404366e8d8e
parentffcc33f6a6923ade435a65d6cba751b3b95e6fd8 (diff)
downloadgit-b6014eeac0963ccad3f769fc6cdd09a4a64f478d.zip
git-b6014eeac0963ccad3f769fc6cdd09a4a64f478d.tar.gz
git-b6014eeac0963ccad3f769fc6cdd09a4a64f478d.tar.bz2
mergetools: vimdiff: fix single window layouts
Layouts with a single window other than "MERGED" do not work (e.g. "LOCAL" or "MERGED+LOCAL"). This is because as the documentation of bufdo says: The last buffer (or where an error occurred) becomes the current buffer. And we do always do bufdo the end. Additionally, we do it only once, when it should be per tab. Fix this by doing it once per tab right after it's created and before any buffer is switched. Cc: Fernando Ramos <greenfoo@u92.eu> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Reviewed-by: Fernando Ramos <greenfoo@u92.eu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--mergetools/vimdiff20
1 files changed, 8 insertions, 12 deletions
diff --git a/mergetools/vimdiff b/mergetools/vimdiff
index 8334871..e27734b 100644
--- a/mergetools/vimdiff
+++ b/mergetools/vimdiff
@@ -325,21 +325,17 @@ gen_cmd () {
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
+
CMD=$(gen_cmd_aux "$tab" "$CMD")
done
IFS=$oldIFS
-
- # Adjust the just obtained script depending on whether more than one
- # windows are visible or not
-
- if echo "$LAYOUT" | grep ",\|/" >/dev/null
- then
- CMD="$CMD | tabdo windo diffthis"
- else
- CMD="$CMD | silent bufdo diffthis"
- fi
-
+ CMD="$CMD | 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
@@ -552,7 +548,7 @@ run_unit_tests () {
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\""
EXPECTED_CMD_02="-c \"set hidden diffopt-=hiddenoff | echo | leftabove vertical split | 1b | wincmd l | 3b | tabdo windo diffthis\" -c \"tabfirst\""
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\""
- EXPECTED_CMD_04="-c \"set hidden diffopt-=hiddenoff | echo | 4b | silent bufdo diffthis\" -c \"tabfirst\""
+ EXPECTED_CMD_04="-c \"set hidden diffopt-=hiddenoff | echo | silent execute 'bufdo diffthis' | 4b | tabdo windo diffthis\" -c \"tabfirst\""
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\""
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\""
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\""