[vim/vim] git mergetool use vimdiff, vimrc &diff is 0 (Issue #10934)

94 views
Skip to first unread message

aohan237

unread,
Aug 17, 2022, 6:29:34 AM8/17/22
to vim/vim, Subscribed

Steps to reproduce

set git merge tool using vimdiff

using git mergetool

vimrc :
echo &diff

Expected behaviour

echo 1 but echo 0

using standalone vimdiff echo 1

Version of Vim

9.0.200

Environment

mac

Logs and stack traces

No response


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/10934@github.com>

Christian Brabandt

unread,
Aug 17, 2022, 6:43:41 AM8/17/22
to vim/vim, Subscribed

most likely, diff mode is enabled after the vim has completely started up (and after .vimrc) is read. Run it interactively using :echo &diff or in a VimEnter autocommand. I don't think this is a bug here.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/10934/1217843217@github.com>

Gary Johnson

unread,
Aug 17, 2022, 12:08:37 PM8/17/22
to reply+ACY5DGGFCFYGUEFFKB...@reply.github.com, vim...@googlegroups.com
On 2022-08-17, Christian Brabandt wrote:
> most likely, diff mode is enabled after the vim has completely started up (and
> after .vimrc) is read. Run it interactively using :echo &diff or in a VimEnter
> autocommand. I don't think this is a bug here.

Something funny is going on, though. When I try that experiment on
my Ubuntu 20.04 system with Vim 9.0, &diff is 1.

I've had one or more tests of "if &diff" in my vimrc for years and
they have always worked as expected.

Here is the mergetool section of my ~/.gitconfig, for what it's
worth.

[merge]
tool = vimdiff
trustExitCode = true
conflictStyle = diff3

[mergetool "vimdiff"]
cmd = "vim -d -c '4wincmd w | wincmd J | wincmd =' $LOCAL $BASE $REMOTE $MERGED"

Maybe there's something different about some of this on a Mac.

Regards,
Gary

vim-dev ML

unread,
Aug 17, 2022, 12:08:53 PM8/17/22
to vim/vim, vim-dev ML, Your activity


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/10934/1218223692@github.com>

Christian Brabandt

unread,
Aug 17, 2022, 12:36:38 PM8/17/22
to vim...@googlegroups.com, vim/vim, vim-dev ML, Your activity
I wonder, if this is caused by the recent changes  in git release 2.37 on how vimdiff is called https://github.com/git/git/blob/v2.37.0/Documentation/RelNotes/2.37.0.txt

Chris 

Am 17.08.2022 um 18:08 schrieb vim-dev ML <vim-dev...@256bit.org>:


--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/vim/vim/issues/10934/1218223692%40github.com.

Christian Brabandt

unread,
Aug 17, 2022, 12:39:50 PM8/17/22
to vim...@googlegroups.com, vim/vim, Comment
I wonder, if this is caused by the recent changes  in git release 2.37 on how vimdiff is called https://github.com/git/git/blob/v2.37.0/Documentation/RelNotes/2.37.0.txt

Chris 


Am 17.08.2022 um 18:08 schrieb vim-dev ML <notifi...@github.com>:


--

Gary Johnson

unread,
Aug 17, 2022, 1:58:13 PM8/17/22
to vim...@googlegroups.com
On 2022-08-17, Christian Brabandt wrote:
> I wonder, if this is caused by the recent changes in git release 2.37 on how
> vimdiff is called https://github.com/git/git/blob/v2.37.0/Documentation/
> RelNotes/2.37.0.txt

I wonder. I'm still running git 2.26.2. If, from the Vim instance
running the merge, I execute this:

:!ps -fH

I see this:

UID PID PPID C STIME TTY TIME CMD
gary 109235 109234 0 10:16 pts/9 00:00:00 bash
gary 109430 109235 0 10:18 pts/9 00:00:00 git mergetool
gary 109431 109430 0 10:18 pts/9 00:00:00 /bin/sh /usr/lib/git-core/git-mergetool
gary 109489 109431 0 10:18 pts/9 00:00:00 /bin/sh /usr/lib/git-core/git-mergetool
gary 109490 109489 0 10:18 pts/9 00:00:00 vim -d -c 4wincmd w | wincmd J | wincmd = ./mary_LOCAL_109431.txt ./mary_BASE_109431.txt ./mary_REMOTE_109431.txt mary.txt
gary 109535 109490 0 10:20 pts/9 00:00:00 ps -fH

I wonder what the OP sees on their Mac. I _think_ a Mac has ps.

OK, I tried another experiment. I have Cygwin running on a Windows
10 PC and it has git 2.37.1 and Vim 9.0. I set up the same
experiment as on my Ubuntu system, but stripped the ~/.gitconfig
file down to its essentials so that it would use the default
mergetool. When I did that and ran the following:

$ git mergetool
:sh
$ COLUMNS=512 ps -fH

I saw this:

UID PID PPID C STIME TTY TIME CMD
gjohn 1507 1506 0 10:27 pty0 00:00:00 -bash
gjohn 1857 1507 0 10:41 pty0 00:00:00 git mergetool
gjohn 1858 1857 0 10:41 pty0 00:00:00 /bin/sh /usr/libexec/git-core/git-mergetool
gjohn 2070 1858 0 10:41 pty0 00:00:01 vim -f -c echo | split | vertical split | 1b | wincmd l | vertical split | 2b | wincmd l | 3b | wincmd j | 4b | tabdo windo diffthis -c tabfirst ./mary_LOCAL_1858.txt ./mary_BASE_1858.txt ./mary_REMOTE_1858.txt mary.txt
gjohn 2076 2070 0 10:43 pty0 00:00:00 /bin/bash
gjohn 2129 2076 0 10:48 pty0 00:00:00 /bin/bash
gjohn 2128 2076 0 10:48 pty0 00:00:00 procps -fH

Sure enough, the new git mergetool using vimdiff does not start vim
in diff mode. Good find, Chris.

So I guess the OP can either define mergetool in their ~/.gitconfig
to something more like mine or like the old git default, or figure
out how to get the information they want from the new mergetool
command.

Regards,
Gary

aohan237

unread,
Aug 17, 2022, 10:11:22 PM8/17/22
to vim/vim, vim-dev ML, Comment

i just only use tool as vimdiff ,but has no startup cmd

[mergetool "vimdiff"]
cmd = "vim -d -c '4wincmd w | wincmd J | wincmd =' $LOCAL $BASE $REMOTE $MERGED"

this section makes it right.

but is there any explanation on this, git or vimdiff seems no doc on this, and cant google it out


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/issues/10934/1218911809@github.com>

aohan237

unread,
Aug 17, 2022, 10:14:14 PM8/17/22
to vim/vim, vim-dev ML, Mention

@chrisbra maybe the way git mergetool use vimdiff cause this.

@vim-ml 's cmd solution goes right. maybe i should ask git for an answer, there is no doc on this feature


Reply to this email directly, view it on GitHub.

You are receiving this because you were mentioned.Message ID: <vim/vim/issues/10934/1218912997@github.com>

Gary Johnson

unread,
Aug 18, 2022, 1:05:56 AM8/18/22
to reply+ACY5DGHONTXVCN7FNM...@reply.github.com, vim...@googlegroups.com
On 2022-08-17, aohan237 wrote:
> @chrisbra maybe the way git mergetool use vimdiff cause this.
>
> @vim-ml 's cmd solution goes right. maybe i should ask git for an answer, there
> is no doc on this feature

I don't know whether you saw my earlier, lengthy reply to Chris, but
that answered the question of _what_ changed in git. The URL that
Chris posted explains a little of the _why_, but not all. It just
said that they made the mergetool better, but it didn't explain how
the new way was better.

What the git developers did was to change the mergetool command that
diffs the various versions of the file being merged. They used to
start the command with "vim -f -d ...", which started vim in diff
mode so that &diff was 1 when vimrc was sourced. They changed the
command to start with "vim -f -c 'echo | ..." and somewhere in that
command they execute diffthis in a loop. Consequently, that command
does not put vim into diff mode when it starts and vimrc is sourced
when &diff is 0.

It is not clear at all to me why someone thought the new mergetool
command was in some way better than the old one.

The problem is solely due to the change made in git.

I thought that the mergetool command was documented somewhere in the
git documentation, but I haven't looked for it in a long while. You
_might_ find some explanation for the change in the git mailing list
archives or in the git log of the git repository, but not all
developers explain their reasoning very well. The git mailing list
would be the place to ask about this.

Regards,
Gary

vim-dev ML

unread,
Aug 18, 2022, 1:06:17 AM8/18/22
to vim/vim, vim-dev ML, Your activity


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/10934/1219042459@github.com>

aohan237

unread,
Aug 18, 2022, 2:33:31 AM8/18/22
to vim/vim, vim-dev ML, Mention

@vim-ml

I don't know whether you saw my earlier, lengthy reply to Chris, but

that answered the question of what changed in git. The URL that
Chris posted explains a little of the why, but not all. It just


said that they made the mergetool better, but it didn't explain how
the new way was better.

i did not see your lengthy reply to Chris and what he posted, perhaps in other issues or somewhere else.

i read the git-scm doc git-scm and the git man page, there is no explanations on this.

maybe the git mailing list is the right place to ask.

thanks, best regards


Reply to this email directly, view it on GitHub.

You are receiving this because you were mentioned.Message ID: <vim/vim/issues/10934/1219090347@github.com>

aohan237

unread,
Aug 18, 2022, 2:34:20 AM8/18/22
to vim/vim, vim-dev ML, Mention

Closed #10934 as completed.


Reply to this email directly, view it on GitHub.

You are receiving this because you were mentioned.Message ID: <vim/vim/issue/10934/issue_event/7211436521@github.com>

Christian Brabandt

unread,
Aug 18, 2022, 2:42:54 AM8/18/22
to vim/vim, vim-dev ML, Mention

I think the change by git was done to make the layout for vim more flexible, so that you do not need to specify vimdiff1, vimdiff2, vimdiff3 etc. It's explained by the author here: https://u92.eu/blog/git-vimdiff/

If you think there is a bug with this, I'd recommend to take this to the git developers mailinglist.


Reply to this email directly, view it on GitHub.

You are receiving this because you were mentioned.Message ID: <vim/vim/issues/10934/1219096841@github.com>

aohan237

unread,
Aug 18, 2022, 2:46:34 AM8/18/22
to vim/vim, vim-dev ML, Mention

@chrisbra thanks, i will read it


Reply to this email directly, view it on GitHub.

You are receiving this because you were mentioned.Message ID: <vim/vim/issues/10934/1219099131@github.com>

Reply all
Reply to author
Forward
0 new messages