]> git.ipfire.org Git - thirdparty/git.git/commitdiff
rebase: use 'skip_cache_tree_update' option
authorVictoria Dye <vdye@github.com>
Thu, 10 Nov 2022 19:06:05 +0000 (19:06 +0000)
committerTaylor Blau <me@ttaylorr.com>
Fri, 11 Nov 2022 02:49:34 +0000 (21:49 -0500)
Enable the 'skip_cache_tree_update' option in both 'do_reset()'
('sequencer.c') and 'reset_head()' ('reset.c'). Both of these callers invoke
'prime_cache_tree()' after 'unpack_trees()', so we can remove an unnecessary
cache tree rebuild by skipping 'cache_tree_update()'.

When testing with 'p3400-rebase.sh' and 'p3404-rebase-interactive.sh', the
performance change of this update was negligible, likely due to the
operation being dominated by more expensive operations (like checking out
trees). However, since the change doesn't harm performance, it's worth
keeping this 'unpack_trees()' usage consistent with others that subsequently
invoke 'prime_cache_tree()'.

Signed-off-by: Victoria Dye <vdye@github.com>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
reset.c
sequencer.c

diff --git a/reset.c b/reset.c
index e3383a93343e3df16ee9eda6ee7886a49e980a1a..5ded23611f3f7316e2327872a54474ce6e4f6200 100644 (file)
--- a/reset.c
+++ b/reset.c
@@ -128,6 +128,7 @@ int reset_head(struct repository *r, const struct reset_head_opts *opts)
        unpack_tree_opts.update = 1;
        unpack_tree_opts.merge = 1;
        unpack_tree_opts.preserve_ignored = 0; /* FIXME: !overwrite_ignore */
+       unpack_tree_opts.skip_cache_tree_update = 1;
        init_checkout_metadata(&unpack_tree_opts.meta, switch_to_branch, oid, NULL);
        if (reset_hard)
                unpack_tree_opts.reset = UNPACK_RESET_PROTECT_UNTRACKED;
index f0f1af4d4784b4ad7536a0a3de2857ab1dc8ca27..0c60800ad1e26fc72cf66007504ad46eedc6bee1 100644 (file)
@@ -3748,6 +3748,7 @@ static int do_reset(struct repository *r,
        unpack_tree_opts.merge = 1;
        unpack_tree_opts.update = 1;
        unpack_tree_opts.preserve_ignored = 0; /* FIXME: !overwrite_ignore */
+       unpack_tree_opts.skip_cache_tree_update = 1;
        init_checkout_metadata(&unpack_tree_opts.meta, name, &oid, NULL);
 
        if (repo_read_index_unmerged(r)) {