git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: git@vger.kernel.org
Cc: "Taylor Blau" <me@ttaylorr.com>,
	"Junio C Hamano" <gitster@pobox.com>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: [PATCH 09/12] {builtin/*,repository}.c: add & use "USE_THE_INDEX_VARIABLE"
Date: Fri, 18 Nov 2022 12:31:03 +0100	[thread overview]
Message-ID: <patch-09.12-5b69cfa17ad-20221118T112205Z-avarab@gmail.com> (raw)
In-Reply-To: <cover-00.12-00000000000-20221118T112205Z-avarab@gmail.com>

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.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/cat-file.c   | 2 +-
 builtin/difftool.c   | 2 +-
 builtin/merge-tree.c | 2 +-
 builtin/pull.c       | 2 +-
 cache.h              | 6 +++++-
 repository.c         | 2 +-
 6 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index fa7bd891692..b3be58b1fb0 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -3,7 +3,7 @@
  *
  * Copyright (C) Linus Torvalds, 2005
  */
-#define USE_THE_INDEX_COMPATIBILITY_MACROS
+#define USE_THE_INDEX_VARIABLE
 #include "cache.h"
 #include "config.h"
 #include "builtin.h"
diff --git a/builtin/difftool.c b/builtin/difftool.c
index d7f08c8a7fa..d9b76226f6a 100644
--- a/builtin/difftool.c
+++ b/builtin/difftool.c
@@ -11,7 +11,7 @@
  *
  * Copyright (C) 2016 Johannes Schindelin
  */
-#define USE_THE_INDEX_COMPATIBILITY_MACROS
+#define USE_THE_INDEX_VARIABLE
 #include "cache.h"
 #include "config.h"
 #include "builtin.h"
diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c
index fe853aa8f91..e3767087bbf 100644
--- a/builtin/merge-tree.c
+++ b/builtin/merge-tree.c
@@ -1,4 +1,4 @@
-#define USE_THE_INDEX_COMPATIBILITY_MACROS
+#define USE_THE_INDEX_VARIABLE
 #include "builtin.h"
 #include "tree-walk.h"
 #include "xdiff-interface.h"
diff --git a/builtin/pull.c b/builtin/pull.c
index 4a2a6db2dce..1ab4de0005d 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -5,7 +5,7 @@
  *
  * Fetch one or more remote refs and merge it/them into the current HEAD.
  */
-#define USE_THE_INDEX_COMPATIBILITY_MACROS
+#define USE_THE_INDEX_VARIABLE
 #include "cache.h"
 #include "config.h"
 #include "builtin.h"
diff --git a/cache.h b/cache.h
index 8b54b627459..72c3d4e2ef5 100644
--- a/cache.h
+++ b/cache.h
@@ -433,9 +433,11 @@ typedef int (*must_prefetch_predicate)(const struct cache_entry *);
 void prefetch_cache_entries(const struct index_state *istate,
 			    must_prefetch_predicate must_prefetch);
 
-#ifdef USE_THE_INDEX_COMPATIBILITY_MACROS
+#if defined(USE_THE_INDEX_COMPATIBILITY_MACROS) || defined(USE_THE_INDEX_VARIABLE)
 extern struct index_state the_index;
 
+#ifndef USE_THE_INDEX_VARIABLE
+#ifdef USE_THE_INDEX_COMPATIBILITY_MACROS
 #define active_nr (the_index.cache_nr)
 #define active_cache_tree (the_index.cache_tree)
 
@@ -448,6 +450,8 @@ extern struct index_state the_index;
 #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)
 #define hold_locked_index(lock_file, flags) repo_hold_locked_index(the_repository, (lock_file), (flags))
 #endif
+#endif
+#endif
 
 #define TYPE_BITS 3
 
diff --git a/repository.c b/repository.c
index 5d166b692c8..3427085fd6d 100644
--- a/repository.c
+++ b/repository.c
@@ -2,7 +2,7 @@
  * not really _using_ the compat macros, just make sure the_index
  * declaration matches the definition in this file.
  */
-#define USE_THE_INDEX_COMPATIBILITY_MACROS
+#define USE_THE_INDEX_VARIABLE
 #include "cache.h"
 #include "repository.h"
 #include "object-store.h"
-- 
2.38.0.1511.gcdcff1f1dc2


  parent reply	other threads:[~2022-11-18 11:31 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-18 11:30 [PATCH 00/12] tree-wide: chip away at USE_THE_INDEX_COMPATIBILITY_MACROS Ævar Arnfjörð Bjarmason
2022-11-18 11:30 ` [PATCH 01/12] cache.h: remove unused "the_index" compat macros Ævar Arnfjörð Bjarmason
2022-11-18 11:30 ` [PATCH 02/12] builtin/{grep,log}.: don't define "USE_THE_INDEX_COMPATIBILITY_MACROS" Ævar Arnfjörð Bjarmason
2022-11-18 11:30 ` [PATCH 03/12] cocci & cache.h: remove rarely used "the_index" compat macros Ævar Arnfjörð Bjarmason
2022-11-18 11:30 ` [PATCH 04/12] read-cache API & users: make discard_index() return void Ævar Arnfjörð Bjarmason
2022-11-18 11:30 ` [PATCH 05/12] cocci: add a index-compatibility.pending.cocci Ævar Arnfjörð Bjarmason
2022-11-18 11:31 ` [PATCH 06/12] cocci & cache.h: apply a selection of "pending" index-compatibility Ævar Arnfjörð Bjarmason
2022-11-18 11:31 ` [PATCH 07/12] cocci & cache.h: apply variable section " Ævar Arnfjörð Bjarmason
2022-11-18 11:31 ` [PATCH 08/12] cocci: apply "pending" index-compatibility to "t/helper/*.c" Ævar Arnfjörð Bjarmason
2022-11-18 11:31 ` Ævar Arnfjörð Bjarmason [this message]
2022-11-18 18:41   ` [PATCH 09/12] {builtin/*,repository}.c: add & use "USE_THE_INDEX_VARIABLE" Taylor Blau
2022-11-18 11:31 ` [PATCH 10/12] cache.h & test-tool.h: " Ævar Arnfjörð Bjarmason
2022-11-18 18:41   ` Taylor Blau
2022-11-18 11:31 ` [PATCH 11/12] cocci: apply "pending" index-compatibility to some "builtin/*.c" Ævar Arnfjörð Bjarmason
2022-11-18 11:31 ` [PATCH 12/12] builtin/*: remove or amend "USE_THE_INDEX_COMPATIBILITY_MACROS" Ævar Arnfjörð Bjarmason
2022-11-18 18:42   ` Taylor Blau
2022-11-18 19:27     ` Ævar Arnfjörð Bjarmason
2022-11-18 23:04       ` Taylor Blau
2022-11-18 12:13 ` [PATCH 00/12] tree-wide: chip away at USE_THE_INDEX_COMPATIBILITY_MACROS Phillip Wood
2022-11-18 12:21   ` Ævar Arnfjörð Bjarmason
2022-11-19 13:07 ` [PATCH v2 00/11] " Ævar Arnfjörð Bjarmason
2022-11-19 13:07   ` [PATCH v2 01/11] cache.h: remove unused "the_index" compat macros Ævar Arnfjörð Bjarmason
2022-11-19 13:07   ` [PATCH v2 02/11] builtin/{grep,log}.: don't define "USE_THE_INDEX_COMPATIBILITY_MACROS" Ævar Arnfjörð Bjarmason
2022-11-19 13:07   ` [PATCH v2 03/11] cocci & cache.h: remove rarely used "the_index" compat macros Ævar Arnfjörð Bjarmason
2022-11-19 13:07   ` [PATCH v2 04/11] read-cache API & users: make discard_index() return void Ævar Arnfjörð Bjarmason
2022-11-19 13:07   ` [PATCH v2 05/11] cocci: add a index-compatibility.pending.cocci Ævar Arnfjörð Bjarmason
2022-11-19 13:07   ` [PATCH v2 06/11] cocci & cache.h: apply a selection of "pending" index-compatibility Ævar Arnfjörð Bjarmason
2022-11-19 13:07   ` [PATCH v2 07/11] cocci & cache.h: apply variable section " Ævar Arnfjörð Bjarmason
2022-11-19 13:07   ` [PATCH v2 08/11] cocci: apply "pending" index-compatibility to "t/helper/*.c" Ævar Arnfjörð Bjarmason
2022-11-19 13:07   ` [PATCH v2 09/11] {builtin/*,repository}.c: add & use "USE_THE_INDEX_VARIABLE" Ævar Arnfjörð Bjarmason
2022-11-19 13:07   ` [PATCH v2 10/11] cache.h & test-tool.h: " Ævar Arnfjörð Bjarmason
2022-11-19 13:07   ` [PATCH v2 11/11] cocci: apply "pending" index-compatibility to some "builtin/*.c" Ævar Arnfjörð Bjarmason

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=patch-09.12-5b69cfa17ad-20221118T112205Z-avarab@gmail.com \
    --to=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=me@ttaylorr.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).