Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>2023-02-10 13:28:38 +0300
committerJunio C Hamano <gitster@pobox.com>2023-02-10 22:38:14 +0300
commitfcb864bce70573380e6409c4ca25d1bdf16b0841 (patch)
treea443ad93e150ee0aa0e5c8a1111fa35dc092ce7c
parent99370863e20131627f0ea0481b7006d0d2125c93 (diff)
cache-tree API: remove redundant update_main_cache_tree()
Remove the redundant update_main_cache_tree() function, and make its users use cache_tree_update() instead. The behavior of populating the "the_index.cache_tree" if it wasn't present already was needed when this function was introduced in [1], but it hasn't been needed since [2]; The "cache_tree_update()" will now lazy-allocate, so there's no need for the wrapper. 1. 996277c5206 (Refactor cache_tree_update idiom from commit, 2011-12-06) 2. fb0882648e0 (cache-tree: clean up cache_tree_update(), 2021-01-23) Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--builtin/commit.c10
-rw-r--r--cache-tree.h10
-rw-r--r--contrib/coccinelle/index-compatibility.cocci3
3 files changed, 8 insertions, 15 deletions
diff --git a/builtin/commit.c b/builtin/commit.c
index 57a95123df..31fbbd73d1 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -414,7 +414,7 @@ static const char *prepare_index(const char **argv, const char *prefix,
discard_index(&the_index);
read_index_from(&the_index, get_lock_file_path(&index_lock),
get_git_dir());
- if (update_main_cache_tree(WRITE_TREE_SILENT) == 0) {
+ if (cache_tree_update(&the_index, WRITE_TREE_SILENT) == 0) {
if (reopen_lock_file(&index_lock) < 0)
die(_("unable to write index file"));
if (write_locked_index(&the_index, &index_lock, 0))
@@ -444,7 +444,7 @@ static const char *prepare_index(const char **argv, const char *prefix,
LOCK_DIE_ON_ERROR);
add_files_to_cache(also ? prefix : NULL, &pathspec, 0);
refresh_cache_or_die(refresh_flags);
- update_main_cache_tree(WRITE_TREE_SILENT);
+ cache_tree_update(&the_index, WRITE_TREE_SILENT);
if (write_locked_index(&the_index, &index_lock, 0))
die(_("unable to write new_index file"));
commit_style = COMMIT_NORMAL;
@@ -467,7 +467,7 @@ static const char *prepare_index(const char **argv, const char *prefix,
refresh_cache_or_die(refresh_flags);
if (the_index.cache_changed
|| !cache_tree_fully_valid(the_index.cache_tree))
- update_main_cache_tree(WRITE_TREE_SILENT);
+ cache_tree_update(&the_index, WRITE_TREE_SILENT);
if (write_locked_index(&the_index, &index_lock,
COMMIT_LOCK | SKIP_IF_UNCHANGED))
die(_("unable to write new_index file"));
@@ -516,7 +516,7 @@ static const char *prepare_index(const char **argv, const char *prefix,
repo_hold_locked_index(the_repository, &index_lock, LOCK_DIE_ON_ERROR);
add_remove_files(&partial);
refresh_index(&the_index, REFRESH_QUIET, NULL, NULL, NULL);
- update_main_cache_tree(WRITE_TREE_SILENT);
+ cache_tree_update(&the_index, WRITE_TREE_SILENT);
if (write_locked_index(&the_index, &index_lock, 0))
die(_("unable to write new_index file"));
@@ -1079,7 +1079,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
}
read_index_from(&the_index, index_file, get_git_dir());
- if (update_main_cache_tree(0)) {
+ if (cache_tree_update(&the_index, 0)) {
error(_("Error building trees"));
return 0;
}
diff --git a/cache-tree.h b/cache-tree.h
index 84890c9ff3..bd97caa07b 100644
--- a/cache-tree.h
+++ b/cache-tree.h
@@ -53,14 +53,4 @@ int write_index_as_tree(struct object_id *oid, struct index_state *index_state,
void prime_cache_tree(struct repository *, struct index_state *, struct tree *);
int cache_tree_matches_traversal(struct cache_tree *, struct name_entry *ent, struct traverse_info *info);
-
-#ifdef USE_THE_INDEX_COMPATIBILITY_MACROS
-static inline int update_main_cache_tree(int flags)
-{
- if (!the_index.cache_tree)
- the_index.cache_tree = cache_tree();
- return cache_tree_update(&the_index, flags);
-}
-#endif
-
#endif
diff --git a/contrib/coccinelle/index-compatibility.cocci b/contrib/coccinelle/index-compatibility.cocci
index e245d805dc..9fca870162 100644
--- a/contrib/coccinelle/index-compatibility.cocci
+++ b/contrib/coccinelle/index-compatibility.cocci
@@ -94,6 +94,9 @@ identifier ACT = active_cache_tree;
|
- cache_name_pos
+ index_name_pos
+|
+- update_main_cache_tree
++ cache_tree_update
)
(
+ &the_index,