git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 10/12] cache.h & test-tool.h: add & use "USE_THE_INDEX_VARIABLE"

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Nov 18, 2022, 11:31 UTC
Message-ID
<patch-10.12-9eda7916e75-20221118T112205Z-avarab@gmail.com>
In-Reply-To
<cover-00.12-00000000000-20221118T112205Z-avarab@gmail.com>

In a preceding commit we fully applied the "index-compatibility.pending.cocci" rule to "t/helper/*". Let's now stop defining "USE_THE_INDEX_COMPATIBILITY_MACROS" in test-tool.h itself, and instead instead move the define to the individual test helpers that need it. This mirrors how we do the same thing in the "builtin/" directory.

We could start using "USE_THE_INDEX_COMPATIBILITY_MACROS", but let's instead introduce a narrow version of it named "USE_THE_INDEX_VARIABLE". As the name suggests this doesn't give us any of the compatibility macros, but only "the_index" variable.

Eventually we'll move other outstanding users of "USE_THE_INDEX_COMPATIBILITY_MACROS" over to using 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>
---
 t/helper/test-dump-cache-tree.c      | 1 +
 t/helper/test-dump-split-index.c     | 1 +
 t/helper/test-dump-untracked-cache.c | 2 +-
 t/helper/test-fast-rebase.c          | 2 +-
 t/helper/test-lazy-init-name-hash.c  | 1 +
 t/helper/test-read-cache.c           | 1 +
 t/helper/test-scrap-cache-tree.c     | 1 +
 t/helper/test-write-cache.c          | 1 +
 8 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/t/helper/test-dump-cache-tree.c b/t/helper/test-dump-cache-tree.c
index 4bf8bc3df6e..454f17b1a0c 100644
--- a/t/helper/test-dump-cache-tree.c
+++ b/t/helper/test-dump-cache-tree.c
@@ -1,3 +1,4 @@
+#define USE_THE_INDEX_VARIABLE
 #include "test-tool.h"
 #include "cache.h"
 #include "tree.h"
diff --git a/t/helper/test-dump-split-index.c b/t/helper/test-dump-split-index.c
index a209880eb37..0ea97b84072 100644
--- a/t/helper/test-dump-split-index.c
+++ b/t/helper/test-dump-split-index.c
@@ -1,3 +1,4 @@
+#define USE_THE_INDEX_VARIABLE
 #include "test-tool.h"
 #include "cache.h"
 #include "split-index.h"
diff --git a/t/helper/test-dump-untracked-cache.c b/t/helper/test-dump-untracked-cache.c
index ffe34736e53..6d53683f13b 100644
--- a/t/helper/test-dump-untracked-cache.c
+++ b/t/helper/test-dump-untracked-cache.c
@@ -1,4 +1,4 @@
-#define USE_THE_INDEX_COMPATIBILITY_MACROS
+#define USE_THE_INDEX_VARIABLE
 #include "test-tool.h"
 #include "cache.h"
 #include "dir.h"
diff --git a/t/helper/test-fast-rebase.c b/t/helper/test-fast-rebase.c
index 9def2ba6889..efc82dd80c5 100644
--- a/t/helper/test-fast-rebase.c
+++ b/t/helper/test-fast-rebase.c
@@ -10,7 +10,7 @@
  * refactoring is the better route).
  */
 
-#define USE_THE_INDEX_COMPATIBILITY_MACROS
+#define USE_THE_INDEX_VARIABLE
 #include "test-tool.h"
 
 #include "cache-tree.h"
diff --git a/t/helper/test-lazy-init-name-hash.c b/t/helper/test-lazy-init-name-hash.c
index 7e8723a1900..ab86c14c8ba 100644
--- a/t/helper/test-lazy-init-name-hash.c
+++ b/t/helper/test-lazy-init-name-hash.c
@@ -1,3 +1,4 @@
+#define USE_THE_INDEX_VARIABLE
 #include "test-tool.h"
 #include "cache.h"
 #include "parse-options.h"
diff --git a/t/helper/test-read-cache.c b/t/helper/test-read-cache.c
index a089be9104c..23e9e27109f 100644
--- a/t/helper/test-read-cache.c
+++ b/t/helper/test-read-cache.c
@@ -1,3 +1,4 @@
+#define USE_THE_INDEX_VARIABLE
 #include "test-tool.h"
 #include "cache.h"
 #include "config.h"
diff --git a/t/helper/test-scrap-cache-tree.c b/t/helper/test-scrap-cache-tree.c
index 9206dee1fd2..a26107ed70a 100644
--- a/t/helper/test-scrap-cache-tree.c
+++ b/t/helper/test-scrap-cache-tree.c
@@ -1,3 +1,4 @@
+#define USE_THE_INDEX_VARIABLE
 #include "test-tool.h"
 #include "cache.h"
 #include "lockfile.h"
diff --git a/t/helper/test-write-cache.c b/t/helper/test-write-cache.c
index 66287d6d47d..7d45cd61e82 100644
--- a/t/helper/test-write-cache.c
+++ b/t/helper/test-write-cache.c
@@ -1,3 +1,4 @@
+#define USE_THE_INDEX_VARIABLE
 #include "test-tool.h"
 #include "cache.h"
 #include "lockfile.h"
-- 
2.38.0.1511.gcdcff1f1dc2
Previous: Taylor BlauNext: Taylor Blau
Message 12 of 32 in “tree-wide: chip away at USE_THE_INDEX_COMPATIBILITY_MACROS”
  1. 00/12 tree-wide: chip away at USE_THE_INDEX_COMPATIBILITY_MACROSÆvar Arnfjörð Bjarmason, Nov 18, 2022
  2. 01/12 cache.h: remove unused "the_index" compat macrosÆvar Arnfjörð Bjarmason, Nov 18, 2022
  3. 02/12 builtin/{grep,log}.: don't define "USE_THE_INDEX_COMPATIBILITY_MACROS"Ævar Arnfjörð Bjarmason, Nov 18, 2022
  4. 03/12 cocci & cache.h: remove rarely used "the_index" compat macrosÆvar Arnfjörð Bjarmason, Nov 18, 2022
  5. 04/12 read-cache API & users: make discard_index() return voidÆvar Arnfjörð Bjarmason, Nov 18, 2022
  6. 05/12 cocci: add a index-compatibility.pending.cocciÆvar Arnfjörð Bjarmason, Nov 18, 2022
  7. 06/12 cocci & cache.h: apply a selection of "pending" index-compatibilityÆvar Arnfjörð Bjarmason, Nov 18, 2022
  8. 07/12 cocci & cache.h: apply variable section of "pending" index-compatibilityÆvar Arnfjörð Bjarmason, Nov 18, 2022
  9. 08/12 cocci: apply "pending" index-compatibility to "t/helper/*.c"Ævar Arnfjörð Bjarmason, Nov 18, 2022
  10. 09/12 {builtin/*,repository}.c: add & use "USE_THE_INDEX_VARIABLE"Ævar Arnfjörð Bjarmason, Nov 18, 2022
  11. Taylor BlauNov 18, 2022
  12. 10/12 cache.h & test-tool.h: add & use "USE_THE_INDEX_VARIABLE"Ævar Arnfjörð Bjarmason, Nov 18, 2022
  13. Taylor BlauNov 18, 2022
  14. 12/12 builtin/*: remove or amend "USE_THE_INDEX_COMPATIBILITY_MACROS"Ævar Arnfjörð Bjarmason, Nov 18, 2022
  15. Taylor BlauNov 18, 2022
  16. Ævar Arnfjörð BjarmasonNov 18, 2022
  17. Taylor BlauNov 18, 2022
  18. 11/12 cocci: apply "pending" index-compatibility to some "builtin/*.c"Ævar Arnfjörð Bjarmason, Nov 18, 2022
  19. Phillip WoodNov 18, 2022
  20. Ævar Arnfjörð BjarmasonNov 18, 2022
  21. 00/11 tree-wide: chip away at USE_THE_INDEX_COMPATIBILITY_MACROSÆvar Arnfjörð Bjarmason, Nov 19, 2022
  22. 01/11 cache.h: remove unused "the_index" compat macrosÆvar Arnfjörð Bjarmason, Nov 19, 2022
  23. 02/11 builtin/{grep,log}.: don't define "USE_THE_INDEX_COMPATIBILITY_MACROS"Ævar Arnfjörð Bjarmason, Nov 19, 2022
  24. 03/11 cocci & cache.h: remove rarely used "the_index" compat macrosÆvar Arnfjörð Bjarmason, Nov 19, 2022
  25. 04/11 read-cache API & users: make discard_index() return voidÆvar Arnfjörð Bjarmason, Nov 19, 2022
  26. 05/11 cocci: add a index-compatibility.pending.cocciÆvar Arnfjörð Bjarmason, Nov 19, 2022
  27. 06/11 cocci & cache.h: apply a selection of "pending" index-compatibilityÆvar Arnfjörð Bjarmason, Nov 19, 2022
  28. 08/11 cocci: apply "pending" index-compatibility to "t/helper/*.c"Ævar Arnfjörð Bjarmason, Nov 19, 2022
  29. 07/11 cocci & cache.h: apply variable section of "pending" index-compatibilityÆvar Arnfjörð Bjarmason, Nov 19, 2022
  30. 09/11 {builtin/*,repository}.c: add & use "USE_THE_INDEX_VARIABLE"Ævar Arnfjörð Bjarmason, Nov 19, 2022
  31. 10/11 cache.h & test-tool.h: add & use "USE_THE_INDEX_VARIABLE"Ævar Arnfjörð Bjarmason, Nov 19, 2022
  32. 11/11 cocci: apply "pending" index-compatibility to some "builtin/*.c"Ævar Arnfjörð Bjarmason, Nov 19, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.