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

Re: trustExitCode doesn't apply to vimdiff mergetool

From
Dun Peal <dunpealer@gmail.com>
Date
Nov 27, 2016, 13:46 UTC
Message-ID
<CAD03jn7gU9g7NyDk_3wYTKsYQUtRGg6msvumZqUDs44hMOVX7w@mail.gmail.com>
In-Reply-To
<20161127050818.rmjpvha64y4wosq2@sigill.intra.peff.net>
Thanks, Jeff.

Ignoring a non-zero exit code from the merge tool, and assuming a successful merge in that case, seems like the wrong default behavior to me.

If your merge tool quit with an error, it is more sensible to assume that the resolution you were working on has not been successfully concluded.

In the rare case where one did successfully conclude the resolution, you can always quickly mark the file resolved. I'm not even sure how to do that short of `git checkout -m -- file`, which would lose any work you've already done towards the merge.

Long story short, I hope the developers change this default, or at least let us override it for the builtin invocations.

Finally, if you're not using mergetools, how do you resolve conflicts?
On Sun, Nov 27, 2016 at 12:08 AM, Jeff King <peff@peff.net> wrote:
Show 39 quoted lines
> On Sat, Nov 26, 2016 at 09:44:36PM -0500, Dun Peal wrote:
>
>> I'm using vimdiff as my mergetool, and have the following lines in
>> ~/.gitconfig:
>>
>> [merge]
>>     tool = vimdiff
>> [mergetool "vimdiff"]
>>     trustExitCode = true
>>
>>
>> My understanding from the docs is that this sets
>> mergetool.vimdiff.trustExitCode to true, thereby concluding that a
>> merge hasn't been successful if vimdiff's exit code is non-zero.
>>
>> Unfortunately, when I exit Vim using `:cq` - which returns code 1 -
>> the merge is still presumed to have succeeded.
>>
>> Is there a way to accomplish the desired effect, such that exiting
>> vimdiff with a non-zero code would prevent git from resolving the
>> conflict in the merged file?
>
> I don't use mergetool myself, but peeking at the code, it looks like
> trustExitCode is used only for a "user" tool, not for the builtin tool
> profiles. That sounds kind of confusing to me, but I'll leave discussion
> of that to people more interested in mergetool.
>
> However, I think you can work around it by defining your own tool that
> runs vimdiff:
>
>   git config merge.tool foo
>   git config mergetool.foo.cmd 'vimdiff "$LOCAL" "$BASE" "$REMOTE" "$MERGED"'
>   git config mergetool.foo.trustExitCode true
>
> Though note that the builtin vimdiff invocation is a little more
> complicated than that. You may want to adapt what is in git.git's
> mergetools/vimdiff to your liking.
>
> -Peff
Previous: Jeff KingNext: Jeff King
Message 3 of 8 in “trustExitCode doesn't apply to vimdiff mergetool”
  1. Dun PealNov 27, 2016
  2. Jeff KingNov 27, 2016
  3. Dun PealNov 27, 2016
  4. Jeff KingNov 27, 2016
  5. David AguilarNov 28, 2016
  6. Jeff KingNov 28, 2016
  7. David AguilarNov 28, 2016
  8. Junio C HamanoNov 28, 2016

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.