# Union diff

3 messages from 2006-03-26 to 2006-04-09. Participants: Petr Baudis, Junio C Hamano.
Thread: https://gitlist.dev/t/3731

## Petr Baudis, 2006-03-26 10:21

Subject: Union diff
Message-ID: <20060326102100.GF18185@pasky.or.cz>
URL: https://gitlist.dev/e/20060326102100.GF18185%40pasky.or.cz

```
  Hello,

  sorry for possibly a silly question, but can I get a diff of a merge
commit with _union_ of changes against all the parents?

	$ git-diff-tree --abbrev -r -m --pretty=raw badfc383b

	diff-tree badfc38... (from 1ee6c84...)
	tree 29d81f18912328df4f4104e9b9cc355424ced04d
	parent 1ee6c84efda742eda8b4b200491341125d8d9639
	parent 453b160f03c8c6d450879482f617412c257e5889
	author Petr Baudis <pasky@suse.cz> 1143328578 +0100
	committer Petr Baudis <xpasky@machine.or.cz> 1143328578 +0100

	    Merge with v0.17

	:100755 100755 743c19f... b05900d... M	Documentation/make-cogito-asciidoc
	:100644 100644 5896df7... 6f06c35... M	cg-Xlib

	diff-tree badfc38... (from 453b160...)
	tree 29d81f18912328df4f4104e9b9cc355424ced04d
	parent 1ee6c84efda742eda8b4b200491341125d8d9639
	parent 453b160f03c8c6d450879482f617412c257e5889
	author Petr Baudis <pasky@suse.cz> 1143328578 +0100
	committer Petr Baudis <xpasky@machine.or.cz> 1143328578 +0100

	    Merge with v0.17

	:100644 100644 24ce0a4... d540853... M	TODO
	:100755 100755 6005083... f7efa9d... M	cg-log

  I would like something like:

	diff-tree badfc38... (from parents)
	tree 29d81f18912328df4f4104e9b9cc355424ced04d
	parent 1ee6c84efda742eda8b4b200491341125d8d9639
	parent 453b160f03c8c6d450879482f617412c257e5889
	author Petr Baudis <pasky@suse.cz> 1143328578 +0100
	committer Petr Baudis <xpasky@machine.or.cz> 1143328578 +0100

	    Merge with v0.17

	:100755 100755 743c19f... b05900d... M	Documentation/make-cogito-asciidoc
	:100644 100644 24ce0a4... d540853... M	TODO
	:100644 100644 5896df7... 6f06c35... M	cg-Xlib
	:100755 100755 6005083... f7efa9d... M	cg-log

  Now, the -c option documentation says:

	  It shows the differences from each of the parents to the merge
	result simultaneously, instead of showing pairwise diff between
	a parent and the result one at a time, which '-m' option output
	does.

  This sounds as exactly what I want. Well, the only problem is that the
same diff command as above with -c option added produces no diff at all,
just the header and commit messages. Did I misunderstand the -c
description and does it do something different?

  Thanks,

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
Right now I am having amnesia and deja-vu at the same time.  I think
I have forgotten this before.

```

## Junio C Hamano, 2006-04-09 09:45

Subject: Re: Union diff
Message-ID: <7vslonaxq6.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vslonaxq6.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <20060326102100.GF18185@pasky.or.cz>

```
Petr Baudis <pasky@ucw.cz> writes:

>   Now, the -c option documentation says:
>
> 	  It shows the differences from each of the parents to the merge
> 	result simultaneously, instead of showing pairwise diff between
> 	a parent and the result one at a time, which '-m' option output
> 	does.
>
>   This sounds as exactly what I want. Well, the only problem is that the
> same diff command as above with -c option added produces no diff at all,
> just the header and commit messages. Did I misunderstand the -c
> description and does it do something different?

The --combined diff option is to show merges more sensibly than
plain -m option.  Now, the definition of "sensible" is to say
that a merge is not interesting if it takes a version from one
of the parents.  The paths whose results do not match any of the
parents' version are deemed interesting and are shown.

I think you could tweak and give an option to intersect_paths()
in combine-diff.c, so that paths that match one of the parents
are also included in the output.  I haven't thought about it too
much, but my gut feeling is it would not be very involved
change.

```

## Petr Baudis, 2006-04-09 13:43

Subject: [PATCH] Improve the git-diff-tree -c/-cc documentation
Message-ID: <20060409134317.GV27689@pasky.or.cz>
URL: https://gitlist.dev/e/20060409134317.GV27689%40pasky.or.cz
In-Reply-To: <7vslonaxq6.fsf@assigned-by-dhcp.cox.net>

```
Dear diary, on Sun, Apr 09, 2006 at 11:45:37AM CEST, I got a letter
where Junio C Hamano <junkio@cox.net> said that...
> Petr Baudis <pasky@ucw.cz> writes:
> 
> >   Now, the -c option documentation says:
> >
> > 	  It shows the differences from each of the parents to the merge
> > 	result simultaneously, instead of showing pairwise diff between
> > 	a parent and the result one at a time, which '-m' option output
> > 	does.
> >
> >   This sounds as exactly what I want. Well, the only problem is that the
> > same diff command as above with -c option added produces no diff at all,
> > just the header and commit messages. Did I misunderstand the -c
> > description and does it do something different?
> 
> The --combined diff option is to show merges more sensibly than
> plain -m option.  Now, the definition of "sensible" is to say
> that a merge is not interesting if it takes a version from one
> of the parents.  The paths whose results do not match any of the
> parents' version are deemed interesting and are shown.
> 
> I think you could tweak and give an option to intersect_paths()
> in combine-diff.c, so that paths that match one of the parents
> are also included in the output.  I haven't thought about it too
> much, but my gut feeling is it would not be very involved
> change.

Aha, thanks! I actually think this is more sensible to do, so now I'm
only pondering if in cg-log -f it is more useful to show the list of
files changed relative to the first parent or the files which were
subjected to a content merge...

---
This tries to clarify the -c/-cc documentation and clean up the style and
grammar.

Signed-off-by: Petr Baudis <pasky@suse.cz>
---

 Documentation/git-diff-tree.txt |   25 ++++++++++++++++---------
 1 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/Documentation/git-diff-tree.txt b/Documentation/git-diff-tree.txt
index 9153e4c..d7e529b 100644
--- a/Documentation/git-diff-tree.txt
+++ b/Documentation/git-diff-tree.txt
@@ -60,7 +60,8 @@ separated with a single space are given.
 -m::
 	By default, "git-diff-tree --stdin" does not show
 	differences for merge commits.  With this flag, it shows
-	differences to that commit from all of its parents.
+	differences to that commit from all of its parents. See
+	also '-c'.
 
 -s::
 	By default, "git-diff-tree --stdin" shows differences,
@@ -81,19 +82,25 @@ separated with a single space are given.
 	git-diff-tree outputs a line with the commit ID when
 	applicable.  This flag suppressed the commit ID output.
 
--c,--cc::
-	These flags change the way a merge commit is displayed
+-c::
+	This flag changes the way a merge commit is displayed
 	(which means it is useful only when the command is given
 	one <tree-ish>, or '--stdin').  It shows the differences
-	from each of the parents to the merge result
-	simultaneously, instead of showing pairwise diff between
-	a parent and the result one at a time, which '-m' option
-	output does.  '--cc' further compresses the output by
-	omiting hunks that show differences from only one
+	from each of the parents to the merge result simultaneously
+	instead of showing pairwise diff between a parent and the
+	result one at a time (which is what the '-m' option does).
+	Furthermore, it lists only files which were modified
+	in both parents.
+
+-cc::
+	This flag changes the way a merge commit patch is displayed,
+	in a similar way to the '-c' option. It implies the '-c'
+	and '-p' options and further compresses the patch output
+	by omitting hunks that show differences from only one
 	parent, or show the same change from all but one parent
 	for an Octopus merge.  When this optimization makes all
 	hunks disappear, the commit itself and the commit log
-	message is not shown, just like any other "empty diff" cases.
+	message is not shown, just like in any other "empty diff" case.
 
 --always::
 	Show the commit itself and the commit log message even


-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
Right now I am having amnesia and deja-vu at the same time.  I think
I have forgotten this before.

```
