]> git.ipfire.org Git - thirdparty/git.git/commitdiff
{builtin/*,repository}.c: add & use "USE_THE_INDEX_VARIABLE"
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Sat, 19 Nov 2022 13:07:36 +0000 (14:07 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 21 Nov 2022 03:06:15 +0000 (12:06 +0900)
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 <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/cat-file.c
builtin/difftool.c
builtin/merge-tree.c
builtin/pull.c
cache.h
repository.c

index fa7bd89169205b4c3c1ff6d6813330278cc7539f..b3be58b1fb06678376568753f9fc221d8cfb3750 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (C) Linus Torvalds, 2005
  */
-#define USE_THE_INDEX_COMPATIBILITY_MACROS
+#define USE_THE_INDEX_VARIABLE
 #include "cache.h"
 #include "config.h"
 #include "builtin.h"
index d7f08c8a7fa201750465d37a3b6b8fbb7b91ac6a..d9b76226f6a8dd4f256a902c02cde05bd7399293 100644 (file)
@@ -11,7 +11,7 @@
  *
  * Copyright (C) 2016 Johannes Schindelin
  */
-#define USE_THE_INDEX_COMPATIBILITY_MACROS
+#define USE_THE_INDEX_VARIABLE
 #include "cache.h"
 #include "config.h"
 #include "builtin.h"
index fe853aa8f9147b540d5427af33cec824a54de3df..e3767087bbfdeb065e9a2806df4ba99b922eb2ec 100644 (file)
@@ -1,4 +1,4 @@
-#define USE_THE_INDEX_COMPATIBILITY_MACROS
+#define USE_THE_INDEX_VARIABLE
 #include "builtin.h"
 #include "tree-walk.h"
 #include "xdiff-interface.h"
index 4a2a6db2dce2022d1d0770ba1fa1562129081d9c..1ab4de0005da3f6d2aa4b6a93d61544818af8700 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Fetch one or more remote refs and merge it/them into the current HEAD.
  */
-#define USE_THE_INDEX_COMPATIBILITY_MACROS
+#define USE_THE_INDEX_VARIABLE
 #include "cache.h"
 #include "config.h"
 #include "builtin.h"
diff --git a/cache.h b/cache.h
index 805e25f9a67a07e2e2633e34823f2072717e7fb0..707806d21255259a620c441321fb6ab3a01d7bbb 100644 (file)
--- 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
 
index 5d166b692c8aa8ec24bbbde90cab1279ed2bdf53..3427085fd6d2e44fa32c3e0ebc4ffba7a4c8286f 100644 (file)
@@ -2,7 +2,7 @@
  * not really _using_ the compat macros, just make sure the_index
  * declaration matches the definition in this file.
  */
-#define USE_THE_INDEX_COMPATIBILITY_MACROS
+#define USE_THE_INDEX_VARIABLE
 #include "cache.h"
 #include "repository.h"
 #include "object-store.h"