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

[PATCH 4/5] cache.h: drop read_cache_preload(pathspec)

From
Stefan Beller <sbeller@google.com>
Date
May 1, 2017, 19:07 UTC
Message-ID
<20170501190719.10669-5-sbeller@google.com>
In-Reply-To
<20170501190719.10669-1-sbeller@google.com>

coccinelle patch: @@ expression E; @@ -read_cache_preload(E) +read_index_preload(&the_index, E)

Additionally manual editing:
* drop the define from cache.h.
* builtin/{commit,describe}.c were not picked up as we have NULL and
  the address of an expression. Converted them manually.
* builtin/diff{-files,-index}.c error messages converted as well.
Signed-off-by: Stefan Beller <sbeller@google.com>
---
 builtin/checkout.c     | 4 ++--
 builtin/commit.c       | 4 ++--
 builtin/describe.c     | 2 +-
 builtin/diff-files.c   | 4 ++--
 builtin/diff-index.c   | 4 ++--
 builtin/diff.c         | 8 ++++----
 builtin/update-index.c | 2 +-
 cache.h                | 1 -
 8 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 0aac616ad6..2328a475ea 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -295,7 +295,7 @@ static int checkout_paths(const struct checkout_opts *opts,
 	lock_file = xcalloc(1, sizeof(struct lock_file));
 
 	hold_locked_index(lock_file, LOCK_DIE_ON_ERROR);
-	if (read_cache_preload(&opts->pathspec) < 0)
+	if (read_index_preload(&the_index, &opts->pathspec) < 0)
 		return error(_("index file corrupt"));
 
 	if (opts->source_tree)
@@ -488,7 +488,7 @@ static int merge_working_tree(const struct checkout_opts *opts,
 	struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));
 
 	hold_locked_index(lock_file, LOCK_DIE_ON_ERROR);
-	if (read_cache_preload(NULL) < 0)
+	if (read_index_preload(&the_index, NULL) < 0)
 		return error(_("index file corrupt"));
 
 	resolve_undo_clear();
diff --git a/builtin/commit.c b/builtin/commit.c
index 65a04ac199..687e7c8a3a 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -346,7 +346,7 @@ static const char *prepare_index(int argc, const char **argv, const char *prefix
 		       PATHSPEC_PREFER_FULL,
 		       prefix, argv);
 
-	if (read_cache_preload(&pathspec) < 0)
+	if (read_index_preload(&the_index, &pathspec) < 0)
 		die(_("index file corrupt"));
 
 	if (interactive) {
@@ -1377,7 +1377,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
 		       PATHSPEC_PREFER_FULL,
 		       prefix, argv);
 
-	read_cache_preload(&s.pathspec);
+	read_index_preload(&the_index, &s.pathspec);
 	refresh_index(&the_index, REFRESH_QUIET|REFRESH_UNMERGED, &s.pathspec, NULL, NULL);
 
 	fd = hold_locked_index(&index_lock, 0);
diff --git a/builtin/describe.c b/builtin/describe.c
index a5cd8c513f..0229458ac6 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -531,7 +531,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
 			static struct lock_file index_lock;
 			int fd;
 
-			read_cache_preload(NULL);
+			read_index_preload(&the_index, NULL);
 			refresh_index(&the_index, REFRESH_QUIET|REFRESH_UNMERGED,
 				      NULL, NULL, NULL);
 			fd = hold_locked_index(&index_lock, 0);
diff --git a/builtin/diff-files.c b/builtin/diff-files.c
index 15c61fd8d1..d400d8c1fc 100644
--- a/builtin/diff-files.c
+++ b/builtin/diff-files.c
@@ -62,8 +62,8 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix)
 	    (rev.diffopt.output_format & DIFF_FORMAT_PATCH))
 		rev.combine_merges = rev.dense_combined_merges = 1;
 
-	if (read_cache_preload(&rev.diffopt.pathspec) < 0) {
-		perror("read_cache_preload");
+	if (read_index_preload(&the_index, &rev.diffopt.pathspec) < 0) {
+		perror("read_index_preload");
 		return -1;
 	}
 	result = run_diff_files(&rev, options);
diff --git a/builtin/diff-index.c b/builtin/diff-index.c
index 49fd64d4ce..3fbe33a90a 100644
--- a/builtin/diff-index.c
+++ b/builtin/diff-index.c
@@ -44,8 +44,8 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix)
 		usage(diff_cache_usage);
 	if (!cached) {
 		setup_work_tree();
-		if (read_cache_preload(&rev.diffopt.pathspec) < 0) {
-			perror("read_cache_preload");
+		if (read_index_preload(&the_index, &rev.diffopt.pathspec) < 0) {
+			perror("read_index_preload");
 			return -1;
 		}
 	} else if (read_index(&the_index) < 0) {
diff --git a/builtin/diff.c b/builtin/diff.c
index ed9edb2d0c..0ae33bce2b 100644
--- a/builtin/diff.c
+++ b/builtin/diff.c
@@ -144,8 +144,8 @@ static int builtin_diff_index(struct rev_info *revs,
 		usage(builtin_diff_usage);
 	if (!cached) {
 		setup_work_tree();
-		if (read_cache_preload(&revs->diffopt.pathspec) < 0) {
-			perror("read_cache_preload");
+		if (read_index_preload(&the_index, &revs->diffopt.pathspec) < 0) {
+			perror("read_index_preload");
 			return -1;
 		}
 	} else if (read_index(&the_index) < 0) {
@@ -246,8 +246,8 @@ static int builtin_diff_files(struct rev_info *revs, int argc, const char **argv
 		revs->combine_merges = revs->dense_combined_merges = 1;
 
 	setup_work_tree();
-	if (read_cache_preload(&revs->diffopt.pathspec) < 0) {
-		perror("read_cache_preload");
+	if (read_index_preload(&the_index, &revs->diffopt.pathspec) < 0) {
+		perror("read_index_preload");
 		return -1;
 	}
 	return run_diff_files(revs, options);
diff --git a/builtin/update-index.c b/builtin/update-index.c
index 9b93e09765..8667c48446 100644
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
@@ -766,7 +766,7 @@ struct refresh_params {
 static int refresh(struct refresh_params *o, unsigned int flag)
 {
 	setup_work_tree();
-	read_cache_preload(NULL);
+	read_index_preload(&the_index, NULL);
 	*o->has_errors |= refresh_cache(o->flags | flag);
 	return 0;
 }
diff --git a/cache.h b/cache.h
index 6abf48dcc3..a66ae97fb7 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 read_cache_preload(pathspec) read_index_preload(&the_index, (pathspec))
 #define is_cache_unborn() is_index_unborn(&the_index)
 #define read_cache_unmerged() read_index_unmerged(&the_index)
 #define discard_cache() discard_index(&the_index)
-- 
2.13.0.rc1.1.gbc33f0f778
Previous: Stefan BellerNext: Stefan Beller
Message 5 of 25 in “Start of a journey: drop NO_THE_INDEX_COMPATIBILITY_MACROS”
  1. 0/5 Start of a journey: drop NO_THE_INDEX_COMPATIBILITY_MACROSStefan Beller, May 1, 2017
  2. 1/5 cache.h: drop read_cache()Stefan Beller, May 1, 2017
  3. 2/5 cache.h: drop active_* macrosStefan Beller, May 1, 2017
  4. 3/5 cache.h: drop read_cache_fromStefan Beller, May 1, 2017
  5. 4/5 cache.h: drop read_cache_preload(pathspec)Stefan Beller, May 1, 2017
  6. 5/5 cache.h: drop read_cache_unmerged()Stefan Beller, May 1, 2017
  7. Junio C HamanoMay 2, 2017
  8. Stefan BellerMay 2, 2017
  9. Jeff HostetlerMay 2, 2017
  10. Samuel LijinMay 3, 2017
  11. Stefan BellerMay 3, 2017
  12. Samuel LijinMay 3, 2017
  13. Brandon WilliamsMay 4, 2017
  14. Duy NguyenMay 3, 2017
  15. Stefan BellerMay 3, 2017
  16. Junio C HamanoMay 4, 2017
  17. Brandon WilliamsMay 4, 2017
  18. Stefan BellerMay 4, 2017
  19. Johannes SchindelinMay 5, 2017
  20. Brandon WilliamsMay 5, 2017
  21. Jonathan NiederMay 4, 2017
  22. Junio C HamanoMay 5, 2017
  23. Brandon WilliamsMay 5, 2017
  24. Jeff HostetlerMay 2, 2017
  25. Stefan BellerMay 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.