Skip to content

Commit 666f53e

Browse files
avargitster
authored andcommitted
{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 f8adbec (cache.h: flip NO_THE_INDEX_COMPATIBILITY_MACROS switch, 2019-01-24). Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0ea414a commit 666f53e

File tree

6 files changed

+10
-6
lines changed

6 files changed

+10
-6
lines changed

builtin/cat-file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (C) Linus Torvalds, 2005
55
*/
6-
#define USE_THE_INDEX_COMPATIBILITY_MACROS
6+
#define USE_THE_INDEX_VARIABLE
77
#include "cache.h"
88
#include "config.h"
99
#include "builtin.h"

builtin/difftool.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
* Copyright (C) 2016 Johannes Schindelin
1313
*/
14-
#define USE_THE_INDEX_COMPATIBILITY_MACROS
14+
#define USE_THE_INDEX_VARIABLE
1515
#include "cache.h"
1616
#include "config.h"
1717
#include "builtin.h"

builtin/merge-tree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#define USE_THE_INDEX_COMPATIBILITY_MACROS
1+
#define USE_THE_INDEX_VARIABLE
22
#include "builtin.h"
33
#include "tree-walk.h"
44
#include "xdiff-interface.h"

builtin/pull.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* Fetch one or more remote refs and merge it/them into the current HEAD.
77
*/
8-
#define USE_THE_INDEX_COMPATIBILITY_MACROS
8+
#define USE_THE_INDEX_VARIABLE
99
#include "cache.h"
1010
#include "config.h"
1111
#include "builtin.h"

cache.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,9 +433,11 @@ typedef int (*must_prefetch_predicate)(const struct cache_entry *);
433433
void prefetch_cache_entries(const struct index_state *istate,
434434
must_prefetch_predicate must_prefetch);
435435

436-
#ifdef USE_THE_INDEX_COMPATIBILITY_MACROS
436+
#if defined(USE_THE_INDEX_COMPATIBILITY_MACROS) || defined(USE_THE_INDEX_VARIABLE)
437437
extern struct index_state the_index;
438438

439+
#ifndef USE_THE_INDEX_VARIABLE
440+
#ifdef USE_THE_INDEX_COMPATIBILITY_MACROS
439441
#define active_nr (the_index.cache_nr)
440442

441443
#define read_cache() repo_read_index(the_repository)
@@ -447,6 +449,8 @@ extern struct index_state the_index;
447449
#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)
448450
#define hold_locked_index(lock_file, flags) repo_hold_locked_index(the_repository, (lock_file), (flags))
449451
#endif
452+
#endif
453+
#endif
450454

451455
#define TYPE_BITS 3
452456

repository.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* not really _using_ the compat macros, just make sure the_index
33
* declaration matches the definition in this file.
44
*/
5-
#define USE_THE_INDEX_COMPATIBILITY_MACROS
5+
#define USE_THE_INDEX_VARIABLE
66
#include "cache.h"
77
#include "repository.h"
88
#include "object-store.h"

0 commit comments

Comments
 (0)