Reputation: 1710
I have git
configured (like below) to use vimdiff
as difftool
and compare another pair of files without prompting as soon as I call :qa
. It's awesome. The only problem is sometimes there are differences in many files. How do I prevent git
from running another vimdiff
instance and continuing the diffs queue?
git config --global diff.tool vimdiff
git config --global difftool.prompt false
git config --global alias.d difftool
I tried to quit vim
with a non-zero error code (:cq
) but it doesn't help.
Would be awesome if the answer worked for both vim
and nvim
.
Upvotes: 0
Views: 458
Reputation: 1330102
Note that you will be able to apply your mergetool.trustExitCode true
not just for vimdiff
, but nvimdiff
as well.
With Git 2.29 (Q4 2020), The existing backends for "git mergetool
"(man) based on variants of vim
have been refactored and then support for "nvim
" has been added.
See commit 1186897, commit 83bbf9b (29 Jul 2020) by pudinha (pudinha
).
(Merged by Junio C Hamano -- gitster
-- in commit 873fa13, 17 Aug 2020)
mergetools
: add support for nvimdiff (neovim) familySigned-off-by: pudinha
Fix regression introduced when nvimdiff
support in mergetool
was added with Git 2.30 (Q1 2021).
See commit 12026f4, commit 6bc9082 (11 Nov 2020) by Johannes Schindelin (dscho
).
(Merged by Junio C Hamano -- gitster
-- in commit d203add, 21 Nov 2020)
mergetool
: avoid lettinglist_tool_variants
break user-defined setupsSigned-off-by: Johannes Schindelin
In 83bbf9b92ea8 ("
mergetool--lib
: improve support for vimdiff-style tool variants", 2020-07-29, Git v2.29.0-rc0 -- merge listed in batch #8), we introduced alist_tool_variants
function in the spirit of Postel's Law: be lenient in what you accept as input. In this particular instance, we wanted to allow not onlybc
but alsobc3
as name for the Beyond Compare tool.However, what this patch overlooked is that it is totally allowed for users to override the defaults in
mergetools/
.
But now that we strip off trailing digits, the name that the user gave the tool might not actually be in the list produced bylist_tool_variants
.So let's do the same as for the
diff_cmd
and themerge_cmd
: override it with the trivial version in case a user-defined setup was detected.
Git 2.30.1 (Q1 2021) fixes a 2.29 regression where "git mergetool --tool-help
"(man) fails to list all the available tools.
See commit 80f5a16 (07 Jan 2021) by Philippe Blain (phil-blain
).
(Merged by Junio C Hamano -- gitster
-- in commit 073552d, 15 Jan 2021)
mergetool--lib
: fix '--tool-help
' to correctly show available toolsReported-by: Philippe Blain
Based-on-patch-by: Johannes Sixt
Signed-off-by: Philippe Blain
Commit 83bbf9b ("
mergetool--lib
: improve support for vimdiff-style tool variants", 2020-07-29, Git v2.29.0-rc0 -- merge listed in batch #8) introduced a regression in the output ofgit mergetool --tool-help
(man) andgit difftool --tool-help
(man) [1].In function '
show_tool_names
' ingit-mergetool--lib.sh
, we loop over the supportedmergetools
and their variants and accumulate them in the variable 'variants
', separating them with a literal '\n
'.The code then uses '
echo $variants
' to turn these '\n
' into newlines, but this behaviour is not portable, it just happens to work in some shells, like dash(1)'s 'echo' builtin.For shells in which '
echo
' does not turn '\n
' into newlines, the end result is that the only tools that are shown are the existing variants (except the last variant alphabetically), since the variants are separated by actual newlines in '$variants
' because of the several 'echo
' calls inmergetools/{bc,vimdiff}::list_tool_variants
.Fix this bug by embedding an actual line feed into
variants
inshow_tool_names()
.
While at it, replacesort
|uniq
bysort -u
.To prevent future regressions, add a simple test that checks that a few known tools are correctly shown (let's avoid counting the total number of tools to lessen the maintenance burden when new tools are added or if '
--tool-help
' learns additional logic, like hiding tools depending on the current platform).[1] https://lore.kernel.org/git/CADtb9DyozjgAsdFYL8fFBEWmq7iz4=prZYVUdH9W-J5CKVS4OA@mail.gmail.com/
Upvotes: 1
Reputation: 1710
I got the solution on different stack:
git config --global difftool.trustExitCode true
git config --global mergetool.trustExitCode true
And then exiting with :cq
As mentioned by @VonC, works for nvim
as well.
Upvotes: 3