Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2022-11-28 06:13:46 +0300
committerJunio C Hamano <gitster@pobox.com>2022-11-28 06:13:46 +0300
commit041df69edd393204c220f3f39d217e284258fd18 (patch)
tree20760c6a0bcbbec48fcc4a05d8d245581d570e91 /builtin/rm.c
parent613999cc5c951bc2c078caad59e339243f119a6e (diff)
parent07047d68294769d5e8700fc200ac326a21d04f8e (diff)
Merge branch 'ab/fewer-the-index-macros'
Progress on removing 'the_index' convenience wrappers. * ab/fewer-the-index-macros: cocci: apply "pending" index-compatibility to some "builtin/*.c" cache.h & test-tool.h: add & use "USE_THE_INDEX_VARIABLE" {builtin/*,repository}.c: add & use "USE_THE_INDEX_VARIABLE" cocci: apply "pending" index-compatibility to "t/helper/*.c" cocci & cache.h: apply variable section of "pending" index-compatibility cocci & cache.h: apply a selection of "pending" index-compatibility cocci: add a index-compatibility.pending.cocci read-cache API & users: make discard_index() return void cocci & cache.h: remove rarely used "the_index" compat macros builtin/{grep,log}.: don't define "USE_THE_INDEX_COMPATIBILITY_MACROS" cache.h: remove unused "the_index" compat macros
Diffstat (limited to 'builtin/rm.c')
-rw-r--r--builtin/rm.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/builtin/rm.c b/builtin/rm.c
index 05bfe20a46..d4989d4d86 100644
--- a/builtin/rm.c
+++ b/builtin/rm.c
@@ -35,8 +35,8 @@ static int get_ours_cache_pos(const char *path, int pos)
{
int i = -pos - 1;
- while ((i < active_nr) && !strcmp(active_cache[i]->name, path)) {
- if (ce_stage(active_cache[i]) == 2)
+ while ((i < the_index.cache_nr) && !strcmp(the_index.cache[i]->name, path)) {
+ if (ce_stage(the_index.cache[i]) == 2)
return i;
i++;
}
@@ -72,13 +72,13 @@ static void submodules_absorb_gitdir_if_needed(void)
int pos;
const struct cache_entry *ce;
- pos = cache_name_pos(name, strlen(name));
+ pos = index_name_pos(&the_index, name, strlen(name));
if (pos < 0) {
pos = get_ours_cache_pos(name, pos);
if (pos < 0)
continue;
}
- ce = active_cache[pos];
+ ce = the_index.cache[pos];
if (!S_ISGITLINK(ce->ce_mode) ||
!file_exists(ce->name) ||
@@ -116,7 +116,7 @@ static int check_local_mod(struct object_id *head, int index_only)
int local_changes = 0;
int staged_changes = 0;
- pos = cache_name_pos(name, strlen(name));
+ pos = index_name_pos(&the_index, name, strlen(name));
if (pos < 0) {
/*
* Skip unmerged entries except for populated submodules
@@ -126,11 +126,11 @@ static int check_local_mod(struct object_id *head, int index_only)
if (pos < 0)
continue;
- if (!S_ISGITLINK(active_cache[pos]->ce_mode) ||
+ if (!S_ISGITLINK(the_index.cache[pos]->ce_mode) ||
is_empty_dir(name))
continue;
}
- ce = active_cache[pos];
+ ce = the_index.cache[pos];
if (lstat(ce->name, &st) < 0) {
if (!is_missing_file_error(errno))
@@ -167,7 +167,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 |
@@ -290,9 +290,9 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
prepare_repo_settings(the_repository);
the_repository->settings.command_requires_full_index = 0;
- hold_locked_index(&lock_file, LOCK_DIE_ON_ERROR);
+ repo_hold_locked_index(the_repository, &lock_file, LOCK_DIE_ON_ERROR);
- if (read_cache() < 0)
+ if (repo_read_index(the_repository) < 0)
die(_("index file corrupt"));
refresh_index(&the_index, REFRESH_QUIET|REFRESH_UNMERGED, &pathspec, NULL, NULL);
@@ -302,8 +302,8 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
if (pathspec_needs_expanded_index(&the_index, &pathspec))
ensure_full_index(&the_index);
- for (i = 0; i < active_nr; i++) {
- const struct cache_entry *ce = active_cache[i];
+ for (i = 0; i < the_index.cache_nr; i++) {
+ const struct cache_entry *ce = the_index.cache[i];
if (!include_sparse &&
(ce_skip_worktree(ce) ||
@@ -385,7 +385,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);
}