summaryrefslogtreecommitdiffstats
path: root/builtin/merge-index.c
diff options
context:
space:
mode:
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>2022-11-19 14:07:34 +0100
committerJunio C Hamano <gitster@pobox.com>2022-11-21 04:06:15 +0100
commitdc594180d9e62438cb664c678f5e5bd229154c75 (patch)
tree10b94b968ae39d1f78cdac0fdaa3238f744f5c41 /builtin/merge-index.c
parentcocci & cache.h: apply a selection of "pending" index-compatibility (diff)
downloadgit-dc594180d9e62438cb664c678f5e5bd229154c75.tar.xz
git-dc594180d9e62438cb664c678f5e5bd229154c75.zip
cocci & cache.h: apply variable section of "pending" index-compatibility
Mostly apply the part of "index-compatibility.pending.cocci" that renames the global variables like "active_nr", which are a shorthand to referencing (in that case) a struct member as "the_index.cache_nr". In doing so move more of "index-compatibility.pending.cocci" to "index-compatibility.cocci". In the case of "active_nr" we'd have a textual conflict with "ab/various-leak-fixes" in "next"[1]. Let's exclude that specific case while moving the rule over from "pending". 1. 407b94280f8 (commit: discard partial cache before (re-)reading it, 2022-11-08) Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/merge-index.c')
-rw-r--r--builtin/merge-index.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/builtin/merge-index.c b/builtin/merge-index.c
index 012f52bd00..a334c513c9 100644
--- a/builtin/merge-index.c
+++ b/builtin/merge-index.c
@@ -14,11 +14,11 @@ static int merge_entry(int pos, const char *path)
char ownbuf[4][60];
struct child_process cmd = CHILD_PROCESS_INIT;
- if (pos >= active_nr)
+ if (pos >= the_index.cache_nr)
die("git merge-index: %s not in the cache", path);
found = 0;
do {
- const struct cache_entry *ce = active_cache[pos];
+ const struct cache_entry *ce = the_index.cache[pos];
int stage = ce_stage(ce);
if (strcmp(ce->name, path))
@@ -28,7 +28,7 @@ static int merge_entry(int pos, const char *path)
xsnprintf(ownbuf[stage], sizeof(ownbuf[stage]), "%o", ce->ce_mode);
arguments[stage] = hexbuf[stage];
arguments[stage + 4] = ownbuf[stage];
- } while (++pos < active_nr);
+ } while (++pos < the_index.cache_nr);
if (!found)
die("git merge-index: %s not in the cache", path);
@@ -62,8 +62,8 @@ static void merge_all(void)
int i;
/* TODO: audit for interaction with sparse-index. */
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 (!ce_stage(ce))
continue;
i += merge_entry(i, ce->name)-1;