diff mbox series

[v2,05/11] cocci: add a index-compatibility.pending.cocci

Message ID patch-v2-05.11-ec740a81d9f-20221119T125551Z-avarab@gmail.com (mailing list archive)
State Accepted
Commit 0e6550a2c631e032c1c283398e50e9e654c171f0
Headers show
Series tree-wide: chip away at USE_THE_INDEX_COMPATIBILITY_MACROS | expand

Commit Message

Ævar Arnfjörð Bjarmason Nov. 19, 2022, 1:07 p.m. UTC
Add a coccinelle rule which covers the rest of the macros guarded by
"USE_THE_INDEX_COMPATIBILITY_MACROS" cache.h. If the result of this
were applied it can be reduced down to just:

	#ifdef USE_THE_INDEX_COMPATIBILITY_MACROS
	extern struct index_state the_index;
	#endif

But that patch is just under 2000 lines, so let's first add this as a
"pending", and then incrementally pick changes from it in subsequent
commits. In doing that we'll migrate rules from this
"index-compatibility.pending.cocci" to the "index-compatibility.cocci"
created in a preceding commit.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 .../index-compatibility.pending.cocci         | 110 ++++++++++++++++++
 1 file changed, 110 insertions(+)
 create mode 100644 contrib/coccinelle/index-compatibility.pending.cocci
diff mbox series

Patch

diff --git a/contrib/coccinelle/index-compatibility.pending.cocci b/contrib/coccinelle/index-compatibility.pending.cocci
new file mode 100644
index 00000000000..6e96de0f638
--- /dev/null
+++ b/contrib/coccinelle/index-compatibility.pending.cocci
@@ -0,0 +1,110 @@ 
+// the_index.* variables
+@@
+@@
+(
+- active_cache
++ the_index.cache
+|
+- active_nr
++ the_index.cache_nr
+|
+- active_cache_changed
++ the_index.cache_changed
+|
+- active_cache_tree
++ the_index.cache_tree
+)
+
+// "the_repository" simple cases
+@@
+@@
+(
+- read_cache
++ repo_read_index
+|
+- hold_locked_index
++ repo_hold_locked_index
+)
+  (
++ the_repository,
+  ...)
+
+// "the_index" simple cases
+@@
+@@
+(
+- discard_cache
++ discard_index
+|
+- cache_name_pos
++ index_name_pos
+|
+- add_cache_entry
++ add_index_entry
+|
+- remove_file_from_cache
++ remove_file_from_index
+|
+- ce_match_stat
++ ie_match_stat
+|
+- ce_modified
++ ie_modified
+|
+- resolve_undo_clear
++ resolve_undo_clear_index
+)
+  (
++ &the_index,
+  ...)
+
+// "the_repository" special-cases
+@@
+@@
+(
+- read_cache_preload
++ repo_read_index_preload
+)
+  (
++ the_repository,
+  ...
++ , 0
+  )
+
+@@
+@@
+(
+- refresh_and_write_cache
++ repo_refresh_and_write_index
+)
+  (
++ the_repository,
+  ...
++ , NULL, NULL, NULL
+  )
+
+
+// "the_index" special-cases
+@@
+@@
+(
+- read_cache_from
++ read_index_from
+)
+  (
++ &the_index,
+  ...
++ , get_git_dir()
+  )
+
+@@
+@@
+(
+- refresh_cache
++ refresh_index
+)
+  (
++ &the_index,
+  ...
++ , NULL, NULL, NULL
+  )