git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 0/2] mergetools: vimdiff3: fix regression

From
Fernando Ramos <greenfoo@u92.eu>
Date
Aug 6, 2022, 16:25 UTC
Message-ID
<Yu6V4cIajhoMhB3t@zacax395.localdomain>
In-Reply-To
<20220802214134.681300-1-felipe.contreras@gmail.com>
On 22/08/02 04:41PM, Felipe Contreras wrote:
Show 5 quoted lines
> Hello,
> 
> I wrote vimdiff3 to leverage both the power of git's diff3 and vim's
> diff mode, but commit 0041797449 broke that.
> 
Hi Felipe,
This is the command that runs now when using 'git merge -t vimdiff3':
    vim -c "echo | 4b | bufdo diffthis" -c "tabfirst" LOCAL BASE REMOTE MERGED
...and this is the command that runs after your patch:
    vim -d -c "setl diffopt-=closeoff diffopt-=hiddenoff | hid | hid | hid" LOCAL BASE REMOTE MERGED
The new command you suggest is meant to improve two aspects:
    1. Preserves diff colors.
    2. Removes the "Press ENTER" message.

Regarding (1) I never noticed this because in my tests colors were always shown... but I just tried to run with '-u NONE' (which prevents .vimrc from being loaded) and you are right: there are now no colors.

    vim -u NONE -c "echo | 4b | bufdo diffthis" -c "tabfirst" LOCAL BASE REMOTE MERGED
        ^^^^^^^
        `-> Tell vim not to load .vimrc
So... I started looking into my .vimrc and found the "problem":
    set hidden

By default this option is *not* set, which means buffers are discarded when hidden (and that's why diff colors dissapear). By setting this option colors are back even with '-u NONE':

    vim -u NONE -c "echo | set hidden | 4b | bufdo diffthis" -c "tabfirst" LOCAL BASE REMOTE MERGED
                           ^^^^^^^^^^

Regarding (2) we can remove the "Press ENTER" message by adding "silent" to both "4b" and "bufdo", like this:

    vim -u NONE -c "echo | set hidden | silent 4b | silent bufdo diffthis" -c "tabfirst" LOCAL BASE REMOTE MERGED
                                        ^^^^^^      ^^^^^^

So... by making two changes to the current implementation (adding "set hidden" and "silent") we can make it work. The nice thing is that, this way, "vimdiff3" does not need to be treated as an exception and thus it will be (hopefully) easier to maintain.

What do you think? :)
Thanks!
Fernando.
PS: I'll reply to this message with a patch that implements this in case we
decide to go this route.
Previous: Felipe ContrerasNext: Fernando Ramos
Message 4 of 15 in “mergetools: vimdiff3: fix regression”
  1. 0/2 mergetools: vimdiff3: fix regressionFelipe Contreras, Aug 2, 2022
  2. 1/2 mergetools: vimdiff3: make it work as intendedFelipe Contreras, Aug 2, 2022
  3. 2/2 mergetools: vimdiff3: fix diffopt optionsFelipe Contreras, Aug 2, 2022
  4. Fernando RamosAug 6, 2022
  5. Fernando RamosAug 6, 2022
  6. Felipe ContrerasAug 6, 2022
  7. Fernando RamosAug 6, 2022
  8. vimdiff: fix 'vimdiff3' behavior (colors + no extra key press)Fernando Ramos, Aug 6, 2022
  9. Felipe ContrerasAug 6, 2022
  10. Fernando RamosAug 6, 2022
  11. vimdiff: fix 'vimdiff3' behavior (colors + no extra key press)Fernando Ramos, Aug 6, 2022
  12. Felipe ContrerasAug 7, 2022
  13. Felipe ContrerasAug 6, 2022
  14. Fernando RamosAug 6, 2022
  15. Felipe ContrerasAug 7, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.