[PATCH 17/24] cache.h: drop remove_file_from_cache

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



coccinelle patch:
@@ expression path; @@
-remove_file_from_cache(path)
+remove_file_from_index(&the_index, path)

Additionally drop the define from cache.h manually.

Signed-off-by: Stefan Beller <sbeller@xxxxxxxxxx>
---
 apply.c                |  4 ++--
 builtin/commit.c       |  2 +-
 builtin/reset.c        |  2 +-
 builtin/rm.c           |  2 +-
 builtin/update-index.c | 10 +++++-----
 cache.h                |  1 -
 merge-recursive.c      | 16 ++++++++--------
 7 files changed, 18 insertions(+), 19 deletions(-)

diff --git a/apply.c b/apply.c
index 66d4969e72..8a61f19d03 100644
--- a/apply.c
+++ b/apply.c
@@ -4230,7 +4230,7 @@ static int build_fake_ancestor(struct apply_state *state, struct patch *list)
  static int remove_file(struct apply_state *state, struct patch *patch, int rmdir_empty)
  {
 	 if (state->update_index) {
-		 if (remove_file_from_cache(patch->old_name) < 0)
+		 if (remove_file_from_index(&the_index, patch->old_name) < 0)
 			 return error(_("unable to remove %s from index"), patch->old_name);
 	 }
 	 if (!state->cached) {
@@ -4418,7 +4418,7 @@ static int add_conflicted_stages_file(struct apply_state *state,
 	ce_size = cache_entry_size(namelen);
 	mode = patch->new_mode ? patch->new_mode : (S_IFREG | 0644);
 
-	remove_file_from_cache(patch->new_name);
+	remove_file_from_index(&the_index, patch->new_name);
 	for (stage = 1; stage < 4; stage++) {
 		if (is_null_oid(&patch->threeway_stage[stage - 1]))
 			continue;
diff --git a/builtin/commit.c b/builtin/commit.c
index ef12ea3991..fa962c4f86 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -290,7 +290,7 @@ static void add_remove_files(struct string_list *list)
 			if (add_to_cache(p->string, &st, 0))
 				die(_("updating files failed"));
 		} else
-			remove_file_from_cache(p->string);
+			remove_file_from_index(&the_index, p->string);
 	}
 }
 
diff --git a/builtin/reset.c b/builtin/reset.c
index 0e19d6e8d5..90c56b46f2 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -125,7 +125,7 @@ static void update_index_from_diff(struct diff_queue_struct *q,
 		struct cache_entry *ce;
 
 		if (is_missing && !intent_to_add) {
-			remove_file_from_cache(one->path);
+			remove_file_from_index(&the_index, one->path);
 			continue;
 		}
 
diff --git a/builtin/rm.c b/builtin/rm.c
index c77c941ef0..f479100298 100644
--- a/builtin/rm.c
+++ b/builtin/rm.c
@@ -343,7 +343,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
 		if (!quiet)
 			printf("rm '%s'\n", path);
 
-		if (remove_file_from_cache(path))
+		if (remove_file_from_index(&the_index, path))
 			die(_("git rm: unable to remove %s"), path);
 	}
 
diff --git a/builtin/update-index.c b/builtin/update-index.c
index e0738f74bf..8c4911e920 100644
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
@@ -243,7 +243,7 @@ static int remove_one_path(const char *path)
 {
 	if (!allow_remove)
 		return error("%s: does not exist and --remove not passed", path);
-	if (remove_file_from_cache(path))
+	if (remove_file_from_index(&the_index, path))
 		return error("%s: cannot remove from the index", path);
 	return 0;
 }
@@ -376,7 +376,7 @@ static int process_path(const char *path)
 		 * so updating it does not make sense.
 		 * On the other hand, removing it from index should work
 		 */
-		if (allow_remove && remove_file_from_cache(path))
+		if (allow_remove && remove_file_from_index(&the_index, path))
 			return error("%s: cannot remove from the index", path);
 		return 0;
 	}
@@ -459,7 +459,7 @@ static void update_one(const char *path)
 	}
 
 	if (force_remove) {
-		if (remove_file_from_cache(path))
+		if (remove_file_from_index(&the_index, path))
 			die("git update-index: unable to remove %s", path);
 		report("remove '%s'", path);
 		return;
@@ -541,7 +541,7 @@ static void read_index_info(int nul_term_line)
 
 		if (!mode) {
 			/* mode == 0 means there is no such path -- remove */
-			if (remove_file_from_cache(path_name))
+			if (remove_file_from_index(&the_index, path_name))
 				die("git update-index: unable to remove %s",
 				    ptr);
 		}
@@ -658,7 +658,7 @@ static int unresolve_one(const char *path)
 		goto free_return;
 	}
 
-	remove_file_from_cache(path);
+	remove_file_from_index(&the_index, path);
 	if (add_index_entry(&the_index, ce_2, ADD_CACHE_OK_TO_ADD)) {
 		error("%s: cannot add our version to the index.", path);
 		ret = -1;
diff --git a/cache.h b/cache.h
index 4c12ff265e..88c6f8a7df 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 remove_file_from_cache(path) remove_file_from_index(&the_index, (path))
 #define add_to_cache(path, st, flags) add_to_index(&the_index, (path), (st), (flags))
 #define add_file_to_cache(path, flags) add_file_to_index(&the_index, (path), (flags))
 #define chmod_cache_entry(ce, flip) chmod_index_entry(&the_index, (ce), (flip))
diff --git a/merge-recursive.c b/merge-recursive.c
index 6420dc1951..c5bf1fb6a2 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -582,7 +582,7 @@ static int update_stages(struct merge_options *opt, const char *path,
 	int clear = 1;
 	int options = ADD_CACHE_OK_TO_ADD | ADD_CACHE_SKIP_DFCHECK;
 	if (clear)
-		if (remove_file_from_cache(path))
+		if (remove_file_from_index(&the_index, path))
 			return -1;
 	if (o)
 		if (add_cacheinfo(opt, o->mode, &o->oid, path, 1, 0, options))
@@ -617,7 +617,7 @@ static int remove_file(struct merge_options *o, int clean,
 	int update_working_directory = !o->call_depth && !no_wd;
 
 	if (update_cache) {
-		if (remove_file_from_cache(path))
+		if (remove_file_from_index(&the_index, path))
 			return -1;
 	}
 	if (update_working_directory) {
@@ -1084,7 +1084,7 @@ static int handle_change_delete(struct merge_options *o,
 		 * correct; since there is no true "middle point" between
 		 * them, simply reuse the base version for virtual merge base.
 		 */
-		ret = remove_file_from_cache(path);
+		ret = remove_file_from_index(&the_index, path);
 		if (!ret)
 			ret = update_file(o, 0, o_oid, o_mode, update_path);
 	} else {
@@ -1145,7 +1145,7 @@ static int conflict_rename_delete(struct merge_options *o,
 		return -1;
 
 	if (o->call_depth)
-		return remove_file_from_cache(dest->path);
+		return remove_file_from_index(&the_index, dest->path);
 	else
 		return update_stages(o, dest->path, NULL,
 				     rename_branch == o->branch1 ? dest : NULL,
@@ -1263,14 +1263,14 @@ static int conflict_rename_rename_1to2(struct merge_options *o,
 				return -1;
 		}
 		else
-			remove_file_from_cache(a->path);
+			remove_file_from_index(&the_index, a->path);
 		add = filespec_from_entry(&other, ci->dst_entry2, 3 ^ 1);
 		if (add) {
 			if (update_file(o, 0, &add->oid, add->mode, b->path))
 				return -1;
 		}
 		else
-			remove_file_from_cache(b->path);
+			remove_file_from_index(&the_index, b->path);
 	} else if (handle_file(o, a, 2, ci) || handle_file(o, b, 3, ci))
 		return -1;
 
@@ -1759,7 +1759,7 @@ static int merge_content(struct merge_options *o,
 	if (df_conflict_remains) {
 		char *new_path;
 		if (o->call_depth) {
-			remove_file_from_cache(path);
+			remove_file_from_index(&the_index, path);
 		} else {
 			if (!mfi.clean) {
 				if (update_stages(o, path, &one, &a, &b))
@@ -1887,7 +1887,7 @@ static int process_entry(struct merge_options *o,
 			if (update_file(o, 0, oid, mode, new_path))
 				clean_merge = -1;
 			else if (o->call_depth)
-				remove_file_from_cache(path);
+				remove_file_from_index(&the_index, path);
 			free(new_path);
 		} else {
 			output(o, 2, _("Adding %s"), path);
-- 
2.13.0.rc1.39.ga6db8bfa24




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]