gitdiffvimdiffdifftoolgit-difftool

Is there a way to stop `git diff-tool` when return code is non-zero from the diff-tool is non-zero


I am aware of the git config option difftool.prompt true

However, I am wondering if there is a way to stop diffing when return code is non-zero. I am using vim as diff-tool and if I exit using :cq it will return non-zero but the default settings of git do not stop diffing the remaining files when it gets non-zero return code.

I guess this makes sense since some tools will return non-zero code when files differ and most people will not want to stop at this point, however, in my case it will return non-zero only if I vim encounter an error or if I asked it to do and in these cases I will always want git diff-tool to stop.

So is there a way to change the default setting to stop when received a non-zero return code?


Solution

  • Once:

    git difftool --trust-exit-code
    

    Permanet:

    git config difftool.trustExitCode true
    

    See the docs: 1, 2.