Skip to content

Commit 68fcd48

Browse files
vdyettaylorr
authored andcommitted
unpack-trees: add 'skip_cache_tree_update' option
Add (disabled by default) option to skip the 'cache_tree_update()' at the end of 'unpack_trees()'. In many cases, this cache tree update is redundant because the caller of 'unpack_trees()' immediately follows it with 'prime_cache_tree()', rebuilding the entire cache tree from scratch. While these operations aren't the most expensive part of operations like 'git reset', the duplicate calls still create a minor unnecessary slowdown. Introduce an option for callers to skip the 'cache_tree_update()' in 'unpack_trees()' if it is redundant (that is, if 'prime_cache_tree()' is called afterwards). At the moment, no 'unpack_trees()' callers use the new option; they will be updated in subsequent patches. Signed-off-by: Victoria Dye <[email protected]> Signed-off-by: Taylor Blau <[email protected]>
1 parent 94fcf0e commit 68fcd48

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

unpack-trees.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2043,7 +2043,8 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
20432043
if (!ret) {
20442044
if (git_env_bool("GIT_TEST_CHECK_CACHE_TREE", 0))
20452045
cache_tree_verify(the_repository, &o->result);
2046-
if (!cache_tree_fully_valid(o->result.cache_tree))
2046+
if (!o->skip_cache_tree_update &&
2047+
!cache_tree_fully_valid(o->result.cache_tree))
20472048
cache_tree_update(&o->result,
20482049
WRITE_TREE_SILENT |
20492050
WRITE_TREE_REPAIR);

unpack-trees.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ struct unpack_trees_options {
7171
quiet,
7272
exiting_early,
7373
show_all_errors,
74-
dry_run;
74+
dry_run,
75+
skip_cache_tree_update;
7576
enum unpack_trees_reset_type reset;
7677
const char *prefix;
7778
int cache_bottom;

0 commit comments

Comments
 (0)