{builtin/*,repository}.c: add & use "USE_THE_INDEX_VARIABLE"
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>
Ævar Arnfjörð Bjarmason committed
Nov 19, 2022 at 14:07 UTC
666f53eb43f52216d03d579b91a2152ba7821773
6 files changed
+10
-6
builtin/cat-file.c
+1
-1
@@ -3,7 +3,7 @@
3
*
4
* Copyright (C) Linus Torvalds, 2005
5
*/
6
-#define USE_THE_INDEX_COMPATIBILITY_MACROS
6
+#define USE_THE_INDEX_VARIABLE
7
#include "cache.h"
8
#include "config.h"
9
#include "builtin.h"
builtin/difftool.c
+1
-1
@@ -11,7 +11,7 @@
11
*
12
* Copyright (C) 2016 Johannes Schindelin
13
*/
14
-#define USE_THE_INDEX_COMPATIBILITY_MACROS
14
+#define USE_THE_INDEX_VARIABLE
15
#include "cache.h"
16
#include "config.h"
17
#include "builtin.h"
builtin/merge-tree.c
+1
-1
@@ -1,4 +1,4 @@
1
-#define USE_THE_INDEX_COMPATIBILITY_MACROS
1
+#define USE_THE_INDEX_VARIABLE
2
#include "builtin.h"
3
#include "tree-walk.h"
4
#include "xdiff-interface.h"
builtin/pull.c
+1
-1
@@ -5,7 +5,7 @@
5
*
6
* Fetch one or more remote refs and merge it/them into the current HEAD.
7
*/
8
-#define USE_THE_INDEX_COMPATIBILITY_MACROS
8
+#define USE_THE_INDEX_VARIABLE
9
#include "cache.h"
10
#include "config.h"
11
#include "builtin.h"
cache.h
+5
-1
@@ -433,9 +433,11 @@ typedef int (*must_prefetch_predicate)(const struct cache_entry *);
433
void prefetch_cache_entries(const struct index_state *istate,
434
must_prefetch_predicate must_prefetch);
435
436
-#ifdef USE_THE_INDEX_COMPATIBILITY_MACROS
436
+#if defined(USE_THE_INDEX_COMPATIBILITY_MACROS) || defined(USE_THE_INDEX_VARIABLE)
437
extern struct index_state the_index;
438
439
+#ifndef USE_THE_INDEX_VARIABLE
440
+#ifdef USE_THE_INDEX_COMPATIBILITY_MACROS
441
#define active_nr (the_index.cache_nr)
442
443
#define read_cache() repo_read_index(the_repository)
@@ -447,6 +449,8 @@ extern struct index_state the_index;
449
#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)
450
#define hold_locked_index(lock_file, flags) repo_hold_locked_index(the_repository, (lock_file), (flags))
451
#endif
452
+#endif
453
+#endif
454
455
#define TYPE_BITS 3
456
repository.c
+1
-1
@@ -2,7 +2,7 @@
2
* not really _using_ the compat macros, just make sure the_index
3
* declaration matches the definition in this file.
4
*/
5
-#define USE_THE_INDEX_COMPATIBILITY_MACROS
5
+#define USE_THE_INDEX_VARIABLE
6
#include "cache.h"
7
#include "repository.h"
8
#include "object-store.h"