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

[PATCH 23/24] cache.h: drop ce_match_stat

From
Stefan Beller <sbeller@google.com>
Date
May 2, 2017, 22:23 UTC
Message-ID
<20170502222322.21055-24-sbeller@google.com>
In-Reply-To
<20170502222322.21055-1-sbeller@google.com>

coccinelle patch: @@ expression ce, st, options; @@ -ce_match_stat(ce, st, options) +ie_match_stat(&the_index, ce, st, options)

Additionally drop the define from cache.h manually.

Note that there is an empty define section in cache.h now. The cleanup of that is done in a later patch.

Signed-off-by: Stefan Beller <sbeller@google.com>
---
 apply.c                | 3 ++-
 builtin/rm.c           | 2 +-
 builtin/update-index.c | 2 +-
 cache.h                | 1 -
 check-racy.c           | 4 ++--
 diff-lib.c             | 2 +-
 diff.c                 | 2 +-
 entry.c                | 3 ++-
 submodule.c            | 2 +-
 9 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/apply.c b/apply.c
index 8a61f19d03..46bc5a20b9 100644
--- a/apply.c
+++ b/apply.c
@@ -3364,7 +3364,8 @@ static int verify_index_match(const struct cache_entry *ce, struct stat *st)
 			return -1;
 		return 0;
 	}
-	return ce_match_stat(ce, st, CE_MATCH_IGNORE_VALID|CE_MATCH_IGNORE_SKIP_WORKTREE);
+	return ie_match_stat(&the_index, ce, st,
+			     CE_MATCH_IGNORE_VALID | CE_MATCH_IGNORE_SKIP_WORKTREE);
 }
 
 #define SUBMODULE_PATCH_WITHOUT_INDEX 1
diff --git a/builtin/rm.c b/builtin/rm.c
index f479100298..51b64f2bae 100644
--- a/builtin/rm.c
+++ b/builtin/rm.c
@@ -163,7 +163,7 @@ static int check_local_mod(struct object_id *head, int index_only)
 		 * Is the index different from the file in the work tree?
 		 * If it's a submodule, is its work tree modified?
 		 */
-		if (ce_match_stat(ce, &st, 0) ||
+		if (ie_match_stat(&the_index, ce, &st, 0) ||
 		    (S_ISGITLINK(ce->ce_mode) &&
 		     bad_to_remove_submodule(ce->name,
 				SUBMODULE_REMOVAL_DIE_ON_ERROR |
diff --git a/builtin/update-index.c b/builtin/update-index.c
index 9cbd346f95..042f4c94cf 100644
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
@@ -268,7 +268,7 @@ static int add_one_path(const struct cache_entry *old, const char *path, int len
 	struct cache_entry *ce;
 
 	/* Was the old index entry already up-to-date? */
-	if (old && !ce_stage(old) && !ce_match_stat(old, st, 0))
+	if (old && !ce_stage(old) && !ie_match_stat(&the_index, old, st, 0))
 		return 0;
 
 	size = cache_entry_size(len);
diff --git a/cache.h b/cache.h
index c34fc4fd40..f2a45eda9a 100644
--- a/cache.h
+++ b/cache.h
@@ -354,7 +354,6 @@ extern void free_name_hash(struct index_state *istate);
 
 
 #ifndef NO_THE_INDEX_COMPATIBILITY_MACROS
-#define ce_match_stat(ce, st, options) ie_match_stat(&the_index, (ce), (st), (options))
 #endif
 
 enum object_type {
diff --git a/check-racy.c b/check-racy.c
index 6599ae84cf..485d7ab8f8 100644
--- a/check-racy.c
+++ b/check-racy.c
@@ -16,9 +16,9 @@ int main(int ac, char **av)
 			continue;
 		}
 
-		if (ce_match_stat(ce, &st, 0))
+		if (ie_match_stat(&the_index, ce, &st, 0))
 			dirty++;
-		else if (ce_match_stat(ce, &st, CE_MATCH_RACY_IS_DIRTY))
+		else if (ie_match_stat(&the_index, ce, &st, CE_MATCH_RACY_IS_DIRTY))
 			racy++;
 		else
 			clean++;
diff --git a/diff-lib.c b/diff-lib.c
index de59ec0459..4ca3ce9c90 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -69,7 +69,7 @@ static int match_stat_with_submodule(struct diff_options *diffopt,
 				     struct stat *st, unsigned ce_option,
 				     unsigned *dirty_submodule)
 {
-	int changed = ce_match_stat(ce, st, ce_option);
+	int changed = ie_match_stat(&the_index, ce, st, ce_option);
 	if (S_ISGITLINK(ce->ce_mode)) {
 		unsigned orig_flags = diffopt->flags;
 		if (!DIFF_OPT_TST(diffopt, OVERRIDE_SUBMODULE_CONFIG))
diff --git a/diff.c b/diff.c
index f2ee40fe21..bd1478f6c9 100644
--- a/diff.c
+++ b/diff.c
@@ -2782,7 +2782,7 @@ static int reuse_worktree_file(const char *name, const unsigned char *sha1, int
 	 * If ce matches the file in the work tree, we can reuse it.
 	 */
 	if (ce_uptodate(ce) ||
-	    (!lstat(name, &st) && !ce_match_stat(ce, &st, 0)))
+	    (!lstat(name, &st) && !ie_match_stat(&the_index, ce, &st, 0)))
 		return 1;
 
 	return 0;
diff --git a/entry.c b/entry.c
index d2b512da90..d3a34c9cc4 100644
--- a/entry.c
+++ b/entry.c
@@ -266,7 +266,8 @@ int checkout_entry(struct cache_entry *ce,
 
 	if (!check_path(path.buf, path.len, &st, state->base_dir_len)) {
 		const struct submodule *sub;
-		unsigned changed = ce_match_stat(ce, &st, CE_MATCH_IGNORE_VALID|CE_MATCH_IGNORE_SKIP_WORKTREE);
+		unsigned changed = ie_match_stat(&the_index, ce, &st,
+						 CE_MATCH_IGNORE_VALID | CE_MATCH_IGNORE_SKIP_WORKTREE);
 		/*
 		 * Needs to be checked before !changed returns early,
 		 * as the possibly empty directory was not changed
diff --git a/submodule.c b/submodule.c
index 6587bc0d84..43997f237e 100644
--- a/submodule.c
+++ b/submodule.c
@@ -191,7 +191,7 @@ void gitmodules_config(void)
 		} else if (pos < the_index.cache_nr) {
 			struct stat st;
 			if (lstat(".gitmodules", &st) == 0 &&
-			    ce_match_stat(the_index.cache[pos], &st, 0) & DATA_CHANGED)
+			    ie_match_stat(&the_index, the_index.cache[pos], &st, 0) & DATA_CHANGED)
 				gitmodules_is_modified = 1;
 		}
 
-- 
2.13.0.rc1.39.ga6db8bfa24
Previous: Stefan BellerNext: Stefan Beller
Message 18 of 25 in “Retire NO_THE_INDEX_COMPATIBILITY_MACROS”
  1. 00/24 Retire NO_THE_INDEX_COMPATIBILITY_MACROSStefan Beller, May 2, 2017
  2. 01/24 cache.h: drop read_cache()Stefan Beller, May 2, 2017
  3. 03/24 cache.h: drop read_cache_fromStefan Beller, May 2, 2017
  4. 02/24 cache.h: drop active_* macrosStefan Beller, May 2, 2017
  5. 06/24 unpack-trees.c: rename parameter 'the_index'Stefan Beller, May 2, 2017
  6. 04/24 cache.h: drop read_cache_preload(pathspec)Stefan Beller, May 2, 2017
  7. 07/24 cache.h: drop read_blob_data_from_cacheStefan Beller, May 2, 2017
  8. 05/24 cache.h: drop read_cache_unmerged()Stefan Beller, May 2, 2017
  9. 10/24 cache.h: drop cache_name_is_otherStefan Beller, May 2, 2017
  10. 12/24 cache.h: drop cache_dir_existsStefan Beller, May 2, 2017
  11. 11/24 cache.h: drop cache_file_existsStefan Beller, May 2, 2017
  12. 13/24 cache.h: drop is_cache_unborn(), discard_cache(), unmerged_cache()Stefan Beller, May 2, 2017
  13. 09/24 cache.h: drop resolve_undo_clearStefan Beller, May 2, 2017
  14. 08/24 cache.h: drop unmerge_cache[_entry_at]Stefan Beller, May 2, 2017
  15. 14/24 cache.h: drop cache_name_posStefan Beller, May 2, 2017
  16. 22/24 cache.h: drop ce_modifiedStefan Beller, May 2, 2017
  17. 20/24 cache.h: drop chmod_cache_entryStefan Beller, May 2, 2017
  18. 23/24 cache.h: drop ce_match_statStefan Beller, May 2, 2017
  19. 24/24 cache.h: retire NO_THE_INDEX_COMPATIBILITY_MACROSStefan Beller, May 2, 2017
  20. 21/24 cache.h: drop refresh_cacheStefan Beller, May 2, 2017
  21. 19/24 cache.h: drop add_file_to_cacheStefan Beller, May 2, 2017
  22. 18/24 cache.h: drop add_to_cacheStefan Beller, May 2, 2017
  23. 17/24 cache.h: drop remove_file_from_cacheStefan Beller, May 2, 2017
  24. 16/24 cache.h: drop rename_cache_entry_atStefan Beller, May 2, 2017
  25. 15/24 cache.h: drop add_cache_entryStefan Beller, May 2, 2017

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.