]> git.ipfire.org Git - thirdparty/git.git/commit - tree-diff.c
tree-diff: rework diff_tree interface to be sha1 based
authorKirill Smelkov <kirr@mns.spb.ru>
Thu, 27 Mar 2014 14:24:38 +0000 (18:24 +0400)
committerJunio C Hamano <gitster@pobox.com>
Thu, 27 Mar 2014 18:49:35 +0000 (11:49 -0700)
commit52894e70951518e44c064cef2561aed38202fd36
tree1f1198bd7bd987565ea3bc7caf12ca7e0f943119
parentad6f3cc7d2eaec5247b39e9dca8e55a0f98123e7
tree-diff: rework diff_tree interface to be sha1 based

In the next commit this will allow to reduce intermediate calls, when
recursing into subtrees - at that stage we know only subtree sha1, and
it is natural for tree walker to start from that phase. For now we do

    diff_tree
        show_path
            diff_tree_sha1
                diff_tree
                    ...

and the change will allow to reduce it to

    diff_tree
        show_path
            diff_tree

Also, it will allow to omit allocating strbuf for each subtree, and just
reuse the common strbuf via playing with its len.

The above-mentioned improvements go in the next 2 patches.

The downside is that try_to_follow_renames(), if active, we cause
re-reading of 2 initial trees, which was negligible based on my timings,
and which is outweighed cogently by the upsides.

NOTE To keep with the current interface and semantics, I needed to
rename the function from diff_tree() to diff_tree_sha1(). As
diff_tree_sha1() was already used, and the function we are talking here
is its more low-level helper, let's use convention for prefixing
such helpers with "ll_". So the final renaming is

    diff_tree() -> ll_diff_tree_sha1()

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