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

[PATCH 5/5] diff-lib: drop unused index argument from get_stat_data()

From
Jeff King <peff@peff.net>
Date
Aug 17, 2024, 07:29 UTC
Message-ID
<20240817072949.GE1535915@coredump.intra.peff.net>
In-Reply-To
<20240817072621.GA1535666@coredump.intra.peff.net>

The "struct index_state" parameter passed to get_stat_data() has been unused since we stopped passing it to check_removed() in 6a044a2048 (diff-lib: fix check_removed when fsmonitor is on, 2023-09-11). We can just drop it, which in turns lets us simplify our callers a bit.

Signed-off-by: Jeff King <peff@peff.net>
---
 diff-lib.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/diff-lib.c b/diff-lib.c
index 7a1eb63757..a680768ee7 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -308,8 +308,7 @@ static void diff_index_show_file(struct rev_info *revs,
 		       oid, oid_valid, ce->name, dirty_submodule);
 }
 
-static int get_stat_data(const struct index_state *istate,
-			 const struct cache_entry *ce,
+static int get_stat_data(const struct cache_entry *ce,
 			 const struct object_id **oidp,
 			 unsigned int *modep,
 			 int cached, int match_missing,
@@ -352,7 +351,6 @@ static void show_new_file(struct rev_info *revs,
 	const struct object_id *oid;
 	unsigned int mode;
 	unsigned dirty_submodule = 0;
-	struct index_state *istate = revs->diffopt.repo->index;
 
 	if (new_file && S_ISSPARSEDIR(new_file->ce_mode)) {
 		diff_tree_oid(NULL, &new_file->oid, new_file->name, &revs->diffopt);
@@ -363,7 +361,7 @@ static void show_new_file(struct rev_info *revs,
 	 * New file in the index: it might actually be different in
 	 * the working tree.
 	 */
-	if (get_stat_data(istate, new_file, &oid, &mode, cached, match_missing,
+	if (get_stat_data(new_file, &oid, &mode, cached, match_missing,
 	    &dirty_submodule, &revs->diffopt) < 0)
 		return;
 
@@ -379,7 +377,6 @@ static int show_modified(struct rev_info *revs,
 	unsigned int mode, oldmode;
 	const struct object_id *oid;
 	unsigned dirty_submodule = 0;
-	struct index_state *istate = revs->diffopt.repo->index;
 
 	assert(S_ISSPARSEDIR(old_entry->ce_mode) ==
 	       S_ISSPARSEDIR(new_entry->ce_mode));
@@ -395,7 +392,7 @@ static int show_modified(struct rev_info *revs,
 		return 0;
 	}
 
-	if (get_stat_data(istate, new_entry, &oid, &mode, cached, match_missing,
+	if (get_stat_data(new_entry, &oid, &mode, cached, match_missing,
 			  &dirty_submodule, &revs->diffopt) < 0) {
 		if (report_missing)
 			diff_index_show_file(revs, "-", old_entry,
-- 
2.46.0.585.gd6679c16d8
Previous: Jeff King
Message 7 of 7 in “dropping some more unused parameters”
  1. 0/5 dropping some more unused parametersJeff King, Aug 17, 2024
  2. 1/5 refs: drop some unused parameters from create_symref_lock()Jeff King, Aug 17, 2024
  3. 2/5 pack-bitmap: load writer config from repository parameterJeff King, Aug 17, 2024
  4. Eric SunshineAug 17, 2024
  5. 3/5 pack-bitmap: drop unused parameters from select_pseudo_merges()Jeff King, Aug 17, 2024
  6. 4/5 ref-filter: drop unused parameters from email_atom_option_parser()Jeff King, Aug 17, 2024
  7. 5/5 diff-lib: drop unused index argument from get_stat_data()Jeff King, Aug 17, 2024

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.