如果未设置diff.tool,则Git(2.22.0)difftool不再通过git diff
在Git 2.22.0中的 https://stackoverflow.com/a/56212234 中的每个@VonC答案(发布于2019- 06-08),对git difftool
命令进行了许多更改,以确定其配置方式.
Per @VonC's answer in https://stackoverflow.com/a/56212234 in Git 2.22.0 (released 2019-06-08), a number of changes were made to the git difftool
command regarding how its configuration is determined.
但是,除非我在这里没有什么遗漏,否则似乎在此版本中引入了功能上的回归.在以前的版本(包括2.21.0)中,可以在没有任何配置或CLI选项的情况下使用git difftool
,在这种情况下,它会传递到git diff
.
However, unless I am missing something here, it appears that a regression in functionality has been introduced in this version. In previous versions, including 2.21.0, it has been possible to use git difftool
without any configuration or CLI options, in which case it passes through to git diff
.
现在在Git 2.22.0中,如果我在未配置diff.tool
或merge.tool
的情况下使用git difftool
,则会收到以下消息:
Now in Git 2.22.0 if I use git difftool
without configuring diff.tool
or merge.tool
, I get the following message:
This message is displayed because 'diff.tool' is not configured.
See 'git difftool --tool-help' or 'git help config' for more details.
'git difftool' will now attempt to use one of the following tools:
kompare emerge vimdiff
是否有任何方法可以绕过此错误并返回传递给git diff
的旧行为,或者我必须直接调用git diff
吗?
Is there any way of bypassing this error and returning to the old behavior of passing through to git diff
or must I call git diff
directly?
编辑:根据Jeff King的 git-difftool文档的顶部,它表示:
edit: According to Jeff King's mailing list reply, the new behavior is intentional. However at the top of the git-difftool documentation, it says that:
git difftool 是 git diff 的前端,并接受相同的选项和参数.参见 git-diff [1] .
git difftool is a frontend to git diff and accepts the same options and arguments. See git-diff[1].
不再是这种情况吗?
TLDR;新的错误消息"This message is displayed because 'diff.tool' is not configured.
"可能是实际的错误修复,而不是是新的错误.
TLDR; The new error message "This message is displayed because 'diff.tool' is not configured.
" might be an actual bug fix, and not a new error.
我只是尝试过......没有收到任何错误消息(当使用不带参数时).
I just tried and... didn't get any error message (when used without parameters).
vonc@vonvb:~/git/cplgit/linux$ ./set_git 2.22.0
git set to v2.22.0
vonc@vonvb:~/git/cplgit/linux$ git version
git version 2.22.0
vonc@vonvb:~/git/cplgit/linux$ git config -l|grep -i tool
vonc@vonvb:~/git/cplgit/linux$ git difftool
此外,此错误消息已在 commit 5338a6a,2013年1月,Git v1中引入. 8.2-rc0 .
我确实提到了 commit 05fb872 from Git 2.22 ,它使用的是${GIT_MERGETOOL_GUI}
.
该环境变量未在我的计算机上设置,并且没有收到任何错误消息.
检查您自己的git config
和环境变量.
Plus, this error message has been introduced in commit 5338a6a, Jan. 2013, Git v1.8.2-rc0.
I did mentioned commit 05fb872 from Git 2.22, which uses ${GIT_MERGETOOL_GUI}
.
That environment variable is not set on my machine, and I don't get any error message.
Check your own git config
and environment variables.
我确实在Git 2.22中看到以下错误消息:
I do see the error message in Git 2.22 with:
vonc@vonvb:~/gits/src/git$ git difftool --no-index color.c color.h
This message is displayed because 'diff.tool' is not configured.
See 'git difftool --tool-help' or 'git help config' for more details.
'git difftool' will now attempt to use one of the following tools:
meld opendiff kdiff3 tkdiff xxdiff kompare gvimdiff diffuse diffmerge ecmerge p4merge araxis bc codecompare smerge emerge vimdiff
Viewing (1/1): 'color.c'
Launch 'bc' [Y/n]?
The diff tool bc is not available as 'bcompare'
fatal: external diff died, stopping at color.c
在Git 2.21.0中,它默认为常规的git diff
:
With Git 2.21.0, it does default to a regular git diff
:
vonc@vonvb:~/git/cplgit/linux$ ./set_git 2.21.0
git set to v2.21.0
vonc@vonvb:~/git/cplgit/linux$ git version
git version 2.21.0
vonc@vonvb:~/git/cplgit/linux$ cdgg
vonc@vonvb:~/gits/src/git$ git difftool --no-index color.c color.h
diff --git a/color.c b/color.h
index ebb222ec33..98894d6a17 100644
从 OP Git邮件列表线程:
刘登顿 原始的提交287ab28 (2019年2月16日)通过 Junio C Hamano-gitster
-在
Denton Liu pinpoints the original commit 287ab28 (16 Feb 2019) by Jeff King (peff
).
(Merged by Junio C Hamano -- gitster
-- in commit 12e5bdd, 07 Mar 2019)
diff
:针对--no-index
情况重用差异设置当"
--no-index
"有效(或由参数隐含)时,git-diff
提早跳转到特殊的代码路径来执行该差异.
这意味着我们会错过某些设置,例如默认情况下启用--ext-diff
和--textconv
.
diff
: reuse diff setup for--no-index
caseWhen "
--no-index
" is in effect (or implied by the arguments),git-diff
jumps early to a special code path to perform that diff.
This means we miss out on some settings like enabling--ext-diff
and--textconv
by default.
杰夫·金答复:>
我不太了解
git-difftool
的工作原理,但是看起来像 设置GIT_EXTERNAL_DIFF=git-difftool--helper
.
I don't know much about how
git-difftool
works, but it looks like it setsGIT_EXTERNAL_DIFF=git-difftool--helper
.
在 287ab28bfa 之前,我们不会考虑任何外部差异
运行git-diff
时的命令.但是之后,我们照做.
Prior to 287ab28bfa, we would not have respected any external diff
command when running git-diff
. But after it, we do.
如果用户未提供--no-index
,则全部
我猜difftool
的意思是:它运行帮助程序并说嘿,
您尚未配置".
In the case that the user has not provided --no-index
, then this all
works as I guess difftool
is meant to: it runs the helper and says "hey,
you have not configured this".
似乎上述命令在 287ab28bfa 之前的行为是
不是故意的.
它会运行git-diff
,希望它触发辅助程序,但是它从没有执行(而是执行了普通的no-index diff
).
It seems like the behavior of the above command prior to 287ab28bfa was
not intentional.
It would run git-diff
, expecting it to trigger the helper, but it never did (and instead just did a normal no-index diff
).
因此,看来新行为实际上是正确的选择,因为它使--no-index
案件与常规案件保持一致?
我不清楚您为什么不在这里运行"difftool
"
配置,您只需要直接的diff
输出.
So it seems like the new behavior is actually the right thing, as it makes the --no-index
case consistent with the regular one?
I'm not at all clear why you would run "difftool
" here if you it is not
configured and you just want the straight diff
output.