tig icon indicating copy to clipboard operation
tig copied to clipboard

support diffs for merge commits

Open kapilt opened this issue 9 years ago • 12 comments

per http://stackoverflow.com/questions/25967014/how-to-get-proper-diff-of-merge-commit-in-tig

kapilt avatar Sep 22 '14 05:09 kapilt

Looks like you found a solution using a keybinding:

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

jonas avatar Sep 23 '14 03:09 jonas

Please consider re-opening it.

It would be more convenient to have the diff right there by default (not via some external tool/pager), similar to using git log -p -m.

I can see that the current behaviour is good, because it shows any changes which might have been done in the merge commit itself (like git log -p -c), but there could be some key-binding to toggle this (between the patch of the merge commit and the changes brought in by the merge).

blueyed avatar Jun 12 '15 20:06 blueyed

@blueyed What would be the expected behaviour for merges with multiple parents?

jonas avatar Jun 12 '15 23:06 jonas

I'm not sure. Maybe Git's --first-parent could/should be used with the -m-mode (by default)?

I can see three modes here:

  1. the current (new default?), showing any changes in the merge commit (usually empty)
  2. showing the full diff against the first parent (-m --first-parent)
  3. and the full(?) merge diff (-m).

I am not sure if I understand --first-parent correctly though, from git-log(1):

   git log -p -m --first-parent
       Shows the history including change diffs, but only from the “main
       branch” perspective, skipping commits that come from merged branches,
       and showing full diffs of changes introduced by the merges. This makes
       sense only when following a strict policy of merging all topic
       branches when staying on a single integration branch.

(Here is an additionally use case: I often use tig to see what has changed after git fetch (e.g. via an alias tignews=tig HEAD@{1}..HEAD@{0}), and if there are merge commits, the commits itself are often not included in the list view's range. Having the diff in the merge then would be helpul.)

blueyed avatar Jun 15 '15 01:06 blueyed

I don't see this mentioned here, but this used to work exactly this way (seeing diffs for merges), until it stopped working in 9febe931fb14f71d05d082aef94b17fe45e529f3

chutzimir avatar Aug 25 '15 04:08 chutzimir

OK, I'll make a diff specific filter for rev args

jonas avatar Aug 25 '15 07:08 jonas

Any update on this? I'd love to have a built-in way to see the entire diff produced by a merge (though not by default).

wavexx avatar Feb 04 '20 10:02 wavexx

Anything wrong with tig -m ?

koutcher avatar Feb 04 '20 18:02 koutcher

Anything wrong with tig -m ?

It appears to not be documented at least (--help and man page), and it cannot be toggled in an open instance, can it? I assume it works because it passes the option through to git-log then?

blueyed avatar Feb 04 '20 21:02 blueyed

Yes, it's what it does, that's why it's not documented. In an open instance you can define custom bindings with :set diff-options = -m and :set diff-options = . It's not perfect, especially if you already use diff-options as you'll have to modify your bindings accordingly, but it does the job.

koutcher avatar Feb 04 '20 21:02 koutcher

That does the job then I assume.

blueyed avatar Feb 04 '20 22:02 blueyed

On Tue, Feb 04 2020, Daniel Hahler wrote:

That does the job then I would assume.

.. maybe, we can have toggle for it? ;)

wavexx avatar Feb 04 '20 22:02 wavexx