Prepare "git-merge-tree" for future work
commit83788070a3dd0a4905dd76c865320c51f7d74a83
authorLinus Torvalds <torvalds@osdl.org>
Wed, 28 Jun 2006 18:18:27 +0000 (28 11:18 -0700)
committerJunio C Hamano <junkio@cox.net>
Thu, 29 Jun 2006 05:24:45 +0000 (28 22:24 -0700)
treece3f676e1e7f29abdf52426bdc80781ef0d03d8e
parenta9ed376b158faf82d3685b51d546ccaeda716da3
Prepare "git-merge-tree" for future work

This changes how "git-merge-tree" works in two ways:

 - instead of printing things out as we walk the trees, we save the
   results in memory.
 - when we've walked the tree fully, we print out the results in a more
   explicit way, describing the data.

This is basically preparatory work for extending the git-merge-tree
functionality in interesting directions.

In particular, git-merge-tree is also how you would create a diff between
two trees _without_ necessarily creating the merge commit itself. In other
words, if you were to just wonder what another branch adds, you should be
able to (eventually) just do

git merge-tree -p $base HEAD $otherbranch

to generate a diff of what the merge would look like. The current merge
tree already basically has all the smarts for this, and the explanation of
the results just means that hopefully somebody else than me could do the
boring work.

(You'd basically be able to do the above diff by just changing the
printout format for the explanation, and making the "changed in both"
first do a three-way merge before it diffs the result).

The other thing that the in-memory format allows is rename detection
(which the current code does not do). That's the basic reason why we don't
want to just explain the differences as we go along - because we want to
be able to look at the _other_ differences to see whether the reason an
entry got deleted in either branch was perhaps because it got added in
another place..

Rename detection should be a fairly trivial pass in between the tree
diffing and the explanation.

In the meantime, this doesn't actually do anything new, it just outputs
the information in a more verbose manner.

For an example merge, commit 5ab2c0a47574c92f92ea3709b23ca35d96319edd in
the git tree works well and shows renames, along with true removals and
additions and files that got changed in both branches. To see that as a
tree merge, do:

git-merge-tree 64e86c57 c5c23745 928e47e3

where the two last ones are the tips that got merged, and the first one is
the merge base.

Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
merge-tree.c