]> git.ipfire.org Git - thirdparty/git.git/commit - tree-diff.c
tree-diff: consolidate code for emitting diffs and recursion in one place
authorKirill Smelkov <kirr@mns.spb.ru>
Mon, 24 Feb 2014 16:21:38 +0000 (20:21 +0400)
committerJunio C Hamano <gitster@pobox.com>
Thu, 20 Mar 2014 22:03:24 +0000 (15:03 -0700)
commitd00e980c224d4b65972dda4474fbd9294bdb185f
tree64ebd699c0a5ef9c8db13d141ffbed549e78e1ee
parent7e9003c1497d01f2e75a5f3df7303643fb2432c3
tree-diff: consolidate code for emitting diffs and recursion in one place

Currently both compare_tree_entry() and show_entry() invoke opt diff
callbacks (opt->add_remove() and opt->change()), and also they both have
code which decides whether to recurse into sub-tree, and whether to emit
a tree as separate entry if DIFF_OPT_TREE_IN_RECURSIVE is set.

I.e. we have code duplication and logic scattered on two places.

Let's consolidate it - all diff emiting code and recurion logic moves
to show_entry, which is now named as show_path, because it shows diff
for a path, based on up to two tree entries, with actual diff emitting
code being kept in new helper emit_diff() for clarity.

What we have as the result, is that compare_tree_entry is now free from
code with logic for diff generation, and also performance is not
affected as timings for

    `git log --raw --no-abbrev --no-renames`

for navy.git and `linux.git v3.10..v3.11`, just like in previous patch,
stay the same.

Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
tree-diff.c