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

[PATCH 2/3] submodule: used correct index in is_staging_gitmodules_ok

From
BWBrandon Williams <bmwill@google.com>
Date
Dec 12, 2017, 19:53 UTC
Message-ID
<20171212195352.146675-3-bmwill@google.com>
In-Reply-To
<20171212195352.146675-1-bmwill@google.com>

Commit 883e248b8 (fsmonitor: teach git to optionally utilize a file system monitor to speed up detecting new or changed files., 2017-09-22) introduced a call to 'ce_match_stat()' in 'is_staging_gitmodules_ok()' which implicitly relys on the the global 'the_index' instead of the passed in 'struct index_state'. Fix this by changing the call to 'ie_match_stat()' and using the passed in index_state struct.

Signed-off-by: Brandon Williams <bmwill@google.com>
---
 submodule.c | 5 +++--
 submodule.h | 2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/submodule.c b/submodule.c
index 7097be806..a9670eaae 100644
--- a/submodule.c
+++ b/submodule.c
@@ -55,14 +55,15 @@ int is_gitmodules_unmerged(const struct index_state *istate)
  * future version when we learn to stage the changes we do ourselves without
  * staging any previous modifications.
  */
-int is_staging_gitmodules_ok(const struct index_state *istate)
+int is_staging_gitmodules_ok(struct index_state *istate)
 {
 	int pos = index_name_pos(istate, GITMODULES_FILE, strlen(GITMODULES_FILE));
 
 	if ((pos >= 0) && (pos < istate->cache_nr)) {
 		struct stat st;
 		if (lstat(GITMODULES_FILE, &st) == 0 &&
-		    ce_match_stat(istate->cache[pos], &st, CE_MATCH_IGNORE_FSMONITOR) & DATA_CHANGED)
+		    ie_match_stat(istate, istate->cache[pos], &st,
+				  CE_MATCH_IGNORE_FSMONITOR) & DATA_CHANGED)
 			return 0;
 	}
 
diff --git a/submodule.h b/submodule.h
index cd984ecba..e2a5de3d8 100644
--- a/submodule.h
+++ b/submodule.h
@@ -34,7 +34,7 @@ struct submodule_update_strategy {
 #define SUBMODULE_UPDATE_STRATEGY_INIT {SM_UPDATE_UNSPECIFIED, NULL}
 
 extern int is_gitmodules_unmerged(const struct index_state *istate);
-extern int is_staging_gitmodules_ok(const struct index_state *istate);
+extern int is_staging_gitmodules_ok(struct index_state *istate);
 extern int update_path_in_gitmodules(const char *oldpath, const char *newpath);
 extern int remove_path_from_gitmodules(const char *path);
 extern void stage_updated_gitmodules(struct index_state *istate);
-- 
2.15.1.504.g5279b80103-goog
Previous: Brandon WilliamsNext: Eric Sunshine
Message 3 of 8 in “convert submodule.c to not use the index compat macros”
  1. 0/3 convert submodule.c to not use the index compat macrosBrandon Williams, Dec 12, 2017
  2. 1/3 submodule: convert stage_updated_gitmodules to take a struct index_stateBrandon Williams, Dec 12, 2017
  3. 2/3 submodule: used correct index in is_staging_gitmodules_okBrandon Williams, Dec 12, 2017
  4. Eric SunshineDec 12, 2017
  5. 3/3 submodule: convert get_next_submodule to not rely on the_indexBrandon Williams, Dec 12, 2017
  6. Stefan BellerDec 12, 2017
  7. Junio C HamanoDec 12, 2017
  8. Junio C HamanoDec 12, 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.