From 666f53eb43f52216d03d579b91a2152ba7821773 Mon Sep 17 00:00:00 2001 From: Ævar Arnfjörð Bjarmason Date: Sat, 19 Nov 2022 14:07:36 +0100 Subject: {builtin/*,repository}.c: add & use "USE_THE_INDEX_VARIABLE" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Split up the "USE_THE_INDEX_COMPATIBILITY_MACROS" into that setting and a more narrow "USE_THE_INDEX_VARIABLE". In the case of these built-ins we only need "the_index" variable, but not the compatibility wrapper for functions we're not using. Let's then have some users of "USE_THE_INDEX_COMPATIBILITY_MACROS" use this more narrow and descriptive define. For context: The USE_THE_INDEX_COMPATIBILITY_MACROS macro was added to test-tool.h in f8adbec9fea (cache.h: flip NO_THE_INDEX_COMPATIBILITY_MACROS switch, 2019-01-24). Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- cache.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'cache.h') diff --git a/cache.h b/cache.h index 805e25f9a6..707806d212 100644 --- a/cache.h +++ b/cache.h @@ -433,9 +433,11 @@ typedef int (*must_prefetch_predicate)(const struct cache_entry *); void prefetch_cache_entries(const struct index_state *istate, must_prefetch_predicate must_prefetch); -#ifdef USE_THE_INDEX_COMPATIBILITY_MACROS +#if defined(USE_THE_INDEX_COMPATIBILITY_MACROS) || defined(USE_THE_INDEX_VARIABLE) extern struct index_state the_index; +#ifndef USE_THE_INDEX_VARIABLE +#ifdef USE_THE_INDEX_COMPATIBILITY_MACROS #define active_nr (the_index.cache_nr) #define read_cache() repo_read_index(the_repository) @@ -447,6 +449,8 @@ extern struct index_state the_index; #define refresh_and_write_cache(refresh_flags, write_flags, gentle) repo_refresh_and_write_index(the_repository, (refresh_flags), (write_flags), (gentle), NULL, NULL, NULL) #define hold_locked_index(lock_file, flags) repo_hold_locked_index(the_repository, (lock_file), (flags)) #endif +#endif +#endif #define TYPE_BITS 3 -- cgit v1.3-5-g9baa