git mergetool fails
Asked Answered
C

2

6

After a merge I want to use git mergetool to resolve the issue but it fails with whatever tool I specify:

git mergetool                                                                                                          
 merge tool candidates: opendiff kdiff3 tkdiff xxdiff meld tortoisemerge gvimdiff diffuse ecmerge p4merge araxis bc3 vimdiff emerge
Merging:
main.c

Normal merge conflict for 'main.c':
  {local}: modified file
  {remote}: modified file
Hit return to start merge resolution tool (kdiff3):
merge of main.c failed

The tool I specify doesn't seem to be launched at all.

Output of

git config --list

merge.tool=kdiff3
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
Chump answered 21/6, 2012 at 11:39 Comment(0)
E
5

kdiff3 maybe not installed at your system. If it is, please, check if it is available through your PATH variable

Try

git config --global merge.tool <your_merge_program>

Also, you can specify your operating system and available merge programs

Enriqueenriqueta answered 21/6, 2012 at 11:45 Comment(7)
I have kdiff3, meld, gvimdiff (7.2),... and neither seems to work. I am working on RH4Chump
Please, add your git config --list output, probably, without your email/password/etc private detailsEnriqueenriqueta
I assume you run it under linux?Enriqueenriqueta
merge.tool=kdiff3 core.repositoryformatversion=0 core.filemode=true core.bare=false core.logallrefupdates=trueChump
Have you tried to run your mergetool in terminal? (I mean without git). If you can't, then check if it is in your $PATH by echo $PATHEnriqueenriqueta
There was indeed an issue there. Thanks, Ribtoks !Chump
For anyone finding this via Google, <your_merge_program> is NOT a path to your merge program. See here for a complete example of how to configure your merge tool.Debutant
B
1

Note that git 2.10 will offer a better exit status to identify diff/merge tool installation issue.

See commit 45a4f5d (15 Aug 2016) by John Keeping (johnkeeping).
(Merged by Junio C Hamano -- gitster -- in commit 331f06d, 19 Aug 2016)

difftool: always honor fatal error exit codes

At the moment difftool's "trust exit code" logic always suppresses the exit status of the diff utility we invoke.
This is useful because we don't want to exit just because diff returned "1" because the files differ, but it's confusing if the shell returns an error because the selected diff utility is not found.

POSIX specifies

At least bash and dash follow this specification, while diff utilities generally use "1" for the exit status we want to ignore.

Handle any value of 126 or greater as a special value indicating that some form of fatal error occurred.

Burdelle answered 22/8, 2016 at 8:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.