]> git.ipfire.org Git - thirdparty/git.git/commit
unpack_trees(): skip trees that are the same in all input
authorJunio C Hamano <gitster@pobox.com>
Wed, 22 Dec 2010 22:13:47 +0000 (14:13 -0800)
committerJunio C Hamano <gitster@pobox.com>
Tue, 4 Jan 2011 21:03:32 +0000 (13:03 -0800)
commit83c90314aa27ae3768c04375d02e4f3fb12b726d
tree98c2f09d1f345336613ae6551a99096b58542c33
parent84563a624e1e417c452491f3b9fba8879e989af0
unpack_trees(): skip trees that are the same in all input

unpack_trees() merges two trees (the current HEAD and the destination
commit) when switching to another branch, checking and updating the index
entry where the destination differs from the current HEAD.  It merges three
trees (the common ancestor, the current HEAD and the other commit) when
performing a three-way merge, checking and updating the index entry when
the merge result differs from the current HEAD.  It does so by walking the
input trees in parallel all the way down to the leaves.

One common special case is a directory is identical across the trees
involved in the merge.  In such a case, we do not have to descend into the
directory at all---we know that the end result is to keep the entries in
the current index.

This optimization cannot be applied in a few special cases in
unpack_trees(), though.  We need to descend into the directory and update
the index entries from the target tree in the following cases:

 - When resetting (e.g. "git reset --hard"); and

 - When checking out a tree for the first time into an empty working tree
   (e.g. "git read-tree -m -u HEAD HEAD" with missing .git/index).

Signed-off-by: Junio C Hamano <gitster@pobox.com>
unpack-trees.c