Re: mergetool.vimdiff.layout behavior differs from documentation
From: D. Ben Knoble <hidden>
Date: 2025-03-24 20:35:41
On Mon, Mar 24, 2025 at 10:54 AM kawarimidoll [off-list ref] wrote:
Hello, This is my first time reporting an issue with Git. I am not a native English speaker, so I apologize if there are any translation mistakes. Below is my response to `git bugreport`:quoted
What did you do before the bug happened? (Steps to reproduce your issue)1. I checked the `git mergetool --help` documentation and configured `$ git config --global mergetool.vimdiff.layout "@REMOTE"`. 2. In a repository with merge conflicts, I opened vimdiff using `git mergetool`, updated the REMOTE buffer, and saved the changes.quoted
What did you expect to happen? (Expected behavior)I expected the changes made to the REMOTE buffer to be reflected in the file.quoted
What happened instead? (Actual behavior)The changes made to the REMOTE buffer were **not** reflected in the file.quoted
What’s different between what you expected and what actually happened?The documentation states: ”@ is used to indicate the file containing the final version after solving the conflicts. If not present, MERGED will be used by default.” So I thought that the changes made to the REMOTE buffer will be reflected in the file if I use @REMOTE. However, in my tests, @LOCAL and @MERGED worked as expected, but @BASE and @REMOTE did not behave correctly.
Interesting; I haven't tried to reproduce this, but the docs appear to
(vaguely) indicate that this is the case.
I've CC'd the author of most of that mergetool for some help, but the
issue is likely here (lines 298–310 of the script mergetools/vimdiff
on 683c54c999 (Git 2.49, 2025-03-14)):
# Search for a "@" in one of the files identifiers ("LOCAL", "BASE",
# "REMOTE", "MERGED"). If not found, use "MERGE" as the default file
# where changes will be saved.
if echo "$LAYOUT" | grep @LOCAL >/dev/null
then
FINAL_TARGET="LOCAL"
elif echo "$LAYOUT" | grep @BASE >/dev/null
then
FINAL_TARGET="BASE"
else
FINAL_TARGET="MERGED"
fi
(Apologies that my mail client appears to strip leading indentation on
paste, ugh)
A GitHub link, for those who prefer it:
https://github.com/git/git/blob/683c54c999c301c2cd6f715c411407c413b1d84e/mergetools/vimdiff#L298-L310
That code goes back to 0041797449 (vimdiff: new implementation with
layout support, 2022-03-30), whose author is also CC'd.
--
D. Ben Knoble