Skip to content

Commit dfd0a89

Browse files
avargitster
authored andcommitted
cocci & cache.h: remove "USE_THE_INDEX_COMPATIBILITY_MACROS"
Have the last users of "USE_THE_INDEX_COMPATIBILITY_MACROS" use the underlying *_index() variants instead. Now all previous users of "USE_THE_INDEX_COMPATIBILITY_MACROS" have been migrated away from the wrapper macros, and if applicable to use the "USE_THE_INDEX_VARIABLE" added in [1]. Let's leave the "index-compatibility.cocci" in place, even though it won't be doing anything on "master". It will benefit any out-of-tree code that need to use these compatibility macros. We can eventually remove it. 1. bdafeae (cache.h & test-tool.h: add & use "USE_THE_INDEX_VARIABLE", 2022-11-19) Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fcb864b commit dfd0a89

File tree

5 files changed

+13
-35
lines changed

5 files changed

+13
-35
lines changed

builtin/commit.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Based on git-commit.sh by Junio C Hamano and Linus Torvalds
66
*/
77

8-
#define USE_THE_INDEX_COMPATIBILITY_MACROS
8+
#define USE_THE_INDEX_VARIABLE
99
#include "cache.h"
1010
#include "config.h"
1111
#include "lockfile.h"
@@ -992,8 +992,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
992992
const char *parent = "HEAD";
993993

994994
if (!the_index.cache_nr) {
995-
discard_cache();
996-
if (read_cache() < 0)
995+
discard_index(&the_index);
996+
if (repo_read_index(the_repository) < 0)
997997
die(_("Cannot read index"));
998998
}
999999

builtin/merge.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Based on git-merge.sh by Junio C Hamano.
77
*/
88

9-
#define USE_THE_INDEX_COMPATIBILITY_MACROS
9+
#define USE_THE_INDEX_VARIABLE
1010
#include "cache.h"
1111
#include "config.h"
1212
#include "parse-options.h"
@@ -390,8 +390,8 @@ static void restore_state(const struct object_id *head,
390390
run_command(&cmd);
391391

392392
refresh_cache:
393-
discard_cache();
394-
if (read_cache() < 0)
393+
discard_index(&the_index);
394+
if (repo_read_index(the_repository) < 0)
395395
die(_("could not read index"));
396396
}
397397

cache.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -449,15 +449,8 @@ typedef int (*must_prefetch_predicate)(const struct cache_entry *);
449449
void prefetch_cache_entries(const struct index_state *istate,
450450
must_prefetch_predicate must_prefetch);
451451

452-
#if defined(USE_THE_INDEX_COMPATIBILITY_MACROS) || defined(USE_THE_INDEX_VARIABLE)
452+
#ifdef USE_THE_INDEX_VARIABLE
453453
extern struct index_state the_index;
454-
455-
#ifndef USE_THE_INDEX_VARIABLE
456-
#ifdef USE_THE_INDEX_COMPATIBILITY_MACROS
457-
#define read_cache() repo_read_index(the_repository)
458-
#define discard_cache() discard_index(&the_index)
459-
#endif
460-
#endif
461454
#endif
462455

463456
#define TYPE_BITS 3

contrib/coccinelle/index-compatibility.cocci

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ identifier ACT = active_cache_tree;
2323
@@
2424
@@
2525
(
26+
- read_cache
27+
+ repo_read_index
28+
|
2629
- read_cache_unmerged
2730
+ repo_read_index_unmerged
2831
|
@@ -97,6 +100,9 @@ identifier ACT = active_cache_tree;
97100
|
98101
- update_main_cache_tree
99102
+ cache_tree_update
103+
|
104+
- discard_cache
105+
+ discard_index
100106
)
101107
(
102108
+ &the_index,

contrib/coccinelle/index-compatibility.pending.cocci

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)