简体   繁体   English

如何在 tig 中获得合并提交的正确差异

[英]How to get proper diff of merge commit in tig

if i got into tig main view, i get a nice graph of commits and merges.如果我进入 tig 主视图,我会得到一个很好的提交和合并图。 i'd prefer to just look at the merge commits to trunk but unlike with normal commits tig where tig shows the full diff with file contents, on merge commits it just shows a list of changed files in the diff view.我更愿意只查看对主干的合并提交,但与普通提交 tig 不同,tig 显示包含文件内容的完整差异,在合并提交时,它仅在差异视图中显示已更改文件的列表。 How do i get tig to display the file contents diff on merge commits?我如何让 tig 在合并提交时显示文件内容差异?

commit fb56223ec50cf659a308b3c9979c912881147689提交 fb56223ec50cf659a308b3c9979c912881147689
Refs: [master], {origin/master}, {origin/HEAD}, juju-1.21-alpha1-229-gfb56223参考资料:[master],{origin/master},{origin/HEAD},juju-1.21-alpha1-229-gfb56223
Merge: 7e7c95d a017b5a合并:7e7c95d a017b5a
Author: Juju bot添加一名作者
AuthorDate: Mon Sep 22 01:22:03 2014 +0100作者日期:2014 年 9 月 22 日星期一 01:22:03 +0100
Commit: Juju bot提交:Juju 机器人
CommitDate: Mon Sep 22 01:22:03 2014 +0100提交日期:2014 年 9 月 22 日星期一 01:22:03 +0100

Merge pull request #803 from mjs/check-ssh-api-methods-are-allowed-during-upgrade

cmd/juju: ensure that API calls used by "juju ssh" are allowed during upgrades

We recently had a regression where an API call required by "juju ssh" wasn't being allowed by the API server while upgrades are in progress. "juju ssh" is one of the few commands that is supposed to work during upgrades.                                                  

The Client used by "juju ssh" is now forced into an interface and this is checked using reflection against what the API server will allow during upgrades. Effectively, the compiler helps to check that the required API methods will be allowed.

http://reviews.vapour.ws/r/64/diff/                                                                                                                                                                                                                                           

apiserver/upgrading_root.go | apiserver/upgrading_root.go | 20 +++++++++++--------- 20 +++++++++++------------
cmd/juju/ssh.go |命令/juju/ssh.go | 15 +++++++++++---- 15 +++++++++++----
cmd/juju/ssh_test.go |命令/juju/ssh_test.go | 24 ++++++++++++++++++++++++ 24 ++++++++++++++++++++++++++
3 files changed, 46 insertions(+), 13 deletions(-) 3 个文件被更改,46 个插入(+),13 个删除(-)

navigating to the individual files (j/k) in the view, says press 'Enter' to view file diff, but hitting enter gets "Failed to find file diff" err message.导航到视图中的单个文件 (j/k),说按“Enter”查看文件差异,但按 Enter 会得到“无法找到文件差异”错误消息。 ideally i'd just be looking at the combined diff for the merge commit.理想情况下,我只是在查看合并提交的组合差异。

[update] i traced through tig with sysdig and it looks like its doing the following which on merge commits won't show the actual diff. [更新]我使用 sysdig 通过 tig 进行了追踪,看起来它正在执行以下合并提交时不会显示实际差异的操作。 git show --encoding=UTF-8 --pretty=fuller --root --patch-with-stat --show-notes --no-color fb56223ec50cf659a308b3c9979c912881147689 -- git show --encoding=UTF-8 --pretty=fuller --root --patch-with-stat --show-notes --no-color fb56223ec50cf659a308b3c9979c912881147689 --

i guess what i'm looking for on merge commits then is to parse the parents commits and then do something like the following git diff 7e7c95d a017b5a我想我在合并提交上寻找的是解析父提交然后做类似下面的 git diff 7e7c95d a017b5a

[update] so the diff actually isn't correct here as that diff would be between the two parents, and be more inclusive of changes then the merge itself, the best content rendering of the diff seems to be [更新]所以这里的差异实际上是不正确的,因为差异将在两个父母之间,并且比合并本身更具包容性,差异的最佳内容呈现似乎是

git diff fb56223^ fb56223 git diff fb56223^ fb56223

Turns out this is pretty straightforward via external command integration, i dropped this into ~/.tigrc and now just press 7 for the diff output i'm looking. 事实证明这是非常简单的通过外部命令集成,我把它放到〜/ .tigrc中,现在只需按7就可以看到diff输出。

bind diff 7 !git diff %(commit)^ %(commit) bind diff 7!git diff%(commit)^%(commit)

You have several options:您有几种选择:

put this into your .tigrc将其放入您的.tigrc

set diff-options = -m

you can set many options in ~/.tigrc , see also the manpage:您可以在~/.tigrc中设置许多选项,另请参阅联机帮助页:

man tigrc


or start tig with the option -m或者使用选项-m启动 tig

tig -m

Options to tig are passed to the underlying git command. tig的选项被传递给底层的 git 命令。 More Info about this also in the manpage:联机帮助页中也有关于此的更多信息:

man tig

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM