{"thread":{"id":"63185","subject":"mergetool.vimdiff.layout behavior differs from documentation","startedAt":"2025-03-24T14:52:54Z","lastAt":"2025-03-24T22:52:49Z","messageCount":3,"participants":["kawarimidoll","D. Ben Knoble","Fernando Ramos"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"514932","messageId":"CAC6paJg19ue7W0VxTnGH-1ra3Zkk+pRnj6McEC755RD54xDzCA@mail.gmail.com","threadId":"63185","inReplyTo":null,"subject":"mergetool.vimdiff.layout behavior differs from documentation","fromName":"kawarimidoll","fromEmail":"kawarimidoll+git@gmail.com","sentAt":"2025-03-24T14:52:40Z","receivedAt":"2025-03-24T14:52:54Z","isPatch":false,"sender":{"key":"kawarimidoll+git@gmail.com","avatar":null},"body":"Hello,\n\nThis is my first time reporting an issue with Git. I am not a native\nEnglish speaker, so I apologize if there are any translation mistakes.\n\nBelow is my response to `git bugreport`:\n\n> What did you do before the bug happened? (Steps to reproduce your issue)\n1. I checked the `git mergetool --help` documentation and configured\n`$ git config --global mergetool.vimdiff.layout \"@REMOTE\"`.\n2. In a repository with merge conflicts, I opened vimdiff using `git\nmergetool`, updated the REMOTE buffer, and saved the changes.\n\n> What did you expect to happen? (Expected behavior)\nI expected the changes made to the REMOTE buffer to be reflected in the file.\n\n> What happened instead? (Actual behavior)\nThe changes made to the REMOTE buffer were **not** reflected in the file.\n\n> What’s different between what you expected and what actually happened?\nThe documentation states:\n”@ is used to indicate the file containing the final version after\nsolving the conflicts. If not present, MERGED will be used by\ndefault.”\nSo I thought that the changes made to the REMOTE buffer will be\nreflected in the file if I use @REMOTE.\nHowever, in my tests, @LOCAL and @MERGED worked as expected, but @BASE\nand @REMOTE did not behave correctly.\n\n> Anything else you want to add:\nI’ve uploaded a video reproducing this issue to a GitHub Gist.\nPlease check here:\nhttps://gist.github.com/kawarimidoll/3e603664432702e434c27f343fb35f85\n\n[System Info]\ngit version:\ngit version 2.48.1\ncpu: aarch64\nno commit associated with this build\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /nix/store/3z1jypscq2ld48kl089ywgwd8ri2rjxq-bash-5.2p37/bin/bash\nfeature: fsmonitor--daemon\nlibcurl: 8.12.1\nOpenSSL: OpenSSL 3.4.1 11 Feb 2025\nzlib: 1.3.1\nuname: Darwin 24.3.0 Darwin Kernel Version 24.3.0: Thu Jan  2 20:24:23\nPST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T8122 arm64\ncompiler info: clang: 19.1.7\nlibc info: no libc information available\n$SHELL (typically, interactive shell): /bin/zsh\n\n\nI appreciate your time in reviewing this. Thank you!\n\nkawarimidoll\nGitHub: https://github.com/kawarimidoll\n"},{"id":"514969","messageId":"CALnO6CD=ghMyWm6s8u3=iH4neRMWnTTAQWUAokcgM1HOBqNC6A@mail.gmail.com","threadId":"63185","inReplyTo":"CAC6paJg19ue7W0VxTnGH-1ra3Zkk+pRnj6McEC755RD54xDzCA@mail.gmail.com","subject":"Re: mergetool.vimdiff.layout behavior differs from documentation","fromName":"D. Ben Knoble","fromEmail":"ben.knoble@gmail.com","sentAt":"2025-03-24T20:35:28Z","receivedAt":"2025-03-24T20:35:41Z","isPatch":false,"sender":{"key":"ben.knoble@gmail.com","avatar":"https://avatars.githubusercontent.com/u/22802209?v=4"},"body":"On Mon, Mar 24, 2025 at 10:54 AM kawarimidoll\n<kawarimidoll+git@gmail.com> wrote:\n>\n> Hello,\n>\n> This is my first time reporting an issue with Git. I am not a native\n> English speaker, so I apologize if there are any translation mistakes.\n>\n> Below is my response to `git bugreport`:\n>\n> > What did you do before the bug happened? (Steps to reproduce your issue)\n> 1. I checked the `git mergetool --help` documentation and configured\n> `$ git config --global mergetool.vimdiff.layout \"@REMOTE\"`.\n> 2. In a repository with merge conflicts, I opened vimdiff using `git\n> mergetool`, updated the REMOTE buffer, and saved the changes.\n>\n> > What did you expect to happen? (Expected behavior)\n> I expected the changes made to the REMOTE buffer to be reflected in the file.\n>\n> > What happened instead? (Actual behavior)\n> The changes made to the REMOTE buffer were **not** reflected in the file.\n>\n> > What’s different between what you expected and what actually happened?\n> The documentation states:\n> ”@ is used to indicate the file containing the final version after\n> solving the conflicts. If not present, MERGED will be used by\n> default.”\n> So I thought that the changes made to the REMOTE buffer will be\n> reflected in the file if I use @REMOTE.\n> However, in my tests, @LOCAL and @MERGED worked as expected, but @BASE\n> and @REMOTE did not behave correctly.\n\nInteresting; I haven't tried to reproduce this, but the docs appear to\n(vaguely) indicate that this is the case.\nI've CC'd the author of most of that mergetool for some help, but the\nissue is likely here (lines 298–310 of the script mergetools/vimdiff\non 683c54c999 (Git 2.49, 2025-03-14)):\n\n# Search for a \"@\" in one of the files identifiers (\"LOCAL\", \"BASE\",\n# \"REMOTE\", \"MERGED\"). If not found, use \"MERGE\" as the default file\n# where changes will be saved.\n\nif echo \"$LAYOUT\" | grep @LOCAL >/dev/null\nthen\nFINAL_TARGET=\"LOCAL\"\nelif echo \"$LAYOUT\" | grep @BASE >/dev/null\nthen\nFINAL_TARGET=\"BASE\"\nelse\nFINAL_TARGET=\"MERGED\"\nfi\n\n(Apologies that my mail client appears to strip leading indentation on\npaste, ugh)\n\nA GitHub link, for those who prefer it:\nhttps://github.com/git/git/blob/683c54c999c301c2cd6f715c411407c413b1d84e/mergetools/vimdiff#L298-L310\n\nThat code goes back to 0041797449 (vimdiff: new implementation with\nlayout support, 2022-03-30), whose author is also CC'd.\n\n-- \nD. Ben Knoble\n"},{"id":"514976","messageId":"Z-HiDODocZftrtgL@x395.localdomain","threadId":"63185","inReplyTo":"CALnO6CD=ghMyWm6s8u3=iH4neRMWnTTAQWUAokcgM1HOBqNC6A@mail.gmail.com","subject":"Re: mergetool.vimdiff.layout behavior differs from documentation","fromName":"Fernando Ramos","fromEmail":"greenfoo@u92.eu","sentAt":"2025-03-24T22:51:56Z","receivedAt":"2025-03-24T22:52:49Z","isPatch":false,"sender":{"key":"greenfoo@u92.eu","avatar":"https://avatars.githubusercontent.com/u/42691086?v=4"},"body":"On 25/03/24 04:35PM, D. Ben Knoble wrote:\n> I've CC'd the author of most of that mergetool for some help, but the\n> issue is likely here (lines 298–310 of the script mergetools/vimdiff\n> on 683c54c999 (Git 2.49, 2025-03-14)):\n> \n> # Search for a \"@\" in one of the files identifiers (\"LOCAL\", \"BASE\",\n> # \"REMOTE\", \"MERGED\"). If not found, use \"MERGE\" as the default file\n> # where changes will be saved.\n> \n> if echo \"$LAYOUT\" | grep @LOCAL >/dev/null\n> then\n> FINAL_TARGET=\"LOCAL\"\n> elif echo \"$LAYOUT\" | grep @BASE >/dev/null\n> then\n> FINAL_TARGET=\"BASE\"\n> else\n> FINAL_TARGET=\"MERGED\"\n> fi\n\nYou are completely right. This is a bug which can probably be fixed by simply\nadding one extra \"elif\":\n\n   if echo \"$LAYOUT\" | grep @LOCAL >/dev/null\n   then\n   FINAL_TARGET=\"LOCAL\"\n   elif echo \"$LAYOUT\" | grep @BASE >/dev/null\n   then\n   FINAL_TARGET=\"BASE\"\n  +elif echo \"$LAYOUT\" | grep @REMOTE >/dev/null\n  +then\n  +FINAL_TARGET=\"REMOTE\"\n   else\n   FINAL_TARGET=\"MERGED\"\n   fi\n    \nIf you can test it and prepare a patch, that would be great. Otherwise I will\ntry to do it myself in a few days.\n\nThanks!\n"}]}