如何配置 kdiff3 而不是作为 git mergetool 出现?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9776434/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to configure kdiff3 instead of emerge as a git mergetool?
提问by AKFourSeven
I have Git on mac OSX Snow Leopard and I tried to edit my merge and diff tool to use kdiff3 instead of emerge.
我在 mac OSX Snow Leopard 上安装了 Git,我尝试编辑我的合并和差异工具以使用 kdiff3 而不是emerge。
But when I try to use it does not launch the GUI of kdiff and keeps me with a cmd based interface.
但是当我尝试使用它时,它不会启动 kdiff 的 GUI,而是让我使用基于 cmd 的界面。
My setting in gitconfig are:
我在 gitconfig 中的设置是:
[merge]
tool = kdiff3
[mergetool "kdiff3"]
cmd = /Applications/kdiff3.app/Contents/MacOS/kdiff3
args = $base $local $other -o $output
trustExitCode = false
[diff]
tool = kdiff3
[difftool "kdiff3"]
cmd = /Applications/kdiff3.app/Contents/MacOS/kdiff3
args = $base $local $other -o $output
trustExitCode = false
There is obviously something missing but what did I do wrong ?
显然缺少一些东西,但我做错了什么?
回答by sschuberth
Recent Git versions have built-in support for kdiff3
, so there's no need to configure it manually using the generic cmdand argssettings. Instead do:
最近的 Git 版本内置了对 的支持kdiff3
,因此无需使用通用的cmd和args设置手动配置它。而是这样做:
$ git config --global merge.tool kdiff3
And if kdiff3
is not in your PATHenvironment also do:
如果kdiff3
不在您的PATH环境中,请执行以下操作:
$ git config --global mergetool.kdiff3.path /Applications/kdiff3.app/Contents/MacOS/kdiff3
This makes git mergetool
launch kdiff3
. Note that there is no wayto configure Git to automaticallylaunch your merge tool after a manual merge that has conflicts.
这使得git mergetool
发射kdiff3
. 请注意,有没有办法来配置Git用自动有冲突手动合并后推出的合并工具。
In case you really want to see how Git is calling kdiff3
internally, take a look at the built-in mergetool configuration for kdiff3.
如果您真的想了解 Git 在kdiff3
内部如何调用,请查看kdiff3 的内置 mergetool 配置。
Edit: For Beyond Compare 4, which now also supports Mac OS X, simply exchange kdiff3
with bc3
(yes, "3") and adjust the path in the above lines. Starting with Git 2.2.0 you'll be able to use bc
as an alias for bc3
so that you do not have to care about the version number.
编辑:对于现在也支持 Mac OS X 的Beyond Compare 4,只需kdiff3
与bc3
(是的,“3”)交换并调整上述行中的路径。从 Git 2.2.0 开始,您将能够将其bc
用作别名,bc3
这样您就不必关心版本号。
回答by VonC
Recent Git versions have built-in support for kdiff3
最近的 Git 版本内置了对 kdiff3 的支持
Yes, but only Git 2.12 (Q1 2017) will allow those built-in tools to trust their exit code.
是的,但只有 Git 2.12(2017 年第一季度)将允许这些内置工具信任其退出代码。
See commit 2967284, commit 7c10605(29 Nov 2016) by David Aguilar (davvid
).
(Merged by Junio C Hamano -- gitster
--in commit c4a44e2, 16 Dec 2016)
请参阅David Aguilar ( ) 的commit 2967284和commit 7c10605(2016 年 11 月 29 日)。(由Junio C Hamano合并-- --在提交 c4a44e2 中,2016 年 12 月 16 日)davvid
gitster
mergetool
: honormergetool.$tool.trustExitCode
for built-in toolsBuilt-in merge tools contain a hard-coded assumption about whether or not a tool's exit code can be trusted to determine the success or failure of a merge.
Tools whose exit codes are not trusted contain calls tocheck_unchanged()
in theirmerge_cmd()
functions.A problem with this is that the trustExitCode configuration is not honored for built-in tools.
Teach built-in tools to honor the
trustExitCode
configuration.
mergetool
:mergetool.$tool.trustExitCode
内置工具的荣誉内置合并工具包含一个关于是否可以信任工具的退出代码来确定合并成功或失败的硬编码假设。
退出代码不受信任的工具check_unchanged()
在其merge_cmd()
函数中包含对 的调用。这样做的一个问题是内置工具不支持 trustExitCode 配置。
教授内置工具来尊重
trustExitCode
配置。
(See kdiff3
)
(见kdiff3
)
Extend
run_merge_cmd()
so that it is responsible for callingcheck_unchanged()
when a tool's exit code cannot be trusted.
Removecheck_unchanged()
calls from scriptlets since they are no longer responsible for calling it.
扩展
run_merge_cmd()
以便它负责check_unchanged()
在工具的退出代码不可信时调用。
删除check_unchanged()
scriptlet 中的调用,因为它们不再负责调用它。