All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/24] Retire NO_THE_INDEX_COMPATIBILITY_MACROS
@ 2017-05-02 22:22 Stefan Beller
  2017-05-02 22:22 ` [PATCH 01/24] cache.h: drop read_cache() Stefan Beller
                   ` (23 more replies)
  0 siblings, 24 replies; 25+ messages in thread
From: Stefan Beller @ 2017-05-02 22:22 UTC (permalink / raw)
  To: gitster, git; +Cc: git, Stefan Beller

This is the follow up to [1], but actually completed now.

The reasoning why this series is a good idea is in the commit message of the
last patch, quoted here:

The NO_THE_INDEX_COMPATIBILITY_MACROS pre processor setting was introduced
in 4aab5b46f4 (Make read-cache.c "the_index" free., 2007-04-01), stating:

    This makes all low-level functions defined in read-cache.c to
    take an explicit index_state structure as their first parameter,
    to specify which index to work on.

The reasoning is very vague, maybe indicating that having the index
specified to work on is easier to for the new reader to understand what
is going on.

All preceding patches worked on retiring functions that do not take an
explicit index as to where to perform its work. Spelling out the reasons
why we want to specify the index at each call:

1)  Ease of understanding:
   The recent patches dropped a lot of macros that may confuse new people
   diving into the code base.
2a) Spelling out global state explicitly:
   Anything you do in submodule land today needs to spawn new processes in
   the submodule. This is cumbersome and not performant. So we may want to
   have an abstraction of a repo, i.e. all repository state in one struct.
   That way we can open a submodule in-process and perform the required
   actions without spawning a process. The road to this future is a long
   road, and we have to start somewhere. Exposing the global state seems
   like a good starter point.
2b) Spelling out global state explicitly (II): (Jeff Hostetler wrote)
   In addition to (eventually) allowing multiple repos be open at the same
   time for submodules, it would also help with various multi-threading
   efforts.  For example, we have loops that do a
   "for (k = 0, k < active_nr; k++) {...}"  There is no visual clue in that
   code that it references "the_index" and therefore should be subject to
   the same locking.  Granted, this is a trivial example, but goes to the
   argument that the code has lots of subtle global variables and macros
   that make it difficult to reason about the code.

   This step would help un-hide this.
   

Review as well as critique if this is the right approach to an endgame with
less globals splattered throughout the codebase is welcome.

Thanks,
Stefan

[1] https://public-inbox.org/git/20170501190719.10669-1-sbeller@google.com/

Stefan Beller (24):
  cache.h: drop read_cache()
  cache.h: drop active_* macros
  cache.h: drop read_cache_from
  cache.h: drop read_cache_preload(pathspec)
  cache.h: drop read_cache_unmerged()
  unpack-trees.c: rename parameter 'the_index'
  cache.h: drop read_blob_data_from_cache
  cache.h: drop unmerge_cache[_entry_at]
  cache.h: drop resolve_undo_clear
  cache.h: drop cache_name_is_other
  cache.h: drop cache_file_exists
  cache.h: drop cache_dir_exists
  cache.h: drop is_cache_unborn(), discard_cache(), unmerged_cache()
  cache.h: drop cache_name_pos
  cache.h: drop add_cache_entry
  cache.h: drop rename_cache_entry_at
  cache.h: drop remove_file_from_cache
  cache.h: drop add_to_cache
  cache.h: drop add_file_to_cache
  cache.h: drop chmod_cache_entry
  cache.h: drop refresh_cache
  cache.h: drop ce_modified
  cache.h: drop ce_match_stat
  cache.h: retire NO_THE_INDEX_COMPATIBILITY_MACROS

 apply.c                              | 32 +++++++------
 attr.c                               |  1 -
 builtin/add.c                        | 12 ++---
 builtin/am.c                         | 26 +++++------
 builtin/blame.c                      | 19 ++++----
 builtin/check-attr.c                 |  2 +-
 builtin/check-ignore.c               |  4 +-
 builtin/checkout-index.c             | 12 ++---
 builtin/checkout.c                   | 66 +++++++++++++-------------
 builtin/clean.c                      |  4 +-
 builtin/commit.c                     | 52 ++++++++++-----------
 builtin/describe.c                   |  2 +-
 builtin/diff-files.c                 |  4 +-
 builtin/diff-index.c                 |  6 +--
 builtin/diff.c                       | 19 ++++----
 builtin/fsck.c                       | 14 +++---
 builtin/grep.c                       | 10 ++--
 builtin/ls-files.c                   | 49 +++++++++----------
 builtin/merge-index.c                | 14 +++---
 builtin/merge.c                      | 24 +++++-----
 builtin/mv.c                         | 22 ++++-----
 builtin/pull.c                       |  4 +-
 builtin/read-tree.c                  |  8 ++--
 builtin/reset.c                      | 11 +++--
 builtin/rev-parse.c                  |  2 +-
 builtin/rm.c                         | 26 +++++------
 builtin/submodule--helper.c          | 10 ++--
 builtin/update-index.c               | 91 +++++++++++++++++++-----------------
 cache.h                              | 35 --------------
 check-racy.c                         | 10 ++--
 convert.c                            |  4 +-
 diff-lib.c                           |  8 ++--
 diff.c                               | 14 +++---
 dir.c                                | 41 ++++++++--------
 entry.c                              |  3 +-
 merge-recursive.c                    | 65 +++++++++++++-------------
 merge.c                              |  8 ++--
 name-hash.c                          |  1 -
 pathspec.c                           | 16 +++----
 read-cache.c                         |  5 +-
 rerere.c                             | 38 +++++++--------
 revision.c                           | 22 ++++-----
 sequencer.c                          | 29 ++++++------
 sha1_name.c                          | 22 ++++-----
 submodule.c                          | 20 ++++----
 t/helper/test-dump-cache-tree.c      |  4 +-
 t/helper/test-dump-untracked-cache.c |  2 +-
 t/helper/test-lazy-init-name-hash.c  | 20 ++++----
 t/helper/test-read-cache.c           |  4 +-
 t/helper/test-scrap-cache-tree.c     |  4 +-
 t/t2107-update-index-basic.sh        |  2 +-
 tree.c                               | 10 ++--
 unpack-trees.c                       |  9 ++--
 wt-status.c                          | 24 +++++-----
 54 files changed, 471 insertions(+), 495 deletions(-)

-- 
2.13.0.rc1.39.ga6db8bfa24


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH 01/24] cache.h: drop read_cache()
  2017-05-02 22:22 [PATCH 00/24] Retire NO_THE_INDEX_COMPATIBILITY_MACROS Stefan Beller
@ 2017-05-02 22:22 ` Stefan Beller
  2017-05-02 22:23 ` [PATCH 02/24] cache.h: drop active_* macros Stefan Beller
                   ` (22 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: Stefan Beller @ 2017-05-02 22:22 UTC (permalink / raw)
  To: gitster, git; +Cc: git, Stefan Beller

This patch is produced via coccinelle using this semantic patch:

@@ @@
-read_cache()
+read_index(&the_index)

Additional manual editing:
* drop define in cache.h
* a comment in builtin/check-ignore.c and read-cache.c were
  converted
* builtin/diff.c: fix error message referencing the function.

Signed-off-by: Stefan Beller <sbeller@google.com>
---
 apply.c                              |  2 +-
 builtin/add.c                        |  4 ++--
 builtin/am.c                         |  2 +-
 builtin/blame.c                      |  4 ++--
 builtin/check-attr.c                 |  2 +-
 builtin/check-ignore.c               |  4 ++--
 builtin/checkout-index.c             |  2 +-
 builtin/clean.c                      |  2 +-
 builtin/commit.c                     |  4 ++--
 builtin/diff-index.c                 |  2 +-
 builtin/diff.c                       |  6 +++---
 builtin/fsck.c                       |  2 +-
 builtin/grep.c                       |  2 +-
 builtin/ls-files.c                   |  2 +-
 builtin/merge-index.c                |  2 +-
 builtin/mv.c                         |  2 +-
 builtin/reset.c                      |  2 +-
 builtin/rev-parse.c                  |  2 +-
 builtin/rm.c                         |  2 +-
 builtin/submodule--helper.c          |  2 +-
 builtin/update-index.c               |  2 +-
 cache.h                              |  1 -
 check-racy.c                         |  2 +-
 diff.c                               |  2 +-
 merge-recursive.c                    |  2 +-
 merge.c                              |  2 +-
 read-cache.c                         |  2 +-
 rerere.c                             |  6 +++---
 revision.c                           |  4 ++--
 sequencer.c                          |  6 +++---
 sha1_name.c                          |  2 +-
 submodule.c                          |  4 ++--
 t/helper/test-dump-cache-tree.c      |  2 +-
 t/helper/test-dump-untracked-cache.c |  2 +-
 t/helper/test-lazy-init-name-hash.c  | 10 +++++-----
 t/helper/test-read-cache.c           |  2 +-
 t/helper/test-scrap-cache-tree.c     |  2 +-
 37 files changed, 52 insertions(+), 53 deletions(-)

diff --git a/apply.c b/apply.c
index e6dbab26ad..82701d6580 100644
--- a/apply.c
+++ b/apply.c
@@ -3987,7 +3987,7 @@ static int read_apply_cache(struct apply_state *state)
 	if (state->index_file)
 		return read_cache_from(state->index_file);
 	else
-		return read_cache();
+		return read_index(&the_index);
 }
 
 /* This function tries to read the object name from the current index */
diff --git a/builtin/add.c b/builtin/add.c
index 9f53f020d0..ab6d04e8db 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -205,7 +205,7 @@ static int edit_patch(int argc, const char **argv, const char *prefix)
 
 	git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
 
-	if (read_cache() < 0)
+	if (read_index(&the_index) < 0)
 		die(_("Could not read the index"));
 
 	init_revisions(&rev, prefix);
@@ -376,7 +376,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
 		return 0;
 	}
 
-	if (read_cache() < 0)
+	if (read_index(&the_index) < 0)
 		die(_("index file corrupt"));
 
 	/*
diff --git a/builtin/am.c b/builtin/am.c
index a95dd8b4e6..4405d7307c 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -1633,7 +1633,7 @@ static int fall_back_threeway(const struct am_state *state, const char *index_pa
 	say(state, stdout, _("Falling back to patching base and 3-way merge..."));
 
 	discard_cache();
-	read_cache();
+	read_index(&the_index);
 
 	/*
 	 * This is not so wrong. Depending on which base we picked, orig_tree
diff --git a/builtin/blame.c b/builtin/blame.c
index 07506a3e45..59955208fd 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -2313,7 +2313,7 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,
 	unsigned mode;
 	struct strbuf msg = STRBUF_INIT;
 
-	read_cache();
+	read_index(&the_index);
 	time(&now);
 	commit = alloc_commit_node();
 	commit->object.parsed = 1;
@@ -2395,7 +2395,7 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,
 	 * want to run "diff-index --cached".
 	 */
 	discard_cache();
-	read_cache();
+	read_index(&the_index);
 
 	len = strlen(path);
 	if (!mode) {
diff --git a/builtin/check-attr.c b/builtin/check-attr.c
index 4d01ca0c8b..9cc3675d62 100644
--- a/builtin/check-attr.c
+++ b/builtin/check-attr.c
@@ -114,7 +114,7 @@ int cmd_check_attr(int argc, const char **argv, const char *prefix)
 	argc = parse_options(argc, argv, prefix, check_attr_options,
 			     check_attr_usage, PARSE_OPT_KEEP_DASHDASH);
 
-	if (read_cache() < 0) {
+	if (read_index(&the_index) < 0) {
 		die("invalid cache");
 	}
 
diff --git a/builtin/check-ignore.c b/builtin/check-ignore.c
index 1d73d3ca3d..e526b27151 100644
--- a/builtin/check-ignore.c
+++ b/builtin/check-ignore.c
@@ -167,8 +167,8 @@ int cmd_check_ignore(int argc, const char **argv, const char *prefix)
 	if (show_non_matching && !verbose)
 		die(_("--non-matching is only valid with --verbose"));
 
-	/* read_cache() is only necessary so we can watch out for submodules. */
-	if (!no_index && read_cache() < 0)
+	/* read_index() is only necessary so we can watch out for submodules. */
+	if (!no_index && read_index(&the_index) < 0)
 		die(_("index file corrupt"));
 
 	memset(&dir, 0, sizeof(dir));
diff --git a/builtin/checkout-index.c b/builtin/checkout-index.c
index 07631d0c9c..676b9419f0 100644
--- a/builtin/checkout-index.c
+++ b/builtin/checkout-index.c
@@ -185,7 +185,7 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix)
 	git_config(git_default_config, NULL);
 	prefix_length = prefix ? strlen(prefix) : 0;
 
-	if (read_cache() < 0) {
+	if (read_index(&the_index) < 0) {
 		die("invalid cache");
 	}
 
diff --git a/builtin/clean.c b/builtin/clean.c
index d861f836a2..9bdefca6dc 100644
--- a/builtin/clean.c
+++ b/builtin/clean.c
@@ -916,7 +916,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
 
 	dir.flags |= DIR_SHOW_OTHER_DIRECTORIES;
 
-	if (read_cache() < 0)
+	if (read_index(&the_index) < 0)
 		die(_("index file corrupt"));
 
 	if (!ignored)
diff --git a/builtin/commit.c b/builtin/commit.c
index 1d805f5da8..7cd08841a1 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -465,7 +465,7 @@ static const char *prepare_index(int argc, const char **argv, const char *prefix
 		exit(1);
 
 	discard_cache();
-	if (read_cache() < 0)
+	if (read_index(&the_index) < 0)
 		die(_("cannot read the index"));
 
 	hold_locked_index(&index_lock, LOCK_DIE_ON_ERROR);
@@ -888,7 +888,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 		struct object_id oid;
 		const char *parent = "HEAD";
 
-		if (!active_nr && read_cache() < 0)
+		if (!active_nr && read_index(&the_index) < 0)
 			die(_("Cannot read index"));
 
 		if (amend)
diff --git a/builtin/diff-index.c b/builtin/diff-index.c
index 1af373d002..49fd64d4ce 100644
--- a/builtin/diff-index.c
+++ b/builtin/diff-index.c
@@ -48,7 +48,7 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix)
 			perror("read_cache_preload");
 			return -1;
 		}
-	} else if (read_cache() < 0) {
+	} else if (read_index(&the_index) < 0) {
 		perror("read_cache");
 		return -1;
 	}
diff --git a/builtin/diff.c b/builtin/diff.c
index d184aafab9..ed9edb2d0c 100644
--- a/builtin/diff.c
+++ b/builtin/diff.c
@@ -148,8 +148,8 @@ static int builtin_diff_index(struct rev_info *revs,
 			perror("read_cache_preload");
 			return -1;
 		}
-	} else if (read_cache() < 0) {
-		perror("read_cache");
+	} else if (read_index(&the_index) < 0) {
+		perror("read_index");
 		return -1;
 	}
 	return run_diff_index(revs, cached);
@@ -210,7 +210,7 @@ static void refresh_index_quietly(void)
 	if (fd < 0)
 		return;
 	discard_cache();
-	read_cache();
+	read_index(&the_index);
 	refresh_cache(REFRESH_QUIET|REFRESH_UNMERGED);
 	update_index_if_able(&the_index, lock_file);
 }
diff --git a/builtin/fsck.c b/builtin/fsck.c
index b5e13a4556..35e03556cb 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -772,7 +772,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
 
 	if (keep_cache_objects) {
 		verify_index_checksum = 1;
-		read_cache();
+		read_index(&the_index);
 		for (i = 0; i < active_nr; i++) {
 			unsigned int mode;
 			struct blob *blob;
diff --git a/builtin/grep.c b/builtin/grep.c
index 3ffb5b4e81..5153dbf262 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -676,7 +676,7 @@ static int grep_cache(struct grep_opt *opt, const struct pathspec *pathspec,
 		strbuf_addstr(&name, super_prefix);
 	}
 
-	read_cache();
+	read_index(&the_index);
 
 	for (nr = 0; nr < active_nr; nr++) {
 		const struct cache_entry *ce = active_cache[nr];
diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index a6c70dbe9e..da4779ec0b 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -578,7 +578,7 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)
 	super_prefix = get_super_prefix();
 	git_config(git_default_config, NULL);
 
-	if (read_cache() < 0)
+	if (read_index(&the_index) < 0)
 		die("index file corrupt");
 
 	argc = parse_options(argc, argv, prefix, builtin_ls_files_options,
diff --git a/builtin/merge-index.c b/builtin/merge-index.c
index c99443b095..51fb590dfa 100644
--- a/builtin/merge-index.c
+++ b/builtin/merge-index.c
@@ -77,7 +77,7 @@ int cmd_merge_index(int argc, const char **argv, const char *prefix)
 	if (argc < 3)
 		usage("git merge-index [-o] [-q] <merge-program> (-a | [--] [<filename>...])");
 
-	read_cache();
+	read_index(&the_index);
 
 	i = 1;
 	if (!strcmp(argv[i], "-o")) {
diff --git a/builtin/mv.c b/builtin/mv.c
index 61d20037ad..6fd7a3a9d8 100644
--- a/builtin/mv.c
+++ b/builtin/mv.c
@@ -139,7 +139,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
 		usage_with_options(builtin_mv_usage, builtin_mv_options);
 
 	hold_locked_index(&lock_file, LOCK_DIE_ON_ERROR);
-	if (read_cache() < 0)
+	if (read_index(&the_index) < 0)
 		die(_("index file corrupt"));
 
 	source = internal_prefix_pathspec(prefix, argv, argc, 0);
diff --git a/builtin/reset.c b/builtin/reset.c
index fc3b906c47..03c5498d6e 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -231,7 +231,7 @@ static void parse_args(struct pathspec *pathspec,
 	}
 	*rev_ret = rev;
 
-	if (read_cache() < 0)
+	if (read_index(&the_index) < 0)
 		die(_("index file corrupt"));
 
 	parse_pathspec(pathspec, 0,
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index 0513330910..0c6352a018 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -868,7 +868,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
 				continue;
 			}
 			if (!strcmp(arg, "--shared-index-path")) {
-				if (read_cache() < 0)
+				if (read_index(&the_index) < 0)
 					die(_("Could not read the index"));
 				if (the_index.split_index) {
 					const unsigned char *sha1 = the_index.split_index->base_sha1;
diff --git a/builtin/rm.c b/builtin/rm.c
index fb79dcab18..d0eecbdaac 100644
--- a/builtin/rm.c
+++ b/builtin/rm.c
@@ -267,7 +267,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
 
 	hold_locked_index(&lock_file, LOCK_DIE_ON_ERROR);
 
-	if (read_cache() < 0)
+	if (read_index(&the_index) < 0)
 		die(_("index file corrupt"));
 
 	parse_pathspec(&pathspec, 0,
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 566a5b6a6f..1281056312 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -240,7 +240,7 @@ static int module_list_compute(int argc, const char **argv,
 	if (pathspec->nr)
 		ps_matched = xcalloc(pathspec->nr, 1);
 
-	if (read_cache() < 0)
+	if (read_index(&the_index) < 0)
 		die(_("index file corrupt"));
 
 	for (i = 0; i < active_nr; i++) {
diff --git a/builtin/update-index.c b/builtin/update-index.c
index ebfc09faa0..7a4b914af4 100644
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
@@ -1021,7 +1021,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
 	if (newfd < 0)
 		lock_error = errno;
 
-	entries = read_cache();
+	entries = read_index(&the_index);
 	if (entries < 0)
 		die("cache corrupted");
 
diff --git a/cache.h b/cache.h
index e1f0e182ad..9a1ea38a14 100644
--- a/cache.h
+++ b/cache.h
@@ -360,7 +360,6 @@ extern void free_name_hash(struct index_state *istate);
 #define active_cache_changed (the_index.cache_changed)
 #define active_cache_tree (the_index.cache_tree)
 
-#define read_cache() read_index(&the_index)
 #define read_cache_from(path) read_index_from(&the_index, (path))
 #define read_cache_preload(pathspec) read_index_preload(&the_index, (pathspec))
 #define is_cache_unborn() is_index_unborn(&the_index)
diff --git a/check-racy.c b/check-racy.c
index 24b6542352..f50b21cb06 100644
--- a/check-racy.c
+++ b/check-racy.c
@@ -6,7 +6,7 @@ int main(int ac, char **av)
 	int dirty, clean, racy;
 
 	dirty = clean = racy = 0;
-	read_cache();
+	read_index(&the_index);
 	for (i = 0; i < active_nr; i++) {
 		struct cache_entry *ce = active_cache[i];
 		struct stat st;
diff --git a/diff.c b/diff.c
index 11eef1c85d..05d0312265 100644
--- a/diff.c
+++ b/diff.c
@@ -3497,7 +3497,7 @@ void diff_setup_done(struct diff_options *options)
 			 * when it fails, so we do not have to worry about
 			 * cleaning it up ourselves either.
 			 */
-			read_cache();
+			read_index(&the_index);
 	}
 	if (40 < options->abbrev)
 		options->abbrev = 40; /* full */
diff --git a/merge-recursive.c b/merge-recursive.c
index 62decd51cc..3cfaf33faa 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -2075,7 +2075,7 @@ int merge_recursive(struct merge_options *o,
 
 	discard_cache();
 	if (!o->call_depth)
-		read_cache();
+		read_index(&the_index);
 
 	o->ancestor = "merged common ancestors";
 	clean = merge_trees(o, h1->tree, h2->tree, merged_common_ancestors->tree,
diff --git a/merge.c b/merge.c
index 04ee5fc911..748305031e 100644
--- a/merge.c
+++ b/merge.c
@@ -37,7 +37,7 @@ int try_merge_command(const char *strategy, size_t xopts_nr,
 	argv_array_clear(&args);
 
 	discard_cache();
-	if (read_cache() < 0)
+	if (read_index(&the_index) < 0)
 		die(_("failed to read the cache"));
 	resolve_undo_clear();
 
diff --git a/read-cache.c b/read-cache.c
index b3d0f3c30b..f1bdb006f4 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -2506,7 +2506,7 @@ int write_locked_index(struct index_state *istate, struct lock_file *lock,
  * index_state, dropping any unmerged entries.  Returns true if
  * the index is unmerged.  Callers who want to refuse to work
  * from an unmerged state can call this and check its return value,
- * instead of calling read_cache().
+ * instead of calling read_index().
  */
 int read_index_unmerged(struct index_state *istate)
 {
diff --git a/rerere.c b/rerere.c
index 3bd55caf3b..770b34a5c9 100644
--- a/rerere.c
+++ b/rerere.c
@@ -566,7 +566,7 @@ static int check_one_conflict(int i, int *type)
 static int find_conflict(struct string_list *conflict)
 {
 	int i;
-	if (read_cache() < 0)
+	if (read_index(&the_index) < 0)
 		return error("Could not read index");
 
 	for (i = 0; i < active_nr;) {
@@ -599,7 +599,7 @@ int rerere_remaining(struct string_list *merge_rr)
 	int i;
 	if (setup_rerere(merge_rr, RERERE_READONLY))
 		return 0;
-	if (read_cache() < 0)
+	if (read_index(&the_index) < 0)
 		return error("Could not read index");
 
 	for (i = 0; i < active_nr;) {
@@ -1104,7 +1104,7 @@ int rerere_forget(struct pathspec *pathspec)
 	struct string_list conflict = STRING_LIST_INIT_DUP;
 	struct string_list merge_rr = STRING_LIST_INIT_DUP;
 
-	if (read_cache() < 0)
+	if (read_index(&the_index) < 0)
 		return error("Could not read index");
 
 	fd = setup_rerere(&merge_rr, RERERE_NOAUTOUPDATE);
diff --git a/revision.c b/revision.c
index 7ff61ff5f7..bb6250ef02 100644
--- a/revision.c
+++ b/revision.c
@@ -1267,7 +1267,7 @@ void add_index_objects_to_pending(struct rev_info *revs, unsigned flags)
 {
 	int i;
 
-	read_cache();
+	read_index(&the_index);
 	for (i = 0; i < active_nr; i++) {
 		struct cache_entry *ce = active_cache[i];
 		struct blob *blob;
@@ -1408,7 +1408,7 @@ static void prepare_show_merge(struct rev_info *revs)
 	head->object.flags |= SYMMETRIC_LEFT;
 
 	if (!active_nr)
-		read_cache();
+		read_index(&the_index);
 	for (i = 0; i < active_nr; i++) {
 		const struct cache_entry *ce = active_cache[i];
 		if (!ce_stage(ce))
diff --git a/sequencer.c b/sequencer.c
index 10c3b4ff81..b7ec4e3221 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -381,7 +381,7 @@ static int fast_forward_to(const unsigned char *to, const unsigned char *from,
 	struct strbuf sb = STRBUF_INIT;
 	struct strbuf err = STRBUF_INIT;
 
-	read_cache();
+	read_index(&the_index);
 	if (checkout_fast_forward(from, to, 1))
 		return -1; /* the callee should have complained already */
 
@@ -437,7 +437,7 @@ static int do_recursive_merge(struct commit *base, struct commit *next,
 
 	hold_locked_index(&index_lock, LOCK_DIE_ON_ERROR);
 
-	read_cache();
+	read_index(&the_index);
 
 	init_merge_options(&o);
 	o.ancestor = base ? base_label : "(empty tree)";
@@ -1844,7 +1844,7 @@ static int do_exec(const char *command_line)
 	status = run_command_v_opt(child_argv, RUN_USING_SHELL);
 
 	/* force re-reading of the cache */
-	if (discard_cache() < 0 || read_cache() < 0)
+	if (discard_cache() < 0 || read_index(&the_index) < 0)
 		return error(_("could not read index"));
 
 	dirty = require_clean_work_tree("rebase", NULL, 1, 1);
diff --git a/sha1_name.c b/sha1_name.c
index 8eec9f7c1b..38473b1e6d 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -1552,7 +1552,7 @@ static int get_sha1_with_context_1(const char *name,
 		strlcpy(oc->path, cp, sizeof(oc->path));
 
 		if (!active_cache)
-			read_cache();
+			read_index(&the_index);
 		pos = cache_name_pos(cp, namelen);
 		if (pos < 0)
 			pos = -pos - 1;
diff --git a/submodule.c b/submodule.c
index d3299e29c0..4d77291b11 100644
--- a/submodule.c
+++ b/submodule.c
@@ -177,7 +177,7 @@ void gitmodules_config(void)
 		int pos;
 		strbuf_addstr(&gitmodules_path, work_tree);
 		strbuf_addstr(&gitmodules_path, "/.gitmodules");
-		if (read_cache() < 0)
+		if (read_index(&the_index) < 0)
 			die("index file corrupt");
 		pos = cache_name_pos(".gitmodules", 11);
 		if (pos < 0) { /* .gitmodules not found or isn't merged */
@@ -1151,7 +1151,7 @@ int fetch_populated_submodules(const struct argv_array *options,
 	if (!spf.work_tree)
 		goto out;
 
-	if (read_cache() < 0)
+	if (read_index(&the_index) < 0)
 		die("index file corrupt");
 
 	argv_array_push(&spf.args, "fetch");
diff --git a/t/helper/test-dump-cache-tree.c b/t/helper/test-dump-cache-tree.c
index 7af116d49e..ed037a52f4 100644
--- a/t/helper/test-dump-cache-tree.c
+++ b/t/helper/test-dump-cache-tree.c
@@ -59,7 +59,7 @@ int cmd_main(int ac, const char **av)
 	struct index_state istate;
 	struct cache_tree *another = cache_tree();
 	setup_git_directory();
-	if (read_cache() < 0)
+	if (read_index(&the_index) < 0)
 		die("unable to read index file");
 	istate = the_index;
 	istate.cache_tree = another;
diff --git a/t/helper/test-dump-untracked-cache.c b/t/helper/test-dump-untracked-cache.c
index f752532ffb..7832e833af 100644
--- a/t/helper/test-dump-untracked-cache.c
+++ b/t/helper/test-dump-untracked-cache.c
@@ -47,7 +47,7 @@ int cmd_main(int ac, const char **av)
 	ignore_untracked_cache_config = 1;
 
 	setup_git_directory();
-	if (read_cache() < 0)
+	if (read_index(&the_index) < 0)
 		die("unable to read index file");
 	uc = the_index.untracked;
 	if (!uc) {
diff --git a/t/helper/test-lazy-init-name-hash.c b/t/helper/test-lazy-init-name-hash.c
index 6368a89345..bd747dcbcd 100644
--- a/t/helper/test-lazy-init-name-hash.c
+++ b/t/helper/test-lazy-init-name-hash.c
@@ -31,7 +31,7 @@ static void dump_run(void)
 	struct dir_entry *dir;
 	struct cache_entry *ce;
 
-	read_cache();
+	read_index(&the_index);
 	if (single) {
 		test_lazy_init_name_hash(&the_index, 0);
 	} else {
@@ -69,7 +69,7 @@ static uint64_t time_runs(int try_threaded)
 
 	for (i = 0; i < count; i++) {
 		t0 = getnanotime();
-		read_cache();
+		read_index(&the_index);
 		t1 = getnanotime();
 		nr_threads_used = test_lazy_init_name_hash(&the_index, try_threaded);
 		t2 = getnanotime();
@@ -116,7 +116,7 @@ static void analyze_run(void)
 	int i;
 	int nr;
 
-	read_cache();
+	read_index(&the_index);
 	cache_nr_limit = the_index.cache_nr;
 	discard_cache();
 
@@ -131,7 +131,7 @@ static void analyze_run(void)
 			nr = cache_nr_limit;
 
 		for (i = 0; i < count; i++) {
-			read_cache();
+			read_index(&the_index);
 			the_index.cache_nr = nr; /* cheap truncate of index */
 			t1s = getnanotime();
 			test_lazy_init_name_hash(&the_index, 0);
@@ -140,7 +140,7 @@ static void analyze_run(void)
 			the_index.cache_nr = cache_nr_limit;
 			discard_cache();
 
-			read_cache();
+			read_index(&the_index);
 			the_index.cache_nr = nr; /* cheap truncate of index */
 			t1m = getnanotime();
 			nr_threads_used = test_lazy_init_name_hash(&the_index, 1);
diff --git a/t/helper/test-read-cache.c b/t/helper/test-read-cache.c
index 48255eef31..b4aa339ddb 100644
--- a/t/helper/test-read-cache.c
+++ b/t/helper/test-read-cache.c
@@ -7,7 +7,7 @@ int cmd_main(int argc, const char **argv)
 		cnt = strtol(argv[1], NULL, 0);
 	setup_git_directory();
 	for (i = 0; i < cnt; i++) {
-		read_cache();
+		read_index(&the_index);
 		discard_cache();
 	}
 	return 0;
diff --git a/t/helper/test-scrap-cache-tree.c b/t/helper/test-scrap-cache-tree.c
index d2a63bea43..b02a679166 100644
--- a/t/helper/test-scrap-cache-tree.c
+++ b/t/helper/test-scrap-cache-tree.c
@@ -9,7 +9,7 @@ int cmd_main(int ac, const char **av)
 {
 	setup_git_directory();
 	hold_locked_index(&index_lock, LOCK_DIE_ON_ERROR);
-	if (read_cache() < 0)
+	if (read_index(&the_index) < 0)
 		die("unable to read index file");
 	active_cache_tree = NULL;
 	if (write_locked_index(&the_index, &index_lock, COMMIT_LOCK))
-- 
2.13.0.rc1.39.ga6db8bfa24


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 02/24] cache.h: drop active_* macros
  2017-05-02 22:22 [PATCH 00/24] Retire NO_THE_INDEX_COMPATIBILITY_MACROS Stefan Beller
  2017-05-02 22:22 ` [PATCH 01/24] cache.h: drop read_cache() Stefan Beller
@ 2017-05-02 22:23 ` Stefan Beller
  2017-05-02 22:23 ` [PATCH 03/24] cache.h: drop read_cache_from Stefan Beller
                   ` (21 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: Stefan Beller @ 2017-05-02 22:23 UTC (permalink / raw)
  To: gitster, git; +Cc: git, Stefan Beller

Based on the coccinelle patch:

@@ @@
-active_cache
+the_index.cache
@@ @@
-active_nr
+the_index.cache_nr
@@ @@
-active_alloc
+the_index.cache_alloc
@@ @@
-active_cache_changed
+the_index.cache_changed
@@ @@
-active_cache_tree
+the_index.cache_tree

Additional manual editing:
* drop the macros from cache.h
* fix the whitespace issue that apply complained about in
  builtin/checkout.c
* builtin/commit.c had an occurrence of active_cache_tree->sha1, which
  was not picked up with the coccinelle patch.
* diff.c and t/t2107-update-index-basic.sh referenced
  active_cache[_changed] in comments, fix them up.
* ative_nr was referenced in comments in read-cache.c and
  builtin/update-index.c, fix them.

Signed-off-by: Stefan Beller <sbeller@google.com>
---
 apply.c                          |  6 ++---
 builtin/add.c                    |  6 ++---
 builtin/am.c                     |  6 ++---
 builtin/blame.c                  |  6 ++---
 builtin/checkout-index.c         |  8 +++----
 builtin/checkout.c               | 49 ++++++++++++++++++++--------------------
 builtin/commit.c                 | 20 ++++++++--------
 builtin/fsck.c                   | 12 +++++-----
 builtin/grep.c                   |  8 +++----
 builtin/ls-files.c               | 36 ++++++++++++++---------------
 builtin/merge-index.c            | 10 ++++----
 builtin/merge.c                  | 12 +++++-----
 builtin/mv.c                     | 10 ++++----
 builtin/read-tree.c              |  2 +-
 builtin/rm.c                     | 16 ++++++-------
 builtin/submodule--helper.c      |  8 +++----
 builtin/update-index.c           | 48 ++++++++++++++++++++-------------------
 cache.h                          |  6 -----
 check-racy.c                     |  4 ++--
 diff-lib.c                       |  6 ++---
 diff.c                           |  8 +++----
 dir.c                            | 20 ++++++++--------
 merge-recursive.c                | 28 +++++++++++------------
 pathspec.c                       | 14 ++++++------
 read-cache.c                     |  2 +-
 rerere.c                         | 26 ++++++++++-----------
 revision.c                       | 18 +++++++--------
 sequencer.c                      | 19 ++++++++--------
 sha1_name.c                      | 14 ++++++------
 submodule.c                      | 12 +++++-----
 t/helper/test-dump-cache-tree.c  |  2 +-
 t/helper/test-scrap-cache-tree.c |  2 +-
 t/t2107-update-index-basic.sh    |  2 +-
 tree.c                           |  8 +++----
 wt-status.c                      | 12 +++++-----
 35 files changed, 232 insertions(+), 234 deletions(-)

diff --git a/apply.c b/apply.c
index 82701d6580..ae1b659b68 100644
--- a/apply.c
+++ b/apply.c
@@ -3499,7 +3499,7 @@ static int load_current(struct apply_state *state,
 	pos = cache_name_pos(name, strlen(name));
 	if (pos < 0)
 		return error(_("%s: does not exist in index"), name);
-	ce = active_cache[pos];
+	ce = the_index.cache[pos];
 	if (lstat(name, &st)) {
 		if (errno != ENOENT)
 			return error_errno("%s", name);
@@ -3671,7 +3671,7 @@ static int check_preimage(struct apply_state *state,
 				goto is_new;
 			return error(_("%s: does not exist in index"), old_name);
 		}
-		*ce = active_cache[pos];
+		*ce = the_index.cache[pos];
 		if (stat_ret < 0) {
 			if (checkout_target(&the_index, *ce, st))
 				return -1;
@@ -4001,7 +4001,7 @@ static int get_current_oid(struct apply_state *state, const char *path,
 	pos = cache_name_pos(path, strlen(path));
 	if (pos < 0)
 		return -1;
-	oidcpy(oid, &active_cache[pos]->oid);
+	oidcpy(oid, &the_index.cache[pos]->oid);
 	return 0;
 }
 
diff --git a/builtin/add.c b/builtin/add.c
index ab6d04e8db..f6d71b10d0 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -34,8 +34,8 @@ static void chmod_pathspec(struct pathspec *pathspec, int force_mode)
 {
 	int i;
 
-	for (i = 0; i < active_nr; i++) {
-		struct cache_entry *ce = active_cache[i];
+	for (i = 0; i < the_index.cache_nr; i++) {
+		struct cache_entry *ce = the_index.cache[i];
 
 		if (pathspec && !ce_path_match(ce, pathspec, NULL))
 			continue;
@@ -458,7 +458,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
 	unplug_bulk_checkin();
 
 finish:
-	if (active_cache_changed) {
+	if (the_index.cache_changed) {
 		if (write_locked_index(&the_index, &lock_file, COMMIT_LOCK))
 			die(_("Unable to write new index file"));
 	}
diff --git a/builtin/am.c b/builtin/am.c
index 4405d7307c..c6a679d8e1 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -1155,12 +1155,12 @@ static int index_has_changes(struct strbuf *sb)
 		diff_flush(&opt);
 		return DIFF_OPT_TST(&opt, HAS_CHANGES) != 0;
 	} else {
-		for (i = 0; sb && i < active_nr; i++) {
+		for (i = 0; sb && i < the_index.cache_nr; i++) {
 			if (i)
 				strbuf_addch(sb, ' ');
-			strbuf_addstr(sb, active_cache[i]->name);
+			strbuf_addstr(sb, the_index.cache[i]->name);
 		}
-		return !!active_nr;
+		return !!the_index.cache_nr;
 	}
 }
 
diff --git a/builtin/blame.c b/builtin/blame.c
index 59955208fd..cbb7c1fd9d 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -2242,8 +2242,8 @@ static void verify_working_tree_path(struct commit *work_tree, const char *path)
 	pos = cache_name_pos(path, strlen(path));
 	if (pos >= 0)
 		; /* path is in the index */
-	else if (-1 - pos < active_nr &&
-		 !strcmp(active_cache[-1 - pos]->name, path))
+	else if (-1 - pos < the_index.cache_nr &&
+		 !strcmp(the_index.cache[-1 - pos]->name, path))
 		; /* path is in the index, unmerged */
 	else
 		die("no such path '%s' in HEAD", path);
@@ -2401,7 +2401,7 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,
 	if (!mode) {
 		int pos = cache_name_pos(path, len);
 		if (0 <= pos)
-			mode = active_cache[pos]->ce_mode;
+			mode = the_index.cache[pos]->ce_mode;
 		else
 			/* Let's not bother reading from HEAD tree */
 			mode = S_IFREG | 0644;
diff --git a/builtin/checkout-index.c b/builtin/checkout-index.c
index 676b9419f0..1c3dcc1a8b 100644
--- a/builtin/checkout-index.c
+++ b/builtin/checkout-index.c
@@ -54,8 +54,8 @@ static int checkout_file(const char *name, const char *prefix)
 	if (pos < 0)
 		pos = -pos - 1;
 
-	while (pos < active_nr) {
-		struct cache_entry *ce = active_cache[pos];
+	while (pos < the_index.cache_nr) {
+		struct cache_entry *ce = the_index.cache[pos];
 		if (ce_namelen(ce) != namelen ||
 		    memcmp(ce->name, name, namelen))
 			break;
@@ -95,8 +95,8 @@ static void checkout_all(const char *prefix, int prefix_length)
 	int i, errs = 0;
 	struct cache_entry *last_ce = NULL;
 
-	for (i = 0; i < active_nr ; i++) {
-		struct cache_entry *ce = active_cache[i];
+	for (i = 0; i < the_index.cache_nr ; i++) {
+		struct cache_entry *ce = the_index.cache[i];
 		if (ce_stage(ce) != checkout_stage
 		    && (CHECKOUT_ALL != checkout_stage || !ce_stage(ce)))
 			continue;
diff --git a/builtin/checkout.c b/builtin/checkout.c
index bfa5419f33..0aac616ad6 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -109,7 +109,7 @@ static int update_some(const unsigned char *sha1, struct strbuf *base,
 	 */
 	pos = cache_name_pos(ce->name, ce->ce_namelen);
 	if (pos >= 0) {
-		struct cache_entry *old = active_cache[pos];
+		struct cache_entry *old = the_index.cache[pos];
 		if (ce->ce_mode == old->ce_mode &&
 		    !oidcmp(&ce->oid, &old->oid)) {
 			old->ce_flags |= CE_UPDATE;
@@ -135,17 +135,17 @@ static int read_tree_some(struct tree *tree, const struct pathspec *pathspec)
 
 static int skip_same_name(const struct cache_entry *ce, int pos)
 {
-	while (++pos < active_nr &&
-	       !strcmp(active_cache[pos]->name, ce->name))
+	while (++pos < the_index.cache_nr &&
+	       !strcmp(the_index.cache[pos]->name, ce->name))
 		; /* skip */
 	return pos;
 }
 
 static int check_stage(int stage, const struct cache_entry *ce, int pos)
 {
-	while (pos < active_nr &&
-	       !strcmp(active_cache[pos]->name, ce->name)) {
-		if (ce_stage(active_cache[pos]) == stage)
+	while (pos < the_index.cache_nr &&
+	       !strcmp(the_index.cache[pos]->name, ce->name)) {
+		if (ce_stage(the_index.cache[pos]) == stage)
 			return 0;
 		pos++;
 	}
@@ -160,8 +160,8 @@ static int check_stages(unsigned stages, const struct cache_entry *ce, int pos)
 	unsigned seen = 0;
 	const char *name = ce->name;
 
-	while (pos < active_nr) {
-		ce = active_cache[pos];
+	while (pos < the_index.cache_nr) {
+		ce = the_index.cache[pos];
 		if (strcmp(name, ce->name))
 			break;
 		seen |= (1 << ce_stage(ce));
@@ -176,10 +176,11 @@ static int check_stages(unsigned stages, const struct cache_entry *ce, int pos)
 static int checkout_stage(int stage, const struct cache_entry *ce, int pos,
 			  const struct checkout *state)
 {
-	while (pos < active_nr &&
-	       !strcmp(active_cache[pos]->name, ce->name)) {
-		if (ce_stage(active_cache[pos]) == stage)
-			return checkout_entry(active_cache[pos], state, NULL);
+	while (pos < the_index.cache_nr &&
+	       !strcmp(the_index.cache[pos]->name, ce->name)) {
+		if (ce_stage(the_index.cache[pos]) == stage)
+			return checkout_entry(the_index.cache[pos], state,
+					      NULL);
 		pos++;
 	}
 	if (stage == 2)
@@ -190,7 +191,7 @@ static int checkout_stage(int stage, const struct cache_entry *ce, int pos,
 
 static int checkout_merged(int pos, const struct checkout *state)
 {
-	struct cache_entry *ce = active_cache[pos];
+	struct cache_entry *ce = the_index.cache[pos];
 	const char *path = ce->name;
 	mmfile_t ancestor, ours, theirs;
 	int status;
@@ -200,7 +201,7 @@ static int checkout_merged(int pos, const struct checkout *state)
 	unsigned mode = 0;
 
 	memset(threeway, 0, sizeof(threeway));
-	while (pos < active_nr) {
+	while (pos < the_index.cache_nr) {
 		int stage;
 		stage = ce_stage(ce);
 		if (!stage || strcmp(path, ce->name))
@@ -209,7 +210,7 @@ static int checkout_merged(int pos, const struct checkout *state)
 		if (stage == 2)
 			mode = create_ce_mode(ce->ce_mode);
 		pos++;
-		ce = active_cache[pos];
+		ce = the_index.cache[pos];
 	}
 	if (is_null_oid(&threeway[1]) || is_null_oid(&threeway[2]))
 		return error(_("path '%s' does not have necessary versions"), path);
@@ -306,8 +307,8 @@ static int checkout_paths(const struct checkout_opts *opts,
 	 * Make sure all pathspecs participated in locating the paths
 	 * to be checked out.
 	 */
-	for (pos = 0; pos < active_nr; pos++) {
-		struct cache_entry *ce = active_cache[pos];
+	for (pos = 0; pos < the_index.cache_nr; pos++) {
+		struct cache_entry *ce = the_index.cache[pos];
 		ce->ce_flags &= ~CE_MATCHED;
 		if (!opts->ignore_skipworktree && ce_skip_worktree(ce))
 			continue;
@@ -349,8 +350,8 @@ static int checkout_paths(const struct checkout_opts *opts,
 		unmerge_marked_index(&the_index);
 
 	/* Any unmerged paths? */
-	for (pos = 0; pos < active_nr; pos++) {
-		const struct cache_entry *ce = active_cache[pos];
+	for (pos = 0; pos < the_index.cache_nr; pos++) {
+		const struct cache_entry *ce = the_index.cache[pos];
 		if (ce->ce_flags & CE_MATCHED) {
 			if (!ce_stage(ce))
 				continue;
@@ -374,8 +375,8 @@ static int checkout_paths(const struct checkout_opts *opts,
 	state.force = 1;
 	state.refresh_cache = 1;
 	state.istate = &the_index;
-	for (pos = 0; pos < active_nr; pos++) {
-		struct cache_entry *ce = active_cache[pos];
+	for (pos = 0; pos < the_index.cache_nr; pos++) {
+		struct cache_entry *ce = the_index.cache[pos];
 		if (ce->ce_flags & CE_MATCHED) {
 			if (!ce_stage(ce)) {
 				errs |= checkout_entry(ce, &state, NULL);
@@ -597,10 +598,10 @@ static int merge_working_tree(const struct checkout_opts *opts,
 		}
 	}
 
-	if (!active_cache_tree)
-		active_cache_tree = cache_tree();
+	if (!the_index.cache_tree)
+		the_index.cache_tree = cache_tree();
 
-	if (!cache_tree_fully_valid(active_cache_tree))
+	if (!cache_tree_fully_valid(the_index.cache_tree))
 		cache_tree_update(&the_index, WRITE_TREE_SILENT | WRITE_TREE_REPAIR);
 
 	if (write_locked_index(&the_index, lock_file, COMMIT_LOCK))
diff --git a/builtin/commit.c b/builtin/commit.c
index 7cd08841a1..01d298c836 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -257,8 +257,8 @@ static int list_paths(struct string_list *list, const char *with_tree,
 		free(max_prefix);
 	}
 
-	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];
 		struct string_list_item *item;
 
 		if (ce->ce_flags & CE_UPDATE)
@@ -418,10 +418,10 @@ static const char *prepare_index(int argc, const char **argv, const char *prefix
 	if (!only && !pathspec.nr) {
 		hold_locked_index(&index_lock, LOCK_DIE_ON_ERROR);
 		refresh_cache_or_die(refresh_flags);
-		if (active_cache_changed
-		    || !cache_tree_fully_valid(active_cache_tree))
+		if (the_index.cache_changed
+		    || !cache_tree_fully_valid(the_index.cache_tree))
 			update_main_cache_tree(WRITE_TREE_SILENT);
-		if (active_cache_changed) {
+		if (the_index.cache_changed) {
 			if (write_locked_index(&the_index, &index_lock,
 					       COMMIT_LOCK))
 				die(_("unable to write new_index file"));
@@ -888,7 +888,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 		struct object_id oid;
 		const char *parent = "HEAD";
 
-		if (!active_nr && read_index(&the_index) < 0)
+		if (!the_index.cache_nr && read_index(&the_index) < 0)
 			die(_("Cannot read index"));
 
 		if (amend)
@@ -897,10 +897,10 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 		if (get_sha1(parent, oid.hash)) {
 			int i, ita_nr = 0;
 
-			for (i = 0; i < active_nr; i++)
-				if (ce_intent_to_add(active_cache[i]))
+			for (i = 0; i < the_index.cache_nr; i++)
+				if (ce_intent_to_add(the_index.cache[i]))
 					ita_nr++;
-			commitable = active_nr - ita_nr > 0;
+			commitable = the_index.cache_nr - ita_nr > 0;
 		} else {
 			/*
 			 * Unless the user did explicitly request a submodule
@@ -1758,7 +1758,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 		append_merge_tag_headers(parents, &tail);
 	}
 
-	if (commit_tree_extended(sb.buf, sb.len, active_cache_tree->sha1,
+	if (commit_tree_extended(sb.buf, sb.len, the_index.cache_tree->sha1,
 			 parents, oid.hash, author_ident.buf, sign_commit, extra)) {
 		rollback_index_files();
 		die(_("failed to write commit object"));
diff --git a/builtin/fsck.c b/builtin/fsck.c
index 35e03556cb..c5d6593d30 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -773,15 +773,15 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
 	if (keep_cache_objects) {
 		verify_index_checksum = 1;
 		read_index(&the_index);
-		for (i = 0; i < active_nr; i++) {
+		for (i = 0; i < the_index.cache_nr; i++) {
 			unsigned int mode;
 			struct blob *blob;
 			struct object *obj;
 
-			mode = active_cache[i]->ce_mode;
+			mode = the_index.cache[i]->ce_mode;
 			if (S_ISGITLINK(mode))
 				continue;
-			blob = lookup_blob(active_cache[i]->oid.hash);
+			blob = lookup_blob(the_index.cache[i]->oid.hash);
 			if (!blob)
 				continue;
 			obj = &blob->object;
@@ -789,11 +789,11 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
 			if (name_objects)
 				add_decoration(fsck_walk_options.object_names,
 					obj,
-					xstrfmt(":%s", active_cache[i]->name));
+					xstrfmt(":%s", the_index.cache[i]->name));
 			mark_object_reachable(obj);
 		}
-		if (active_cache_tree)
-			fsck_cache_tree(active_cache_tree);
+		if (the_index.cache_tree)
+			fsck_cache_tree(the_index.cache_tree);
 	}
 
 	check_connectivity();
diff --git a/builtin/grep.c b/builtin/grep.c
index 5153dbf262..a1150e6f87 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -678,8 +678,8 @@ static int grep_cache(struct grep_opt *opt, const struct pathspec *pathspec,
 
 	read_index(&the_index);
 
-	for (nr = 0; nr < active_nr; nr++) {
-		const struct cache_entry *ce = active_cache[nr];
+	for (nr = 0; nr < the_index.cache_nr; nr++) {
+		const struct cache_entry *ce = the_index.cache[nr];
 		strbuf_setlen(&name, name_base_len);
 		strbuf_addstr(&name, ce->name);
 
@@ -711,8 +711,8 @@ static int grep_cache(struct grep_opt *opt, const struct pathspec *pathspec,
 		if (ce_stage(ce)) {
 			do {
 				nr++;
-			} while (nr < active_nr &&
-				 !strcmp(ce->name, active_cache[nr]->name));
+			} while (nr < the_index.cache_nr &&
+				 !strcmp(ce->name, the_index.cache[nr]->name));
 			nr--; /* compensate for loop control */
 		}
 		if (hit && opt->status_only)
diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index da4779ec0b..edcad6e8e1 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -139,20 +139,20 @@ static void show_killed_files(struct dir_struct *dir)
 					die("BUG: killed-file %.*s not found",
 						ent->len, ent->name);
 				pos = -pos - 1;
-				while (pos < active_nr &&
-				       ce_stage(active_cache[pos]))
+				while (pos < the_index.cache_nr &&
+				       ce_stage(the_index.cache[pos]))
 					pos++; /* skip unmerged */
-				if (active_nr <= pos)
+				if (the_index.cache_nr <= pos)
 					break;
 				/* pos points at a name immediately after
 				 * ent->name in the cache.  Does it expect
 				 * ent->name to be a directory?
 				 */
-				len = ce_namelen(active_cache[pos]);
+				len = ce_namelen(the_index.cache[pos]);
 				if ((ent->len < len) &&
-				    !strncmp(active_cache[pos]->name,
+				    !strncmp(the_index.cache[pos]->name,
 					     ent->name, ent->len) &&
-				    active_cache[pos]->name[ent->len] == '/')
+				    the_index.cache[pos]->name[ent->len] == '/')
 					killed = 1;
 				break;
 			}
@@ -340,8 +340,8 @@ static void show_files(struct dir_struct *dir)
 			show_killed_files(dir);
 	}
 	if (show_cached || show_stage) {
-		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 ((dir->flags & DIR_SHOW_IGNORED) &&
 			    !ce_excluded(dir, ce))
 				continue;
@@ -354,8 +354,8 @@ static void show_files(struct dir_struct *dir)
 		}
 	}
 	if (show_deleted || show_modified) {
-		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];
 			struct stat st;
 			int err;
 			if ((dir->flags & DIR_SHOW_IGNORED) &&
@@ -388,19 +388,19 @@ static void prune_cache(const char *prefix, size_t prefixlen)
 	if (pos < 0)
 		pos = -pos-1;
 	first = pos;
-	last = active_nr;
+	last = the_index.cache_nr;
 	while (last > first) {
 		int next = (last + first) >> 1;
-		const struct cache_entry *ce = active_cache[next];
+		const struct cache_entry *ce = the_index.cache[next];
 		if (!strncmp(ce->name, prefix, prefixlen)) {
 			first = next+1;
 			continue;
 		}
 		last = next;
 	}
-	memmove(active_cache, active_cache + pos,
+	memmove(the_index.cache, the_index.cache + pos,
 		(last - pos) * sizeof(struct cache_entry *));
-	active_nr = last - pos;
+	the_index.cache_nr = last - pos;
 }
 
 /*
@@ -426,8 +426,8 @@ void overlay_tree_on_cache(const char *tree_name, const char *prefix)
 		die("bad tree-ish %s", tree_name);
 
 	/* Hoist the unmerged entries up to stage #3 to make room */
-	for (i = 0; i < active_nr; i++) {
-		struct cache_entry *ce = active_cache[i];
+	for (i = 0; i < the_index.cache_nr; i++) {
+		struct cache_entry *ce = the_index.cache[i];
 		if (!ce_stage(ce))
 			continue;
 		ce->ce_flags |= CE_STAGEMASK;
@@ -443,8 +443,8 @@ void overlay_tree_on_cache(const char *tree_name, const char *prefix)
 	if (read_tree(tree, 1, &pathspec))
 		die("unable to read tree entries %s", tree_name);
 
-	for (i = 0; i < active_nr; i++) {
-		struct cache_entry *ce = active_cache[i];
+	for (i = 0; i < the_index.cache_nr; i++) {
+		struct cache_entry *ce = the_index.cache[i];
 		switch (ce_stage(ce)) {
 		case 0:
 			last_stage0 = ce;
diff --git a/builtin/merge-index.c b/builtin/merge-index.c
index 51fb590dfa..d867ee73f0 100644
--- a/builtin/merge-index.c
+++ b/builtin/merge-index.c
@@ -12,11 +12,11 @@ static int merge_entry(int pos, const char *path)
 	char hexbuf[4][GIT_MAX_HEXSZ + 1];
 	char ownbuf[4][60];
 
-	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))
@@ -26,7 +26,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);
 
@@ -57,8 +57,8 @@ static void merge_one_path(const char *path)
 static void merge_all(void)
 {
 	int i;
-	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;
diff --git a/builtin/merge.c b/builtin/merge.c
index 703827f006..4d4c56050c 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -615,7 +615,7 @@ static int read_tree_trivial(struct object_id *common, struct object_id *head,
 	if (!trees[nr_trees++])
 		return -1;
 	opts.fn = threeway_merge;
-	cache_tree_free(&active_cache_tree);
+	cache_tree_free(&the_index.cache_tree);
 	for (i = 0; i < nr_trees; i++) {
 		parse_tree(trees[i]);
 		init_tree_desc(t+i, trees[i]->buffer, trees[i]->size);
@@ -640,7 +640,7 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
 
 	hold_locked_index(&lock, LOCK_DIE_ON_ERROR);
 	refresh_cache(REFRESH_QUIET);
-	if (active_cache_changed &&
+	if (the_index.cache_changed &&
 	    write_locked_index(&the_index, &lock, COMMIT_LOCK))
 		return error(_("Unable to write index."));
 	rollback_lock_file(&lock);
@@ -680,7 +680,7 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
 				remoteheads->item, reversed, &result);
 		if (clean < 0)
 			exit(128);
-		if (active_cache_changed &&
+		if (the_index.cache_changed &&
 		    write_locked_index(&the_index, &lock, COMMIT_LOCK))
 			die (_("unable to write %s"), get_index_file());
 		rollback_lock_file(&lock);
@@ -703,8 +703,8 @@ static int count_unmerged_entries(void)
 {
 	int i, ret = 0;
 
-	for (i = 0; i < active_nr; i++)
-		if (ce_stage(active_cache[i]))
+	for (i = 0; i < the_index.cache_nr; i++)
+		if (ce_stage(the_index.cache[i]))
 			ret++;
 
 	return ret;
@@ -787,7 +787,7 @@ static int merge_trivial(struct commit *head, struct commit_list *remoteheads)
 
 	hold_locked_index(&lock, LOCK_DIE_ON_ERROR);
 	refresh_cache(REFRESH_QUIET);
-	if (active_cache_changed &&
+	if (the_index.cache_changed &&
 	    write_locked_index(&the_index, &lock, COMMIT_LOCK))
 		return error(_("Unable to write index."));
 	rollback_lock_file(&lock);
diff --git a/builtin/mv.c b/builtin/mv.c
index 6fd7a3a9d8..3b887a9490 100644
--- a/builtin/mv.c
+++ b/builtin/mv.c
@@ -78,7 +78,7 @@ static void prepare_move_submodule(const char *src, int first,
 				   const char **submodule_gitfile)
 {
 	struct strbuf submodule_dotgit = STRBUF_INIT;
-	if (!S_ISGITLINK(active_cache[first]->ce_mode))
+	if (!S_ISGITLINK(the_index.cache[first]->ce_mode))
 		die(_("Directory %s is in index and no submodule?"), src);
 	if (!is_staging_gitmodules_ok())
 		die(_("Please stage your changes to .gitmodules or stash them to proceed"));
@@ -102,8 +102,8 @@ static int index_range_of_same_dir(const char *src, int length,
 		die(_("%.*s is in index"), len_w_slash, src_w_slash);
 
 	first = -1 - first;
-	for (last = first; last < active_nr; last++) {
-		const char *path = active_cache[last]->name;
+	for (last = first; last < the_index.cache_nr; last++) {
+		const char *path = the_index.cache[last]->name;
 		if (strncmp(path, src_w_slash, len_w_slash))
 			break;
 	}
@@ -209,7 +209,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
 				dst_len = strlen(dst);
 
 				for (j = 0; j < last - first; j++) {
-					const char *path = active_cache[first + j]->name;
+					const char *path = the_index.cache[first + j]->name;
 					source[argc + j] = path;
 					destination[argc + j] =
 						prefix_path(dst, dst_len, path + length + 1);
@@ -293,7 +293,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
 	if (gitmodules_modified)
 		stage_updated_gitmodules();
 
-	if (active_cache_changed &&
+	if (the_index.cache_changed &&
 	    write_locked_index(&the_index, &lock_file, COMMIT_LOCK))
 		die(_("Unable to write new index file"));
 
diff --git a/builtin/read-tree.c b/builtin/read-tree.c
index 23e212ee8c..f997814933 100644
--- a/builtin/read-tree.c
+++ b/builtin/read-tree.c
@@ -251,7 +251,7 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)
 	if (opts.debug_unpack)
 		opts.fn = debug_merge;
 
-	cache_tree_free(&active_cache_tree);
+	cache_tree_free(&the_index.cache_tree);
 	for (i = 0; i < nr_trees; i++) {
 		struct tree *tree = trees[i];
 		parse_tree(tree);
diff --git a/builtin/rm.c b/builtin/rm.c
index d0eecbdaac..0813d0a853 100644
--- a/builtin/rm.c
+++ b/builtin/rm.c
@@ -30,8 +30,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++;
 	}
@@ -73,7 +73,7 @@ static void submodules_absorb_gitdir_if_needed(const char *prefix)
 			if (pos < 0)
 				continue;
 		}
-		ce = active_cache[pos];
+		ce = the_index.cache[pos];
 
 		if (!S_ISGITLINK(ce->ce_mode) ||
 		    !file_exists(ce->name) ||
@@ -122,11 +122,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 (errno != ENOENT && errno != ENOTDIR)
@@ -278,8 +278,8 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
 
 	seen = xcalloc(pathspec.nr, 1);
 
-	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_path_match(ce, &pathspec, seen))
 			continue;
 		ALLOC_GROW(list.entry, list.nr + 1, list.alloc);
@@ -386,7 +386,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
 			stage_updated_gitmodules();
 	}
 
-	if (active_cache_changed) {
+	if (the_index.cache_changed) {
 		if (write_locked_index(&the_index, &lock_file, COMMIT_LOCK))
 			die(_("Unable to write new index file"));
 	}
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 1281056312..822c3b3e57 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -243,8 +243,8 @@ static int module_list_compute(int argc, const char **argv,
 	if (read_index(&the_index) < 0)
 		die(_("index file corrupt"));
 
-	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 (!match_pathspec(pathspec, ce->name, ce_namelen(ce),
 				    0, ps_matched, 1) ||
@@ -253,8 +253,8 @@ static int module_list_compute(int argc, const char **argv,
 
 		ALLOC_GROW(list->entries, list->nr + 1, list->alloc);
 		list->entries[list->nr++] = ce;
-		while (i + 1 < active_nr &&
-		       !strcmp(ce->name, active_cache[i + 1]->name))
+		while (i + 1 < the_index.cache_nr &&
+		       !strcmp(ce->name, the_index.cache[i + 1]->name))
 			/*
 			 * Skip entries with the same name in different stages
 			 * to make sure an entry is returned only once.
diff --git a/builtin/update-index.c b/builtin/update-index.c
index 7a4b914af4..9b93e09765 100644
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
@@ -228,12 +228,12 @@ static int mark_ce_flags(const char *path, int flag, int mark)
 	int pos = cache_name_pos(path, namelen);
 	if (0 <= pos) {
 		if (mark)
-			active_cache[pos]->ce_flags |= flag;
+			the_index.cache[pos]->ce_flags |= flag;
 		else
-			active_cache[pos]->ce_flags &= ~flag;
-		active_cache[pos]->ce_flags |= CE_UPDATE_IN_BASE;
+			the_index.cache[pos]->ce_flags &= ~flag;
+		the_index.cache[pos]->ce_flags |= CE_UPDATE_IN_BASE;
 		cache_tree_invalidate_path(&the_index, path);
-		active_cache_changed |= CE_ENTRY_CHANGED;
+		the_index.cache_changed |= CE_ENTRY_CHANGED;
 		return 0;
 	}
 	return -1;
@@ -321,7 +321,7 @@ static int process_directory(const char *path, int len, struct stat *st)
 
 	/* Exact match: file or existing gitlink */
 	if (pos >= 0) {
-		const struct cache_entry *ce = active_cache[pos];
+		const struct cache_entry *ce = the_index.cache[pos];
 		if (S_ISGITLINK(ce->ce_mode)) {
 
 			/* Do nothing to the index if there is no HEAD! */
@@ -336,8 +336,8 @@ static int process_directory(const char *path, int len, struct stat *st)
 
 	/* Inexact match: is there perhaps a subdirectory match? */
 	pos = -pos-1;
-	while (pos < active_nr) {
-		const struct cache_entry *ce = active_cache[pos++];
+	while (pos < the_index.cache_nr) {
+		const struct cache_entry *ce = the_index.cache[pos++];
 
 		if (strncmp(ce->name, path, len))
 			break;
@@ -369,7 +369,7 @@ static int process_path(const char *path)
 		return error("'%s' is beyond a symbolic link", path);
 
 	pos = cache_name_pos(path, len);
-	ce = pos < 0 ? NULL : active_cache[pos];
+	ce = pos < 0 ? NULL : the_index.cache[pos];
 	if (ce && ce_skip_worktree(ce)) {
 		/*
 		 * working directory version is assumed "good"
@@ -431,7 +431,7 @@ static void chmod_path(char flip, const char *path)
 	pos = cache_name_pos(path, strlen(path));
 	if (pos < 0)
 		goto fail;
-	ce = active_cache[pos];
+	ce = the_index.cache[pos];
 	if (chmod_cache_entry(ce, flip) < 0)
 		goto fail;
 
@@ -614,8 +614,8 @@ static int unresolve_one(const char *path)
 	if (0 <= pos) {
 		/* already merged */
 		pos = unmerge_cache_entry_at(pos);
-		if (pos < active_nr) {
-			const struct cache_entry *ce = active_cache[pos];
+		if (pos < the_index.cache_nr) {
+			const struct cache_entry *ce = the_index.cache[pos];
 			if (ce_stage(ce) &&
 			    ce_namelen(ce) == namelen &&
 			    !memcmp(ce->name, path, namelen))
@@ -628,8 +628,8 @@ static int unresolve_one(const char *path)
 		 * want to do anything in the former case.
 		 */
 		pos = -pos-1;
-		if (pos < active_nr) {
-			const struct cache_entry *ce = active_cache[pos];
+		if (pos < the_index.cache_nr) {
+			const struct cache_entry *ce = the_index.cache[pos];
 			if (ce_namelen(ce) == namelen &&
 			    !memcmp(ce->name, path, namelen)) {
 				fprintf(stderr,
@@ -724,8 +724,8 @@ static int do_reupdate(int ac, const char **av,
 		 */
 		has_head = 0;
  redo:
-	for (pos = 0; pos < active_nr; pos++) {
-		const struct cache_entry *ce = active_cache[pos];
+	for (pos = 0; pos < the_index.cache_nr; pos++) {
+		const struct cache_entry *ce = the_index.cache[pos];
 		struct cache_entry *old = NULL;
 		int save_nr;
 		char *path;
@@ -740,16 +740,18 @@ static int do_reupdate(int ac, const char **av,
 			free(old);
 			continue; /* unchanged */
 		}
-		/* Be careful.  The working tree may not have the
+		/*
+		 * Be careful.  The working tree may not have the
 		 * path anymore, in which case, under 'allow_remove',
-		 * or worse yet 'allow_replace', active_nr may decrease.
+		 * or worse yet 'allow_replace', the_index.cache_nr
+		 * may decrease.
 		 */
-		save_nr = active_nr;
+		save_nr = the_index.cache_nr;
 		path = xstrdup(ce->name);
 		update_one(path);
 		free(path);
 		free(old);
-		if (save_nr != active_nr)
+		if (save_nr != the_index.cache_nr)
 			goto redo;
 	}
 	clear_pathspec(&pathspec);
@@ -878,7 +880,7 @@ static int unresolve_callback(struct parse_opt_ctx_t *ctx,
 	*has_errors = do_unresolve(ctx->argc, ctx->argv,
 				prefix, prefix ? strlen(prefix) : 0);
 	if (*has_errors)
-		active_cache_changed = 0;
+		the_index.cache_changed = 0;
 
 	ctx->argv += ctx->argc - 1;
 	ctx->argc = 1;
@@ -896,7 +898,7 @@ static int reupdate_callback(struct parse_opt_ctx_t *ctx,
 	*has_errors = do_reupdate(ctx->argc, ctx->argv,
 				prefix, prefix ? strlen(prefix) : 0);
 	if (*has_errors)
-		active_cache_changed = 0;
+		the_index.cache_changed = 0;
 
 	ctx->argv += ctx->argc - 1;
 	ctx->argc = 1;
@@ -1075,7 +1077,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
 			    INDEX_FORMAT_LB, INDEX_FORMAT_UB);
 
 		if (the_index.version != preferred_index_format)
-			active_cache_changed |= SOMETHING_CHANGED;
+			the_index.cache_changed |= SOMETHING_CHANGED;
 		the_index.version = preferred_index_format;
 	}
 
@@ -1146,7 +1148,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
 		die("BUG: bad untracked_cache value: %d", untracked_cache);
 	}
 
-	if (active_cache_changed) {
+	if (the_index.cache_changed) {
 		if (newfd < 0) {
 			if (refresh_args.flags & REFRESH_QUIET)
 				exit(128);
diff --git a/cache.h b/cache.h
index 9a1ea38a14..4e913d1346 100644
--- a/cache.h
+++ b/cache.h
@@ -354,12 +354,6 @@ extern void free_name_hash(struct index_state *istate);
 
 
 #ifndef NO_THE_INDEX_COMPATIBILITY_MACROS
-#define active_cache (the_index.cache)
-#define active_nr (the_index.cache_nr)
-#define active_alloc (the_index.cache_alloc)
-#define active_cache_changed (the_index.cache_changed)
-#define active_cache_tree (the_index.cache_tree)
-
 #define read_cache_from(path) read_index_from(&the_index, (path))
 #define read_cache_preload(pathspec) read_index_preload(&the_index, (pathspec))
 #define is_cache_unborn() is_index_unborn(&the_index)
diff --git a/check-racy.c b/check-racy.c
index f50b21cb06..6599ae84cf 100644
--- a/check-racy.c
+++ b/check-racy.c
@@ -7,8 +7,8 @@ int main(int ac, char **av)
 
 	dirty = clean = racy = 0;
 	read_index(&the_index);
-	for (i = 0; i < active_nr; i++) {
-		struct cache_entry *ce = active_cache[i];
+	for (i = 0; i < the_index.cache_nr; i++) {
+		struct cache_entry *ce = the_index.cache[i];
 		struct stat st;
 
 		if (lstat(ce->name, &st)) {
diff --git a/diff-lib.c b/diff-lib.c
index 52447466b5..de59ec0459 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -95,10 +95,10 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
 
 	if (diff_unmerged_stage < 0)
 		diff_unmerged_stage = 2;
-	entries = active_nr;
+	entries = the_index.cache_nr;
 	for (i = 0; i < entries; i++) {
 		unsigned int oldmode, newmode;
-		struct cache_entry *ce = active_cache[i];
+		struct cache_entry *ce = the_index.cache[i];
 		int changed;
 		unsigned dirty_submodule = 0;
 		const unsigned char *old_sha1, *new_sha1;
@@ -142,7 +142,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
 			dpath->mode = wt_mode;
 
 			while (i < entries) {
-				struct cache_entry *nce = active_cache[i];
+				struct cache_entry *nce = the_index.cache[i];
 				int stage;
 
 				if (strcmp(ce->name, nce->name))
diff --git a/diff.c b/diff.c
index 05d0312265..37083914c5 100644
--- a/diff.c
+++ b/diff.c
@@ -2736,7 +2736,7 @@ static int reuse_worktree_file(const char *name, const unsigned char *sha1, int
 	 * by diff-cache --cached, which does read the cache before
 	 * calling us.
 	 */
-	if (!active_cache)
+	if (!the_index.cache)
 		return 0;
 
 	/* We want to avoid the working directory if our caller
@@ -2762,7 +2762,7 @@ static int reuse_worktree_file(const char *name, const unsigned char *sha1, int
 	pos = cache_name_pos(name, len);
 	if (pos < 0)
 		return 0;
-	ce = active_cache[pos];
+	ce = the_index.cache[pos];
 
 	/*
 	 * This is not the sha1 we are looking for, or
@@ -3490,10 +3490,10 @@ void diff_setup_done(struct diff_options *options)
 	if (options->detect_rename && options->rename_limit < 0)
 		options->rename_limit = diff_rename_limit_default;
 	if (options->setup & DIFF_SETUP_USE_CACHE) {
-		if (!active_cache)
+		if (!the_index.cache)
 			/* read-cache does not die even when it fails
 			 * so it is safe for us to do this here.  Also
-			 * it does not smudge active_cache or active_nr
+			 * it does not smudge cache or nr of the_index
 			 * when it fails, so we do not have to worry about
 			 * cleaning it up ourselves either.
 			 */
diff --git a/dir.c b/dir.c
index f451bfa48c..8abad1b969 100644
--- a/dir.c
+++ b/dir.c
@@ -599,9 +599,9 @@ static void *read_skip_worktree_file_from_index(const char *path, size_t *size,
 	pos = cache_name_pos(path, len);
 	if (pos < 0)
 		return NULL;
-	if (!ce_skip_worktree(active_cache[pos]))
+	if (!ce_skip_worktree(the_index.cache[pos]))
 		return NULL;
-	data = read_sha1_file(active_cache[pos]->oid.hash, &type, &sz);
+	data = read_sha1_file(the_index.cache[pos]->oid.hash, &type, &sz);
 	if (!data || type != OBJ_BLOB) {
 		free(data);
 		return NULL;
@@ -609,7 +609,7 @@ static void *read_skip_worktree_file_from_index(const char *path, size_t *size,
 	*size = xsize_t(sz);
 	if (sha1_stat) {
 		memset(&sha1_stat->stat, 0, sizeof(sha1_stat->stat));
-		hashcpy(sha1_stat->sha1, active_cache[pos]->oid.hash);
+		hashcpy(sha1_stat->sha1, the_index.cache[pos]->oid.hash);
 	}
 	return data;
 }
@@ -786,11 +786,11 @@ static int add_excludes(const char *fname, const char *base, int baselen,
 				; /* no content change, ss->sha1 still good */
 			else if (check_index &&
 				 (pos = cache_name_pos(fname, strlen(fname))) >= 0 &&
-				 !ce_stage(active_cache[pos]) &&
-				 ce_uptodate(active_cache[pos]) &&
+				 !ce_stage(the_index.cache[pos]) &&
+				 ce_uptodate(the_index.cache[pos]) &&
 				 !would_convert_to_git(fname))
 				hashcpy(sha1_stat->sha1,
-					active_cache[pos]->oid.hash);
+					the_index.cache[pos]->oid.hash);
 			else
 				hash_sha1_file(buf, size, "blob", sha1_stat->sha1);
 			fill_stat_data(&sha1_stat->stat, &st);
@@ -1293,8 +1293,8 @@ static enum exist_status directory_exists_in_index(const char *dirname, int len)
 	pos = cache_name_pos(dirname, len);
 	if (pos < 0)
 		pos = -pos-1;
-	while (pos < active_nr) {
-		const struct cache_entry *ce = active_cache[pos++];
+	while (pos < the_index.cache_nr) {
+		const struct cache_entry *ce = the_index.cache[pos++];
 		unsigned char endchar;
 
 		if (strncmp(ce->name, dirname, len))
@@ -1478,8 +1478,8 @@ static int get_index_dtype(const char *path, int len)
 	if (pos >= 0)
 		return DT_UNKNOWN;
 	pos = -pos-1;
-	while (pos < active_nr) {
-		ce = active_cache[pos++];
+	while (pos < the_index.cache_nr) {
+		ce = the_index.cache[pos++];
 		if (strncmp(ce->name, path, len))
 			break;
 		if (ce->name[len] > '/')
diff --git a/merge-recursive.c b/merge-recursive.c
index 3cfaf33faa..57ca250c88 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -275,7 +275,7 @@ static int git_merge_trees(int index_only,
 	init_tree_desc_from_tree(t+2, merge);
 
 	rc = unpack_trees(3, t, &opts);
-	cache_tree_free(&active_cache_tree);
+	cache_tree_free(&the_index.cache_tree);
 	return rc;
 }
 
@@ -286,8 +286,8 @@ struct tree *write_tree_from_memory(struct merge_options *o)
 	if (unmerged_cache()) {
 		int i;
 		fprintf(stderr, "BUG: There are unmerged index entries:\n");
-		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))
 				fprintf(stderr, "BUG: %d %.*s\n", ce_stage(ce),
 					(int)ce_namelen(ce), ce->name);
@@ -295,16 +295,16 @@ struct tree *write_tree_from_memory(struct merge_options *o)
 		die("BUG: unmerged index entries in merge-recursive.c");
 	}
 
-	if (!active_cache_tree)
-		active_cache_tree = cache_tree();
+	if (!the_index.cache_tree)
+		the_index.cache_tree = cache_tree();
 
-	if (!cache_tree_fully_valid(active_cache_tree) &&
+	if (!cache_tree_fully_valid(the_index.cache_tree) &&
 	    cache_tree_update(&the_index, 0) < 0) {
 		err(o, _("error building trees"));
 		return NULL;
 	}
 
-	result = lookup_tree(active_cache_tree->sha1);
+	result = lookup_tree(the_index.cache_tree->sha1);
 
 	return result;
 }
@@ -370,10 +370,10 @@ static struct string_list *get_unmerged(void)
 
 	unmerged->strdup_strings = 1;
 
-	for (i = 0; i < active_nr; i++) {
+	for (i = 0; i < the_index.cache_nr; i++) {
 		struct string_list_item *item;
 		struct stage_data *e;
-		const struct cache_entry *ce = active_cache[i];
+		const struct cache_entry *ce = the_index.cache[i];
 		if (!ce_stage(ce))
 			continue;
 
@@ -683,8 +683,8 @@ static int dir_in_way(const char *path, int check_working_copy, int empty_ok)
 
 	if (pos < 0)
 		pos = -1 - pos;
-	if (pos < active_nr &&
-	    !strncmp(dirpath.buf, active_cache[pos]->name, dirpath.len)) {
+	if (pos < the_index.cache_nr &&
+	    !strncmp(dirpath.buf, the_index.cache[pos]->name, dirpath.len)) {
 		strbuf_release(&dirpath);
 		return 1;
 	}
@@ -709,9 +709,9 @@ static int was_tracked(const char *path)
 	 * had the path tracked (and resulted in a conflict).
 	 */
 	for (pos = -1 - pos;
-	     pos < active_nr && !strcmp(path, active_cache[pos]->name);
+	     pos < the_index.cache_nr && !strcmp(path, the_index.cache[pos]->name);
 	     pos++)
-		if (ce_stage(active_cache[pos]) == 2)
+		if (ce_stage(the_index.cache[pos]) == 2)
 			return 1;
 	return 0;
 }
@@ -2145,7 +2145,7 @@ int merge_recursive_generic(struct merge_options *o,
 	if (clean < 0)
 		return clean;
 
-	if (active_cache_changed &&
+	if (the_index.cache_changed &&
 	    write_locked_index(&the_index, lock, COMMIT_LOCK))
 		return err(o, _("Unable to write index."));
 
diff --git a/pathspec.c b/pathspec.c
index 50f76fff45..25c2afef30 100644
--- a/pathspec.c
+++ b/pathspec.c
@@ -32,8 +32,8 @@ void add_pathspec_matches_against_index(const struct pathspec *pathspec,
 			num_unmatched++;
 	if (!num_unmatched)
 		return;
-	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];
 		ce_path_match(ce, pathspec, seen);
 	}
 }
@@ -391,7 +391,7 @@ static void strip_submodule_slash_cheap(struct pathspec_item *item)
 	if (item->len >= 1 && item->match[item->len - 1] == '/') {
 		int i = cache_name_pos(item->match, item->len - 1);
 
-		if (i >= 0 && S_ISGITLINK(active_cache[i]->ce_mode)) {
+		if (i >= 0 && S_ISGITLINK(the_index.cache[i]->ce_mode)) {
 			item->len--;
 			item->match[item->len] = '\0';
 		}
@@ -402,8 +402,8 @@ static void strip_submodule_slash_expensive(struct pathspec_item *item)
 {
 	int i;
 
-	for (i = 0; i < active_nr; i++) {
-		struct cache_entry *ce = active_cache[i];
+	for (i = 0; i < the_index.cache_nr; i++) {
+		struct cache_entry *ce = the_index.cache[i];
 		int ce_len = ce_namelen(ce);
 
 		if (!S_ISGITLINK(ce->ce_mode))
@@ -428,8 +428,8 @@ static void die_inside_submodule_path(struct pathspec_item *item)
 {
 	int i;
 
-	for (i = 0; i < active_nr; i++) {
-		struct cache_entry *ce = active_cache[i];
+	for (i = 0; i < the_index.cache_nr; i++) {
+		struct cache_entry *ce = the_index.cache[i];
 		int ce_len = ce_namelen(ce);
 
 		if (!S_ISGITLINK(ce->ce_mode))
diff --git a/read-cache.c b/read-cache.c
index f1bdb006f4..6681376f5b 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1791,7 +1791,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
 	istate->timestamp.nsec = ST_MTIME_NSEC(st);
 
 	while (src_offset <= mmap_size - 20 - 8) {
-		/* After an array of active_nr index entries,
+		/* After an array of the_index.cache_nr index entries,
 		 * there can be arbitrary number of extended
 		 * sections, each of which is prefixed with
 		 * extension name (4-byte) and section length
diff --git a/rerere.c b/rerere.c
index 770b34a5c9..b9b39a959e 100644
--- a/rerere.c
+++ b/rerere.c
@@ -523,7 +523,7 @@ static int handle_file(const char *path, unsigned char *sha1, const char *output
  */
 static int check_one_conflict(int i, int *type)
 {
-	const struct cache_entry *e = active_cache[i];
+	const struct cache_entry *e = the_index.cache[i];
 
 	if (!ce_stage(e)) {
 		*type = RESOLVED;
@@ -531,13 +531,13 @@ static int check_one_conflict(int i, int *type)
 	}
 
 	*type = PUNTED;
-	while (ce_stage(active_cache[i]) == 1)
+	while (ce_stage(the_index.cache[i]) == 1)
 		i++;
 
 	/* Only handle regular files with both stages #2 and #3 */
-	if (i + 1 < active_nr) {
-		const struct cache_entry *e2 = active_cache[i];
-		const struct cache_entry *e3 = active_cache[i + 1];
+	if (i + 1 < the_index.cache_nr) {
+		const struct cache_entry *e2 = the_index.cache[i];
+		const struct cache_entry *e3 = the_index.cache[i + 1];
 		if (ce_stage(e2) == 2 &&
 		    ce_stage(e3) == 3 &&
 		    ce_same_name(e, e3) &&
@@ -547,7 +547,7 @@ static int check_one_conflict(int i, int *type)
 	}
 
 	/* Skip the entries with the same name */
-	while (i < active_nr && ce_same_name(e, active_cache[i]))
+	while (i < the_index.cache_nr && ce_same_name(e, the_index.cache[i]))
 		i++;
 	return i;
 }
@@ -569,9 +569,9 @@ static int find_conflict(struct string_list *conflict)
 	if (read_index(&the_index) < 0)
 		return error("Could not read index");
 
-	for (i = 0; i < active_nr;) {
+	for (i = 0; i < the_index.cache_nr;) {
 		int conflict_type;
-		const struct cache_entry *e = active_cache[i];
+		const struct cache_entry *e = the_index.cache[i];
 		i = check_one_conflict(i, &conflict_type);
 		if (conflict_type == THREE_STAGED)
 			string_list_insert(conflict, (const char *)e->name);
@@ -602,9 +602,9 @@ int rerere_remaining(struct string_list *merge_rr)
 	if (read_index(&the_index) < 0)
 		return error("Could not read index");
 
-	for (i = 0; i < active_nr;) {
+	for (i = 0; i < the_index.cache_nr;) {
 		int conflict_type;
-		const struct cache_entry *e = active_cache[i];
+		const struct cache_entry *e = the_index.cache[i];
 		i = check_one_conflict(i, &conflict_type);
 		if (conflict_type == PUNTED)
 			string_list_insert(merge_rr, (const char *)e->name);
@@ -718,7 +718,7 @@ static void update_paths(struct string_list *update)
 			item->string);
 	}
 
-	if (active_cache_changed) {
+	if (the_index.cache_changed) {
 		if (write_locked_index(&the_index, &index_lock, COMMIT_LOCK))
 			die("Unable to write new index file");
 	} else
@@ -971,11 +971,11 @@ static int handle_cache(const char *path, unsigned char *sha1, const char *outpu
 		return -1;
 	pos = -pos - 1;
 
-	while (pos < active_nr) {
+	while (pos < the_index.cache_nr) {
 		enum object_type type;
 		unsigned long size;
 
-		ce = active_cache[pos++];
+		ce = the_index.cache[pos++];
 		if (ce_namelen(ce) != len || memcmp(ce->name, path, len))
 			break;
 		i = ce_stage(ce) - 1;
diff --git a/revision.c b/revision.c
index bb6250ef02..57d71abdbf 100644
--- a/revision.c
+++ b/revision.c
@@ -1268,8 +1268,8 @@ void add_index_objects_to_pending(struct rev_info *revs, unsigned flags)
 	int i;
 
 	read_index(&the_index);
-	for (i = 0; i < active_nr; i++) {
-		struct cache_entry *ce = active_cache[i];
+	for (i = 0; i < the_index.cache_nr; i++) {
+		struct cache_entry *ce = the_index.cache[i];
 		struct blob *blob;
 
 		if (S_ISGITLINK(ce->ce_mode))
@@ -1282,9 +1282,9 @@ void add_index_objects_to_pending(struct rev_info *revs, unsigned flags)
 					     ce->ce_mode, ce->name);
 	}
 
-	if (active_cache_tree) {
+	if (the_index.cache_tree) {
 		struct strbuf path = STRBUF_INIT;
-		add_cache_tree(active_cache_tree, revs, &path);
+		add_cache_tree(the_index.cache_tree, revs, &path);
 		strbuf_release(&path);
 	}
 }
@@ -1407,10 +1407,10 @@ static void prepare_show_merge(struct rev_info *revs)
 	free_commit_list(bases);
 	head->object.flags |= SYMMETRIC_LEFT;
 
-	if (!active_nr)
+	if (!the_index.cache_nr)
 		read_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;
 		if (ce_path_match(ce, &revs->prune_data, NULL)) {
@@ -1419,8 +1419,8 @@ static void prepare_show_merge(struct rev_info *revs)
 			prune[prune_num-2] = ce->name;
 			prune[prune_num-1] = NULL;
 		}
-		while ((i+1 < active_nr) &&
-		       ce_same_name(ce, active_cache[i+1]))
+		while ((i+1 < the_index.cache_nr) &&
+		       ce_same_name(ce, the_index.cache[i+1]))
 			i++;
 	}
 	clear_pathspec(&revs->prune_data);
diff --git a/sequencer.c b/sequencer.c
index b7ec4e3221..9409b65aaa 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -413,12 +413,12 @@ void append_conflicts_hint(struct strbuf *msgbuf)
 
 	strbuf_addch(msgbuf, '\n');
 	strbuf_commented_addf(msgbuf, "Conflicts:\n");
-	for (i = 0; i < active_nr;) {
-		const struct cache_entry *ce = active_cache[i++];
+	for (i = 0; i < the_index.cache_nr;) {
+		const struct cache_entry *ce = the_index.cache[i++];
 		if (ce_stage(ce)) {
 			strbuf_commented_addf(msgbuf, "\t%s\n", ce->name);
-			while (i < active_nr && !strcmp(ce->name,
-							active_cache[i]->name))
+			while (i < the_index.cache_nr && !strcmp(ce->name,
+							the_index.cache[i]->name))
 				i++;
 		}
 	}
@@ -462,7 +462,7 @@ static int do_recursive_merge(struct commit *base, struct commit *next,
 	if (clean < 0)
 		return clean;
 
-	if (active_cache_changed &&
+	if (the_index.cache_changed &&
 	    write_locked_index(&the_index, &index_lock, COMMIT_LOCK))
 		/* TRANSLATORS: %s will be "revert", "cherry-pick" or
 		 * "rebase -i".
@@ -501,14 +501,15 @@ static int is_index_unchanged(void)
 	if (parse_commit(head_commit))
 		return -1;
 
-	if (!active_cache_tree)
-		active_cache_tree = cache_tree();
+	if (!the_index.cache_tree)
+		the_index.cache_tree = cache_tree();
 
-	if (!cache_tree_fully_valid(active_cache_tree))
+	if (!cache_tree_fully_valid(the_index.cache_tree))
 		if (cache_tree_update(&the_index, 0))
 			return error(_("unable to update cache tree\n"));
 
-	return !hashcmp(active_cache_tree->sha1, head_commit->tree->object.oid.hash);
+	return !hashcmp(the_index.cache_tree->sha1,
+			head_commit->tree->object.oid.hash);
 }
 
 static int write_author_script(const char *message)
diff --git a/sha1_name.c b/sha1_name.c
index 38473b1e6d..b73e261498 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -1444,8 +1444,8 @@ static void diagnose_invalid_index_path(int stage,
 	pos = cache_name_pos(filename, namelen);
 	if (pos < 0)
 		pos = -pos - 1;
-	if (pos < active_nr) {
-		ce = active_cache[pos];
+	if (pos < the_index.cache_nr) {
+		ce = the_index.cache[pos];
 		if (ce_namelen(ce) == namelen &&
 		    !memcmp(ce->name, filename, namelen))
 			die("Path '%s' is in the index, but not at stage %d.\n"
@@ -1460,8 +1460,8 @@ static void diagnose_invalid_index_path(int stage,
 	pos = cache_name_pos(fullname.buf, fullname.len);
 	if (pos < 0)
 		pos = -pos - 1;
-	if (pos < active_nr) {
-		ce = active_cache[pos];
+	if (pos < the_index.cache_nr) {
+		ce = the_index.cache[pos];
 		if (ce_namelen(ce) == fullname.len &&
 		    !memcmp(ce->name, fullname.buf, fullname.len))
 			die("Path '%s' is in the index, but not '%s'.\n"
@@ -1551,13 +1551,13 @@ static int get_sha1_with_context_1(const char *name,
 
 		strlcpy(oc->path, cp, sizeof(oc->path));
 
-		if (!active_cache)
+		if (!the_index.cache)
 			read_index(&the_index);
 		pos = cache_name_pos(cp, namelen);
 		if (pos < 0)
 			pos = -pos - 1;
-		while (pos < active_nr) {
-			ce = active_cache[pos];
+		while (pos < the_index.cache_nr) {
+			ce = the_index.cache[pos];
 			if (ce_namelen(ce) != namelen ||
 			    memcmp(ce->name, cp, namelen))
 				break;
diff --git a/submodule.c b/submodule.c
index 4d77291b11..b225ff6d1f 100644
--- a/submodule.c
+++ b/submodule.c
@@ -182,16 +182,16 @@ void gitmodules_config(void)
 		pos = cache_name_pos(".gitmodules", 11);
 		if (pos < 0) { /* .gitmodules not found or isn't merged */
 			pos = -1 - pos;
-			if (active_nr > pos) {  /* there is a .gitmodules */
-				const struct cache_entry *ce = active_cache[pos];
+			if (the_index.cache_nr > pos) {  /* there is a .gitmodules */
+				const struct cache_entry *ce = the_index.cache[pos];
 				if (ce_namelen(ce) == 11 &&
 				    !memcmp(ce->name, ".gitmodules", 11))
 					gitmodules_is_unmerged = 1;
 			}
-		} else if (pos < active_nr) {
+		} else if (pos < the_index.cache_nr) {
 			struct stat st;
 			if (lstat(".gitmodules", &st) == 0 &&
-			    ce_match_stat(active_cache[pos], &st, 0) & DATA_CHANGED)
+			    ce_match_stat(the_index.cache[pos], &st, 0) & DATA_CHANGED)
 				gitmodules_is_modified = 1;
 		}
 
@@ -1038,11 +1038,11 @@ static int get_next_submodule(struct child_process *cp,
 	int ret = 0;
 	struct submodule_parallel_fetch *spf = data;
 
-	for (; spf->count < active_nr; spf->count++) {
+	for (; spf->count < the_index.cache_nr; spf->count++) {
 		struct strbuf submodule_path = STRBUF_INIT;
 		struct strbuf submodule_git_dir = STRBUF_INIT;
 		struct strbuf submodule_prefix = STRBUF_INIT;
-		const struct cache_entry *ce = active_cache[spf->count];
+		const struct cache_entry *ce = the_index.cache[spf->count];
 		const char *git_dir, *default_argv;
 		const struct submodule *submodule;
 
diff --git a/t/helper/test-dump-cache-tree.c b/t/helper/test-dump-cache-tree.c
index ed037a52f4..1ba09f86d6 100644
--- a/t/helper/test-dump-cache-tree.c
+++ b/t/helper/test-dump-cache-tree.c
@@ -64,5 +64,5 @@ int cmd_main(int ac, const char **av)
 	istate = the_index;
 	istate.cache_tree = another;
 	cache_tree_update(&istate, WRITE_TREE_DRY_RUN);
-	return dump_cache_tree(active_cache_tree, another, "");
+	return dump_cache_tree(the_index.cache_tree, another, "");
 }
diff --git a/t/helper/test-scrap-cache-tree.c b/t/helper/test-scrap-cache-tree.c
index b02a679166..1c640752cd 100644
--- a/t/helper/test-scrap-cache-tree.c
+++ b/t/helper/test-scrap-cache-tree.c
@@ -11,7 +11,7 @@ int cmd_main(int ac, const char **av)
 	hold_locked_index(&index_lock, LOCK_DIE_ON_ERROR);
 	if (read_index(&the_index) < 0)
 		die("unable to read index file");
-	active_cache_tree = NULL;
+	the_index.cache_tree = NULL;
 	if (write_locked_index(&the_index, &index_lock, COMMIT_LOCK))
 		die("unable to write index file");
 	return 0;
diff --git a/t/t2107-update-index-basic.sh b/t/t2107-update-index-basic.sh
index 32ac6e09bd..224d509f9f 100755
--- a/t/t2107-update-index-basic.sh
+++ b/t/t2107-update-index-basic.sh
@@ -74,7 +74,7 @@ test_expect_success '.lock files cleaned up' '
 	cd repo &&
 	git config core.worktree ../../worktree &&
 	# --refresh triggers late setup_work_tree,
-	# active_cache_changed is zero, rollback_lock_file fails
+	# the_index.cache_changed is zero, rollback_lock_file fails
 	git update-index --refresh &&
 	! test -f .git/index.lock
 	)
diff --git a/tree.c b/tree.c
index ce345c5511..82a6ae2a19 100644
--- a/tree.c
+++ b/tree.c
@@ -164,8 +164,8 @@ int read_tree(struct tree *tree, int stage, struct pathspec *match)
 	 * do it the original slow way, otherwise, append and then
 	 * sort at the end.
 	 */
-	for (i = 0; !fn && i < active_nr; i++) {
-		const struct cache_entry *ce = active_cache[i];
+	for (i = 0; !fn && i < the_index.cache_nr; i++) {
+		const struct cache_entry *ce = the_index.cache[i];
 		if (ce_stage(ce) == stage)
 			fn = read_one_entry;
 	}
@@ -179,8 +179,8 @@ int read_tree(struct tree *tree, int stage, struct pathspec *match)
 	/*
 	 * Sort the cache entry -- we need to nuke the cache tree, though.
 	 */
-	cache_tree_free(&active_cache_tree);
-	QSORT(active_cache, active_nr, cmp_cache_name_compare);
+	cache_tree_free(&the_index.cache_tree);
+	QSORT(the_index.cache, the_index.cache_nr, cmp_cache_name_compare);
 	return 0;
 }
 
diff --git a/wt-status.c b/wt-status.c
index 0375484962..750ed28b49 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -487,8 +487,8 @@ static int unmerged_mask(const char *path)
 
 	mask = 0;
 	pos = -pos-1;
-	while (pos < active_nr) {
-		ce = active_cache[pos++];
+	while (pos < the_index.cache_nr) {
+		ce = the_index.cache[pos++];
 		if (strcmp(ce->name, path) || !ce_stage(ce))
 			break;
 		mask |= (1 << (ce_stage(ce) - 1));
@@ -614,10 +614,10 @@ static void wt_status_collect_changes_initial(struct wt_status *s)
 {
 	int i;
 
-	for (i = 0; i < active_nr; i++) {
+	for (i = 0; i < the_index.cache_nr; i++) {
 		struct string_list_item *it;
 		struct wt_status_change_data *d;
-		const struct cache_entry *ce = active_cache[i];
+		const struct cache_entry *ce = the_index.cache[i];
 
 		if (!ce_path_match(ce, &s->pathspec, NULL))
 			continue;
@@ -2099,8 +2099,8 @@ static void wt_porcelain_v2_print_unmerged_entry(
 	pos = cache_name_pos(it->string, strlen(it->string));
 	assert(pos < 0);
 	pos = -pos-1;
-	while (pos < active_nr) {
-		ce = active_cache[pos++];
+	while (pos < the_index.cache_nr) {
+		ce = the_index.cache[pos++];
 		stage = ce_stage(ce);
 		if (strcmp(ce->name, it->string) || !stage)
 			break;
-- 
2.13.0.rc1.39.ga6db8bfa24


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 03/24] cache.h: drop read_cache_from
  2017-05-02 22:22 [PATCH 00/24] Retire NO_THE_INDEX_COMPATIBILITY_MACROS Stefan Beller
  2017-05-02 22:22 ` [PATCH 01/24] cache.h: drop read_cache() Stefan Beller
  2017-05-02 22:23 ` [PATCH 02/24] cache.h: drop active_* macros Stefan Beller
@ 2017-05-02 22:23 ` Stefan Beller
  2017-05-02 22:23 ` [PATCH 04/24] cache.h: drop read_cache_preload(pathspec) Stefan Beller
                   ` (20 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: Stefan Beller @ 2017-05-02 22:23 UTC (permalink / raw)
  To: gitster, git; +Cc: git, Stefan Beller

coccinelle patch:
@@ expression E; @@
-read_cache_from(E)
+read_index_from(&the_index, E)

additionally drop the define from cache.h manually

Signed-off-by: Stefan Beller <sbeller@google.com>
---
 apply.c          | 2 +-
 builtin/am.c     | 4 ++--
 builtin/commit.c | 6 +++---
 cache.h          | 1 -
 4 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/apply.c b/apply.c
index ae1b659b68..159e039a18 100644
--- a/apply.c
+++ b/apply.c
@@ -3985,7 +3985,7 @@ static int check_patch_list(struct apply_state *state, struct patch *patch)
 static int read_apply_cache(struct apply_state *state)
 {
 	if (state->index_file)
-		return read_cache_from(state->index_file);
+		return read_index_from(&the_index, state->index_file);
 	else
 		return read_index(&the_index);
 }
diff --git a/builtin/am.c b/builtin/am.c
index c6a679d8e1..cb3e4dff63 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -1557,7 +1557,7 @@ static int run_apply(const struct am_state *state, const char *index_file)
 	if (index_file) {
 		/* Reload index as apply_all_patches() will have modified it. */
 		discard_cache();
-		read_cache_from(index_file);
+		read_index_from(&the_index, index_file);
 	}
 
 	return 0;
@@ -1600,7 +1600,7 @@ static int fall_back_threeway(const struct am_state *state, const char *index_pa
 		return error("could not build fake ancestor");
 
 	discard_cache();
-	read_cache_from(index_path);
+	read_index_from(&the_index, index_path);
 
 	if (write_index_as_tree(orig_tree.hash, &the_index, index_path, 0, NULL))
 		return error(_("Repository lacks necessary blobs to fall back on 3-way merge."));
diff --git a/builtin/commit.c b/builtin/commit.c
index 01d298c836..65a04ac199 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -370,7 +370,7 @@ static const char *prepare_index(int argc, const char **argv, const char *prefix
 			unsetenv(INDEX_ENVIRONMENT);
 
 		discard_cache();
-		read_cache_from(get_lock_file_path(&index_lock));
+		read_index_from(&the_index, get_lock_file_path(&index_lock));
 		if (update_main_cache_tree(WRITE_TREE_SILENT) == 0) {
 			if (reopen_lock_file(&index_lock) < 0)
 				die(_("unable to write index file"));
@@ -489,7 +489,7 @@ static const char *prepare_index(int argc, const char **argv, const char *prefix
 
 	discard_cache();
 	ret = get_lock_file_path(&false_lock);
-	read_cache_from(ret);
+	read_index_from(&the_index, ret);
 	return ret;
 }
 
@@ -949,7 +949,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 	 * the editor and after we invoke run_status above.
 	 */
 	discard_cache();
-	read_cache_from(index_file);
+	read_index_from(&the_index, index_file);
 	if (update_main_cache_tree(0)) {
 		error(_("Error building trees"));
 		return 0;
diff --git a/cache.h b/cache.h
index 4e913d1346..6abf48dcc3 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_from(path) read_index_from(&the_index, (path))
 #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)
-- 
2.13.0.rc1.39.ga6db8bfa24


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 04/24] cache.h: drop read_cache_preload(pathspec)
  2017-05-02 22:22 [PATCH 00/24] Retire NO_THE_INDEX_COMPATIBILITY_MACROS Stefan Beller
                   ` (2 preceding siblings ...)
  2017-05-02 22:23 ` [PATCH 03/24] cache.h: drop read_cache_from Stefan Beller
@ 2017-05-02 22:23 ` Stefan Beller
  2017-05-02 22:23 ` [PATCH 05/24] cache.h: drop read_cache_unmerged() Stefan Beller
                   ` (19 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: Stefan Beller @ 2017-05-02 22:23 UTC (permalink / raw)
  To: gitster, git; +Cc: git, Stefan Beller

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.39.ga6db8bfa24


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 05/24] cache.h: drop read_cache_unmerged()
  2017-05-02 22:22 [PATCH 00/24] Retire NO_THE_INDEX_COMPATIBILITY_MACROS Stefan Beller
                   ` (3 preceding siblings ...)
  2017-05-02 22:23 ` [PATCH 04/24] cache.h: drop read_cache_preload(pathspec) Stefan Beller
@ 2017-05-02 22:23 ` Stefan Beller
  2017-05-02 22:23 ` [PATCH 06/24] unpack-trees.c: rename parameter 'the_index' Stefan Beller
                   ` (18 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: Stefan Beller @ 2017-05-02 22:23 UTC (permalink / raw)
  To: gitster, git; +Cc: git, Stefan Beller

@@ @@
-read_cache_unmerged()
+read_index_unmerged(&the_index)

Additionally drop the define from cache.h manually.

Signed-off-by: Stefan Beller <sbeller@google.com>
---
 builtin/am.c        | 2 +-
 builtin/merge.c     | 2 +-
 builtin/pull.c      | 2 +-
 builtin/read-tree.c | 2 +-
 builtin/reset.c     | 2 +-
 cache.h             | 1 -
 sequencer.c         | 2 +-
 7 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/builtin/am.c b/builtin/am.c
index cb3e4dff63..bb0927fbcc 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -2053,7 +2053,7 @@ static int clean_index(const struct object_id *head, const struct object_id *rem
 	if (!remote_tree)
 		return error(_("Could not parse object '%s'."), oid_to_hex(remote));
 
-	read_cache_unmerged();
+	read_index_unmerged(&the_index);
 
 	if (fast_forward_to(head_tree, head_tree, 1))
 		return -1;
diff --git a/builtin/merge.c b/builtin/merge.c
index 4d4c56050c..c27c806ac1 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -1170,7 +1170,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 		goto done;
 	}
 
-	if (read_cache_unmerged())
+	if (read_index_unmerged(&the_index))
 		die_resolve_conflict("merge");
 
 	if (file_exists(git_path_merge_head())) {
diff --git a/builtin/pull.c b/builtin/pull.c
index dd1a4a94e4..42578cee05 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -788,7 +788,7 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
 
 	git_config(git_pull_config, NULL);
 
-	if (read_cache_unmerged())
+	if (read_index_unmerged(&the_index))
 		die_resolve_conflict("pull");
 
 	if (file_exists(git_path_merge_head()))
diff --git a/builtin/read-tree.c b/builtin/read-tree.c
index f997814933..0bcf021ead 100644
--- a/builtin/read-tree.c
+++ b/builtin/read-tree.c
@@ -195,7 +195,7 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)
 	 */
 
 	if (opts.reset || opts.merge || opts.prefix) {
-		if (read_cache_unmerged() && (opts.prefix || opts.merge))
+		if (read_index_unmerged(&the_index) && (opts.prefix || opts.merge))
 			die("You need to resolve your current index first");
 		stage = opts.merge = 1;
 	}
diff --git a/builtin/reset.c b/builtin/reset.c
index 03c5498d6e..4a4eb723dd 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -66,7 +66,7 @@ static int reset_index(const struct object_id *oid, int reset_type, int quiet)
 		opts.reset = 1;
 	}
 
-	read_cache_unmerged();
+	read_index_unmerged(&the_index);
 
 	if (reset_type == KEEP) {
 		struct object_id head_oid;
diff --git a/cache.h b/cache.h
index a66ae97fb7..9b94339573 100644
--- a/cache.h
+++ b/cache.h
@@ -355,7 +355,6 @@ extern void free_name_hash(struct index_state *istate);
 
 #ifndef NO_THE_INDEX_COMPATIBILITY_MACROS
 #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)
 #define unmerged_cache() unmerged_index(&the_index)
 #define cache_name_pos(name, namelen) index_name_pos(&the_index,(name),(namelen))
diff --git a/sequencer.c b/sequencer.c
index 9409b65aaa..f20e05fe60 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -349,7 +349,7 @@ static struct tree *empty_tree(void)
 
 static int error_dirty_index(struct replay_opts *opts)
 {
-	if (read_cache_unmerged())
+	if (read_index_unmerged(&the_index))
 		return error_resolve_conflict(_(action_name(opts)));
 
 	error(_("your local changes would be overwritten by %s."),
-- 
2.13.0.rc1.39.ga6db8bfa24


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 06/24] unpack-trees.c: rename parameter 'the_index'
  2017-05-02 22:22 [PATCH 00/24] Retire NO_THE_INDEX_COMPATIBILITY_MACROS Stefan Beller
                   ` (4 preceding siblings ...)
  2017-05-02 22:23 ` [PATCH 05/24] cache.h: drop read_cache_unmerged() Stefan Beller
@ 2017-05-02 22:23 ` Stefan Beller
  2017-05-02 22:23 ` [PATCH 07/24] cache.h: drop read_blob_data_from_cache Stefan Beller
                   ` (17 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: Stefan Beller @ 2017-05-02 22:23 UTC (permalink / raw)
  To: gitster, git; +Cc: git, Stefan Beller

As "the_index" is already a global variable, we do not want to confuse
the local variable with the global variable.

Signed-off-by: Stefan Beller <sbeller@google.com>
---
 unpack-trees.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/unpack-trees.c b/unpack-trees.c
index aa15111fef..3dd8f60fc1 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -1199,7 +1199,7 @@ static int clear_ce_flags(struct cache_entry **cache, int nr,
  * Set/Clear CE_NEW_SKIP_WORKTREE according to $GIT_DIR/info/sparse-checkout
  */
 static void mark_new_skip_worktree(struct exclude_list *el,
-				   struct index_state *the_index,
+				   struct index_state *index,
 				   int select_flag, int skip_wt_flag)
 {
 	int i;
@@ -1208,8 +1208,8 @@ static void mark_new_skip_worktree(struct exclude_list *el,
 	 * 1. Pretend the narrowest worktree: only unmerged entries
 	 * are checked out
 	 */
-	for (i = 0; i < the_index->cache_nr; i++) {
-		struct cache_entry *ce = the_index->cache[i];
+	for (i = 0; i < index->cache_nr; i++) {
+		struct cache_entry *ce = index->cache[i];
 
 		if (select_flag && !(ce->ce_flags & select_flag))
 			continue;
@@ -1224,7 +1224,7 @@ static void mark_new_skip_worktree(struct exclude_list *el,
 	 * 2. Widen worktree according to sparse-checkout file.
 	 * Matched entries will have skip_wt_flag cleared (i.e. "in")
 	 */
-	clear_ce_flags(the_index->cache, the_index->cache_nr,
+	clear_ce_flags(index->cache, index->cache_nr,
 		       select_flag, skip_wt_flag, el);
 }
 
-- 
2.13.0.rc1.39.ga6db8bfa24


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 07/24] cache.h: drop read_blob_data_from_cache
  2017-05-02 22:22 [PATCH 00/24] Retire NO_THE_INDEX_COMPATIBILITY_MACROS Stefan Beller
                   ` (5 preceding siblings ...)
  2017-05-02 22:23 ` [PATCH 06/24] unpack-trees.c: rename parameter 'the_index' Stefan Beller
@ 2017-05-02 22:23 ` Stefan Beller
  2017-05-02 22:23 ` [PATCH 08/24] cache.h: drop unmerge_cache[_entry_at] Stefan Beller
                   ` (16 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: Stefan Beller @ 2017-05-02 22:23 UTC (permalink / raw)
  To: gitster, git; +Cc: git, Stefan Beller

This was done without cocinelle, as we only have 2 occurrences.

Signed-off-by: Stefan Beller <sbeller@google.com>
---
 cache.h   | 1 -
 convert.c | 4 ++--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/cache.h b/cache.h
index 9b94339573..d078e88c3f 100644
--- a/cache.h
+++ b/cache.h
@@ -374,7 +374,6 @@ extern void free_name_hash(struct index_state *istate);
 #define resolve_undo_clear() resolve_undo_clear_index(&the_index)
 #define unmerge_cache_entry_at(at) unmerge_index_entry_at(&the_index, at)
 #define unmerge_cache(pathspec) unmerge_index(&the_index, pathspec)
-#define read_blob_data_from_cache(path, sz) read_blob_data_from_index(&the_index, (path), (sz))
 #endif
 
 enum object_type {
diff --git a/convert.c b/convert.c
index 8d652bf27c..cf29280ae1 100644
--- a/convert.c
+++ b/convert.c
@@ -137,7 +137,7 @@ const char *get_cached_convert_stats_ascii(const char *path)
 {
 	const char *ret;
 	unsigned long sz;
-	void *data = read_blob_data_from_cache(path, &sz);
+	void *data = read_blob_data_from_index(&the_index, path, &sz);
 	ret = gather_convert_stats_ascii(data, sz);
 	free(data);
 	return ret;
@@ -222,7 +222,7 @@ static int has_cr_in_index(const char *path)
 	void *data;
 	int has_cr;
 
-	data = read_blob_data_from_cache(path, &sz);
+	data = read_blob_data_from_index(&the_index, path, &sz);
 	if (!data)
 		return 0;
 	has_cr = memchr(data, '\r', sz) != NULL;
-- 
2.13.0.rc1.39.ga6db8bfa24


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 08/24] cache.h: drop unmerge_cache[_entry_at]
  2017-05-02 22:22 [PATCH 00/24] Retire NO_THE_INDEX_COMPATIBILITY_MACROS Stefan Beller
                   ` (6 preceding siblings ...)
  2017-05-02 22:23 ` [PATCH 07/24] cache.h: drop read_blob_data_from_cache Stefan Beller
@ 2017-05-02 22:23 ` Stefan Beller
  2017-05-02 22:23 ` [PATCH 09/24] cache.h: drop resolve_undo_clear Stefan Beller
                   ` (15 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: Stefan Beller @ 2017-05-02 22:23 UTC (permalink / raw)
  To: gitster, git; +Cc: git, Stefan Beller

Signed-off-by: Stefan Beller <sbeller@google.com>
---
 builtin/update-index.c | 2 +-
 cache.h                | 2 --
 rerere.c               | 2 +-
 3 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/builtin/update-index.c b/builtin/update-index.c
index 8667c48446..b8458016f0 100644
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
@@ -613,7 +613,7 @@ static int unresolve_one(const char *path)
 	pos = cache_name_pos(path, namelen);
 	if (0 <= pos) {
 		/* already merged */
-		pos = unmerge_cache_entry_at(pos);
+		pos = unmerge_index_entry_at(&the_index, pos);
 		if (pos < the_index.cache_nr) {
 			const struct cache_entry *ce = the_index.cache[pos];
 			if (ce_stage(ce) &&
diff --git a/cache.h b/cache.h
index d078e88c3f..8a2dc393dc 100644
--- a/cache.h
+++ b/cache.h
@@ -372,8 +372,6 @@ extern void free_name_hash(struct index_state *istate);
 #define cache_file_exists(name, namelen, igncase) index_file_exists(&the_index, (name), (namelen), (igncase))
 #define cache_name_is_other(name, namelen) index_name_is_other(&the_index, (name), (namelen))
 #define resolve_undo_clear() resolve_undo_clear_index(&the_index)
-#define unmerge_cache_entry_at(at) unmerge_index_entry_at(&the_index, at)
-#define unmerge_cache(pathspec) unmerge_index(&the_index, pathspec)
 #endif
 
 enum object_type {
diff --git a/rerere.c b/rerere.c
index b9b39a959e..03218166ab 100644
--- a/rerere.c
+++ b/rerere.c
@@ -1116,7 +1116,7 @@ int rerere_forget(struct pathspec *pathspec)
 	 * recover the original conflicted state and then
 	 * find the conflicted paths.
 	 */
-	unmerge_cache(pathspec);
+	unmerge_index(&the_index, pathspec);
 	find_conflict(&conflict);
 	for (i = 0; i < conflict.nr; i++) {
 		struct string_list_item *it = &conflict.items[i];
-- 
2.13.0.rc1.39.ga6db8bfa24


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 09/24] cache.h: drop resolve_undo_clear
  2017-05-02 22:22 [PATCH 00/24] Retire NO_THE_INDEX_COMPATIBILITY_MACROS Stefan Beller
                   ` (7 preceding siblings ...)
  2017-05-02 22:23 ` [PATCH 08/24] cache.h: drop unmerge_cache[_entry_at] Stefan Beller
@ 2017-05-02 22:23 ` Stefan Beller
  2017-05-02 22:23 ` [PATCH 10/24] cache.h: drop cache_name_is_other Stefan Beller
                   ` (14 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: Stefan Beller @ 2017-05-02 22:23 UTC (permalink / raw)
  To: gitster, git; +Cc: git, Stefan Beller

Signed-off-by: Stefan Beller <sbeller@google.com>
---
 builtin/checkout.c     | 2 +-
 builtin/merge.c        | 2 +-
 builtin/read-tree.c    | 2 +-
 builtin/update-index.c | 2 +-
 cache.h                | 1 -
 merge.c                | 2 +-
 6 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/builtin/checkout.c b/builtin/checkout.c
index 2328a475ea..abcc45a74f 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -491,7 +491,7 @@ static int merge_working_tree(const struct checkout_opts *opts,
 	if (read_index_preload(&the_index, NULL) < 0)
 		return error(_("index file corrupt"));
 
-	resolve_undo_clear();
+	resolve_undo_clear_index(&the_index);
 	if (opts->force) {
 		ret = reset_tree(new->commit->tree, opts, 1, writeout_error);
 		if (ret)
diff --git a/builtin/merge.c b/builtin/merge.c
index c27c806ac1..b023107d26 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -1191,7 +1191,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 		else
 			die(_("You have not concluded your cherry-pick (CHERRY_PICK_HEAD exists)."));
 	}
-	resolve_undo_clear();
+	resolve_undo_clear_index(&the_index);
 
 	if (verbosity < 0)
 		show_diffstat = 0;
diff --git a/builtin/read-tree.c b/builtin/read-tree.c
index 0bcf021ead..61f5f6f028 100644
--- a/builtin/read-tree.c
+++ b/builtin/read-tree.c
@@ -199,7 +199,7 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)
 			die("You need to resolve your current index first");
 		stage = opts.merge = 1;
 	}
-	resolve_undo_clear();
+	resolve_undo_clear_index(&the_index);
 
 	for (i = 0; i < argc; i++) {
 		const char *arg = argv[i];
diff --git a/builtin/update-index.c b/builtin/update-index.c
index b8458016f0..c9f06169c0 100644
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
@@ -796,7 +796,7 @@ static int chmod_callback(const struct option *opt,
 static int resolve_undo_clear_callback(const struct option *opt,
 				const char *arg, int unset)
 {
-	resolve_undo_clear();
+	resolve_undo_clear_index(&the_index);
 	return 0;
 }
 
diff --git a/cache.h b/cache.h
index 8a2dc393dc..abf1474034 100644
--- a/cache.h
+++ b/cache.h
@@ -371,7 +371,6 @@ extern void free_name_hash(struct index_state *istate);
 #define cache_dir_exists(name, namelen) index_dir_exists(&the_index, (name), (namelen))
 #define cache_file_exists(name, namelen, igncase) index_file_exists(&the_index, (name), (namelen), (igncase))
 #define cache_name_is_other(name, namelen) index_name_is_other(&the_index, (name), (namelen))
-#define resolve_undo_clear() resolve_undo_clear_index(&the_index)
 #endif
 
 enum object_type {
diff --git a/merge.c b/merge.c
index 748305031e..06509a6df2 100644
--- a/merge.c
+++ b/merge.c
@@ -39,7 +39,7 @@ int try_merge_command(const char *strategy, size_t xopts_nr,
 	discard_cache();
 	if (read_index(&the_index) < 0)
 		die(_("failed to read the cache"));
-	resolve_undo_clear();
+	resolve_undo_clear_index(&the_index);
 
 	return ret;
 }
-- 
2.13.0.rc1.39.ga6db8bfa24


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 10/24] cache.h: drop cache_name_is_other
  2017-05-02 22:22 [PATCH 00/24] Retire NO_THE_INDEX_COMPATIBILITY_MACROS Stefan Beller
                   ` (8 preceding siblings ...)
  2017-05-02 22:23 ` [PATCH 09/24] cache.h: drop resolve_undo_clear Stefan Beller
@ 2017-05-02 22:23 ` Stefan Beller
  2017-05-02 22:23 ` [PATCH 11/24] cache.h: drop cache_file_exists Stefan Beller
                   ` (13 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: Stefan Beller @ 2017-05-02 22:23 UTC (permalink / raw)
  To: gitster, git; +Cc: git, Stefan Beller

Signed-off-by: Stefan Beller <sbeller@google.com>
---
 builtin/clean.c    | 2 +-
 builtin/ls-files.c | 2 +-
 cache.h            | 1 -
 dir.c              | 2 +-
 wt-status.c        | 4 ++--
 5 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/builtin/clean.c b/builtin/clean.c
index 9bdefca6dc..c6aacbb0f0 100644
--- a/builtin/clean.c
+++ b/builtin/clean.c
@@ -938,7 +938,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
 		struct stat st;
 		const char *rel;
 
-		if (!cache_name_is_other(ent->name, ent->len))
+		if (!index_name_is_other(&the_index, ent->name, ent->len))
 			continue;
 
 		if (pathspec.nr)
diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index edcad6e8e1..6f7ecec1b0 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -114,7 +114,7 @@ static void show_other_files(struct dir_struct *dir)
 
 	for (i = 0; i < dir->nr; i++) {
 		struct dir_entry *ent = dir->entries[i];
-		if (!cache_name_is_other(ent->name, ent->len))
+		if (!index_name_is_other(&the_index, ent->name, ent->len))
 			continue;
 		show_dir_entry(tag_other, ent);
 	}
diff --git a/cache.h b/cache.h
index abf1474034..5de8ab4e69 100644
--- a/cache.h
+++ b/cache.h
@@ -370,7 +370,6 @@ extern void free_name_hash(struct index_state *istate);
 #define ce_modified(ce, st, options) ie_modified(&the_index, (ce), (st), (options))
 #define cache_dir_exists(name, namelen) index_dir_exists(&the_index, (name), (namelen))
 #define cache_file_exists(name, namelen, igncase) index_file_exists(&the_index, (name), (namelen), (igncase))
-#define cache_name_is_other(name, namelen) index_name_is_other(&the_index, (name), (namelen))
 #endif
 
 enum object_type {
diff --git a/dir.c b/dir.c
index 8abad1b969..d5e1c462bb 100644
--- a/dir.c
+++ b/dir.c
@@ -1244,7 +1244,7 @@ static struct dir_entry *dir_add_name(struct dir_struct *dir, const char *pathna
 
 struct dir_entry *dir_add_ignored(struct dir_struct *dir, const char *pathname, int len)
 {
-	if (!cache_name_is_other(pathname, len))
+	if (!index_name_is_other(&the_index, pathname, len))
 		return NULL;
 
 	ALLOC_GROW(dir->ignored, dir->ignored_nr+1, dir->ignored_alloc);
diff --git a/wt-status.c b/wt-status.c
index 750ed28b49..ff0e70a25a 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -669,7 +669,7 @@ static void wt_status_collect_untracked(struct wt_status *s)
 
 	for (i = 0; i < dir.nr; i++) {
 		struct dir_entry *ent = dir.entries[i];
-		if (cache_name_is_other(ent->name, ent->len) &&
+		if (index_name_is_other(&the_index, ent->name, ent->len) &&
 		    dir_path_match(ent, &s->pathspec, 0, NULL))
 			string_list_insert(&s->untracked, ent->name);
 		free(ent);
@@ -677,7 +677,7 @@ static void wt_status_collect_untracked(struct wt_status *s)
 
 	for (i = 0; i < dir.ignored_nr; i++) {
 		struct dir_entry *ent = dir.ignored[i];
-		if (cache_name_is_other(ent->name, ent->len) &&
+		if (index_name_is_other(&the_index, ent->name, ent->len) &&
 		    dir_path_match(ent, &s->pathspec, 0, NULL))
 			string_list_insert(&s->ignored, ent->name);
 		free(ent);
-- 
2.13.0.rc1.39.ga6db8bfa24


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 11/24] cache.h: drop cache_file_exists
  2017-05-02 22:22 [PATCH 00/24] Retire NO_THE_INDEX_COMPATIBILITY_MACROS Stefan Beller
                   ` (9 preceding siblings ...)
  2017-05-02 22:23 ` [PATCH 10/24] cache.h: drop cache_name_is_other Stefan Beller
@ 2017-05-02 22:23 ` Stefan Beller
  2017-05-02 22:23 ` [PATCH 12/24] cache.h: drop cache_dir_exists Stefan Beller
                   ` (12 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: Stefan Beller @ 2017-05-02 22:23 UTC (permalink / raw)
  To: gitster, git; +Cc: git, Stefan Beller

Signed-off-by: Stefan Beller <sbeller@google.com>
---
 apply.c           | 2 +-
 cache.h           | 1 -
 dir.c             | 9 +++++----
 merge-recursive.c | 3 ++-
 4 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/apply.c b/apply.c
index 159e039a18..eb8eaeabec 100644
--- a/apply.c
+++ b/apply.c
@@ -3810,7 +3810,7 @@ static int path_is_beyond_symlink_1(struct apply_state *state, struct strbuf *na
 		if (state->check_index) {
 			struct cache_entry *ce;
 
-			ce = cache_file_exists(name->buf, name->len, ignore_case);
+			ce = index_file_exists(&the_index, name->buf, name->len, ignore_case);
 			if (ce && S_ISLNK(ce->ce_mode))
 				return 1;
 		} else {
diff --git a/cache.h b/cache.h
index 5de8ab4e69..85a85f8b96 100644
--- a/cache.h
+++ b/cache.h
@@ -369,7 +369,6 @@ extern void free_name_hash(struct index_state *istate);
 #define ce_match_stat(ce, st, options) ie_match_stat(&the_index, (ce), (st), (options))
 #define ce_modified(ce, st, options) ie_modified(&the_index, (ce), (st), (options))
 #define cache_dir_exists(name, namelen) index_dir_exists(&the_index, (name), (namelen))
-#define cache_file_exists(name, namelen, igncase) index_file_exists(&the_index, (name), (namelen), (igncase))
 #endif
 
 enum object_type {
diff --git a/dir.c b/dir.c
index d5e1c462bb..0327832e53 100644
--- a/dir.c
+++ b/dir.c
@@ -1235,7 +1235,7 @@ static struct dir_entry *dir_entry_new(const char *pathname, int len)
 
 static struct dir_entry *dir_add_name(struct dir_struct *dir, const char *pathname, int len)
 {
-	if (cache_file_exists(pathname, len, ignore_case))
+	if (index_file_exists(&the_index, pathname, len, ignore_case))
 		return NULL;
 
 	ALLOC_GROW(dir->entries, dir->nr+1, dir->alloc);
@@ -1269,7 +1269,7 @@ static enum exist_status directory_exists_in_index_icase(const char *dirname, in
 	if (cache_dir_exists(dirname, len))
 		return index_directory;
 
-	ce = cache_file_exists(dirname, len, ignore_case);
+	ce = index_file_exists(&the_index, dirname, len, ignore_case);
 	if (ce && S_ISGITLINK(ce->ce_mode))
 		return index_gitdir;
 
@@ -1460,7 +1460,7 @@ static int get_index_dtype(const char *path, int len)
 	int pos;
 	const struct cache_entry *ce;
 
-	ce = cache_file_exists(path, len, 0);
+	ce = index_file_exists(&the_index, path, len, 0);
 	if (ce) {
 		if (!ce_uptodate(ce))
 			return DT_UNKNOWN;
@@ -1522,7 +1522,8 @@ static enum path_treatment treat_one_path(struct dir_struct *dir,
 					  int dtype, struct dirent *de)
 {
 	int exclude;
-	int has_path_in_index = !!cache_file_exists(path->buf, path->len, ignore_case);
+	int has_path_in_index = !!index_file_exists(&the_index, path->buf,
+						    path->len, ignore_case);
 
 	if (dtype == DT_UNKNOWN)
 		dtype = get_dtype(de, path->buf, path->len);
diff --git a/merge-recursive.c b/merge-recursive.c
index 57ca250c88..b8b3a153f1 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -623,7 +623,8 @@ static int remove_file(struct merge_options *o, int clean,
 	if (update_working_directory) {
 		if (ignore_case) {
 			struct cache_entry *ce;
-			ce = cache_file_exists(path, strlen(path), ignore_case);
+			ce = index_file_exists(&the_index, path,
+					       strlen(path), ignore_case);
 			if (ce && ce_stage(ce) == 0)
 				return 0;
 		}
-- 
2.13.0.rc1.39.ga6db8bfa24


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 12/24] cache.h: drop cache_dir_exists
  2017-05-02 22:22 [PATCH 00/24] Retire NO_THE_INDEX_COMPATIBILITY_MACROS Stefan Beller
                   ` (10 preceding siblings ...)
  2017-05-02 22:23 ` [PATCH 11/24] cache.h: drop cache_file_exists Stefan Beller
@ 2017-05-02 22:23 ` Stefan Beller
  2017-05-02 22:23 ` [PATCH 13/24] cache.h: drop is_cache_unborn(), discard_cache(), unmerged_cache() Stefan Beller
                   ` (11 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: Stefan Beller @ 2017-05-02 22:23 UTC (permalink / raw)
  To: gitster, git; +Cc: git, Stefan Beller

Signed-off-by: Stefan Beller <sbeller@google.com>
---
 cache.h | 1 -
 dir.c   | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/cache.h b/cache.h
index 85a85f8b96..4b8e8c31fe 100644
--- a/cache.h
+++ b/cache.h
@@ -368,7 +368,6 @@ extern void free_name_hash(struct index_state *istate);
 #define refresh_cache(flags) refresh_index(&the_index, (flags), NULL, NULL, NULL)
 #define ce_match_stat(ce, st, options) ie_match_stat(&the_index, (ce), (st), (options))
 #define ce_modified(ce, st, options) ie_modified(&the_index, (ce), (st), (options))
-#define cache_dir_exists(name, namelen) index_dir_exists(&the_index, (name), (namelen))
 #endif
 
 enum object_type {
diff --git a/dir.c b/dir.c
index 0327832e53..63edaec2ef 100644
--- a/dir.c
+++ b/dir.c
@@ -1266,7 +1266,7 @@ static enum exist_status directory_exists_in_index_icase(const char *dirname, in
 {
 	struct cache_entry *ce;
 
-	if (cache_dir_exists(dirname, len))
+	if (index_dir_exists(&the_index, dirname, len))
 		return index_directory;
 
 	ce = index_file_exists(&the_index, dirname, len, ignore_case);
-- 
2.13.0.rc1.39.ga6db8bfa24


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 13/24] cache.h: drop is_cache_unborn(), discard_cache(), unmerged_cache()
  2017-05-02 22:22 [PATCH 00/24] Retire NO_THE_INDEX_COMPATIBILITY_MACROS Stefan Beller
                   ` (11 preceding siblings ...)
  2017-05-02 22:23 ` [PATCH 12/24] cache.h: drop cache_dir_exists Stefan Beller
@ 2017-05-02 22:23 ` Stefan Beller
  2017-05-02 22:23 ` [PATCH 14/24] cache.h: drop cache_name_pos Stefan Beller
                   ` (10 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: Stefan Beller @ 2017-05-02 22:23 UTC (permalink / raw)
  To: gitster, git; +Cc: git, Stefan Beller

cocci semantic patch:
@@ @@
-is_cache_unborn()
+is_index_unborn(&the_index)
@@ @@
-discard_cache()
+discard_index(&the_index)
@@ @@
-unmerged_cache()
+unmerged_index(&the_index)

Additionally the defines in cache.h were removed manually.

Signed-off-by: Stefan Beller <sbeller@google.com>
---
 builtin/am.c                        |  8 ++++----
 builtin/blame.c                     |  2 +-
 builtin/checkout.c                  |  4 ++--
 builtin/commit.c                    | 10 +++++-----
 builtin/diff.c                      |  2 +-
 builtin/pull.c                      |  2 +-
 builtin/read-tree.c                 |  2 +-
 builtin/reset.c                     |  2 +-
 cache.h                             |  3 ---
 merge-recursive.c                   |  8 ++++----
 merge.c                             |  2 +-
 sequencer.c                         |  4 ++--
 t/helper/test-lazy-init-name-hash.c | 10 +++++-----
 t/helper/test-read-cache.c          |  2 +-
 wt-status.c                         |  2 +-
 15 files changed, 30 insertions(+), 33 deletions(-)

diff --git a/builtin/am.c b/builtin/am.c
index bb0927fbcc..38fc4566f7 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -1556,7 +1556,7 @@ static int run_apply(const struct am_state *state, const char *index_file)
 
 	if (index_file) {
 		/* Reload index as apply_all_patches() will have modified it. */
-		discard_cache();
+		discard_index(&the_index);
 		read_index_from(&the_index, index_file);
 	}
 
@@ -1599,7 +1599,7 @@ static int fall_back_threeway(const struct am_state *state, const char *index_pa
 	if (build_fake_ancestor(state, index_path))
 		return error("could not build fake ancestor");
 
-	discard_cache();
+	discard_index(&the_index);
 	read_index_from(&the_index, index_path);
 
 	if (write_index_as_tree(orig_tree.hash, &the_index, index_path, 0, NULL))
@@ -1632,7 +1632,7 @@ static int fall_back_threeway(const struct am_state *state, const char *index_pa
 
 	say(state, stdout, _("Falling back to patching base and 3-way merge..."));
 
-	discard_cache();
+	discard_index(&the_index);
 	read_index(&the_index);
 
 	/*
@@ -1938,7 +1938,7 @@ static void am_resolve(struct am_state *state)
 		die_user_resolve(state);
 	}
 
-	if (unmerged_cache()) {
+	if (unmerged_index(&the_index)) {
 		printf_ln(_("You still have unmerged paths in your index.\n"
 			"Did you forget to use 'git add'?"));
 		die_user_resolve(state);
diff --git a/builtin/blame.c b/builtin/blame.c
index cbb7c1fd9d..b47aae25d4 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -2394,7 +2394,7 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,
 	 * bits; we are not going to write this index out -- we just
 	 * want to run "diff-index --cached".
 	 */
-	discard_cache();
+	discard_index(&the_index);
 	read_index(&the_index);
 
 	len = strlen(path);
diff --git a/builtin/checkout.c b/builtin/checkout.c
index abcc45a74f..a6cd8c0f37 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -510,13 +510,13 @@ static int merge_working_tree(const struct checkout_opts *opts,
 
 		refresh_cache(REFRESH_QUIET);
 
-		if (unmerged_cache()) {
+		if (unmerged_index(&the_index)) {
 			error(_("you need to resolve your current index first"));
 			return 1;
 		}
 
 		/* 2-way merge to the new branch */
-		topts.initial_checkout = is_cache_unborn();
+		topts.initial_checkout = is_index_unborn(&the_index);
 		topts.update = 1;
 		topts.merge = 1;
 		topts.gently = opts->merge && old->commit;
diff --git a/builtin/commit.c b/builtin/commit.c
index 687e7c8a3a..ef12ea3991 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -301,7 +301,7 @@ static void create_base_index(const struct commit *current_head)
 	struct tree_desc t;
 
 	if (!current_head) {
-		discard_cache();
+		discard_index(&the_index);
 		return;
 	}
 
@@ -369,7 +369,7 @@ static const char *prepare_index(int argc, const char **argv, const char *prefix
 		else
 			unsetenv(INDEX_ENVIRONMENT);
 
-		discard_cache();
+		discard_index(&the_index);
 		read_index_from(&the_index, get_lock_file_path(&index_lock));
 		if (update_main_cache_tree(WRITE_TREE_SILENT) == 0) {
 			if (reopen_lock_file(&index_lock) < 0)
@@ -464,7 +464,7 @@ static const char *prepare_index(int argc, const char **argv, const char *prefix
 	if (list_paths(&partial, !current_head ? NULL : "HEAD", prefix, &pathspec))
 		exit(1);
 
-	discard_cache();
+	discard_index(&the_index);
 	if (read_index(&the_index) < 0)
 		die(_("cannot read the index"));
 
@@ -487,7 +487,7 @@ static const char *prepare_index(int argc, const char **argv, const char *prefix
 	if (write_locked_index(&the_index, &false_lock, CLOSE_LOCK))
 		die(_("unable to write temporary index file"));
 
-	discard_cache();
+	discard_index(&the_index);
 	ret = get_lock_file_path(&false_lock);
 	read_index_from(&the_index, ret);
 	return ret;
@@ -948,7 +948,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 	 * and write it out as a tree.  We must do this before we invoke
 	 * the editor and after we invoke run_status above.
 	 */
-	discard_cache();
+	discard_index(&the_index);
 	read_index_from(&the_index, index_file);
 	if (update_main_cache_tree(0)) {
 		error(_("Error building trees"));
diff --git a/builtin/diff.c b/builtin/diff.c
index 0ae33bce2b..1efd0d6b61 100644
--- a/builtin/diff.c
+++ b/builtin/diff.c
@@ -209,7 +209,7 @@ static void refresh_index_quietly(void)
 	fd = hold_locked_index(lock_file, 0);
 	if (fd < 0)
 		return;
-	discard_cache();
+	discard_index(&the_index);
 	read_index(&the_index);
 	refresh_cache(REFRESH_QUIET|REFRESH_UNMERGED);
 	update_index_if_able(&the_index, lock_file);
diff --git a/builtin/pull.c b/builtin/pull.c
index 42578cee05..57f9833367 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -805,7 +805,7 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
 		if (opt_autostash != -1)
 			autostash = opt_autostash;
 
-		if (is_null_oid(&orig_head) && !is_cache_unborn())
+		if (is_null_oid(&orig_head) && !is_index_unborn(&the_index))
 			die(_("Updating an unborn branch with changes added to the index."));
 
 		if (!autostash)
diff --git a/builtin/read-tree.c b/builtin/read-tree.c
index 61f5f6f028..2b8f0a0b3a 100644
--- a/builtin/read-tree.c
+++ b/builtin/read-tree.c
@@ -234,7 +234,7 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)
 			break;
 		case 2:
 			opts.fn = twoway_merge;
-			opts.initial_checkout = is_cache_unborn();
+			opts.initial_checkout = is_index_unborn(&the_index);
 			break;
 		case 3:
 		default:
diff --git a/builtin/reset.c b/builtin/reset.c
index 4a4eb723dd..f8073b1caa 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -179,7 +179,7 @@ static void set_reflog_message(struct strbuf *sb, const char *action,
 
 static void die_if_unmerged_cache(int reset_type)
 {
-	if (is_merge() || unmerged_cache())
+	if (is_merge() || unmerged_index(&the_index))
 		die(_("Cannot do a %s reset in the middle of a merge."),
 		    _(reset_type_names[reset_type]));
 
diff --git a/cache.h b/cache.h
index 4b8e8c31fe..a021d6e988 100644
--- a/cache.h
+++ b/cache.h
@@ -354,9 +354,6 @@ extern void free_name_hash(struct index_state *istate);
 
 
 #ifndef NO_THE_INDEX_COMPATIBILITY_MACROS
-#define is_cache_unborn() is_index_unborn(&the_index)
-#define discard_cache() discard_index(&the_index)
-#define unmerged_cache() unmerged_index(&the_index)
 #define cache_name_pos(name, namelen) index_name_pos(&the_index,(name),(namelen))
 #define add_cache_entry(ce, option) add_index_entry(&the_index, (ce), (option))
 #define rename_cache_entry_at(pos, new_name) rename_index_entry_at(&the_index, (pos), (new_name))
diff --git a/merge-recursive.c b/merge-recursive.c
index b8b3a153f1..eb0f0c6960 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -283,7 +283,7 @@ struct tree *write_tree_from_memory(struct merge_options *o)
 {
 	struct tree *result = NULL;
 
-	if (unmerged_cache()) {
+	if (unmerged_index(&the_index)) {
 		int i;
 		fprintf(stderr, "BUG: There are unmerged index entries:\n");
 		for (i = 0; i < the_index.cache_nr; i++) {
@@ -1942,7 +1942,7 @@ int merge_trees(struct merge_options *o,
 		return -1;
 	}
 
-	if (unmerged_cache()) {
+	if (unmerged_index(&the_index)) {
 		struct string_list *entries, *re_head, *re_merge;
 		int i;
 		string_list_clear(&o->current_file_set, 1);
@@ -2058,7 +2058,7 @@ int merge_recursive(struct merge_options *o,
 		 * overwritten it: the committed "conflicts" were
 		 * already resolved.
 		 */
-		discard_cache();
+		discard_index(&the_index);
 		saved_b1 = o->branch1;
 		saved_b2 = o->branch2;
 		o->branch1 = "Temporary merge branch 1";
@@ -2074,7 +2074,7 @@ int merge_recursive(struct merge_options *o,
 			return err(o, _("merge returned no commit"));
 	}
 
-	discard_cache();
+	discard_index(&the_index);
 	if (!o->call_depth)
 		read_index(&the_index);
 
diff --git a/merge.c b/merge.c
index 06509a6df2..e1f93e9714 100644
--- a/merge.c
+++ b/merge.c
@@ -36,7 +36,7 @@ int try_merge_command(const char *strategy, size_t xopts_nr,
 	ret = run_command_v_opt(args.argv, RUN_GIT_CMD);
 	argv_array_clear(&args);
 
-	discard_cache();
+	discard_index(&the_index);
 	if (read_index(&the_index) < 0)
 		die(_("failed to read the cache"));
 	resolve_undo_clear_index(&the_index);
diff --git a/sequencer.c b/sequencer.c
index f20e05fe60..274eda243a 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -958,7 +958,7 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,
 		if (index_differs_from(unborn ? EMPTY_TREE_SHA1_HEX : "HEAD", 0, 0))
 			return error_dirty_index(opts);
 	}
-	discard_cache();
+	discard_index(&the_index);
 
 	if (!commit->parents)
 		parent = NULL;
@@ -1845,7 +1845,7 @@ static int do_exec(const char *command_line)
 	status = run_command_v_opt(child_argv, RUN_USING_SHELL);
 
 	/* force re-reading of the cache */
-	if (discard_cache() < 0 || read_index(&the_index) < 0)
+	if (discard_index(&the_index) < 0 || read_index(&the_index) < 0)
 		return error(_("could not read index"));
 
 	dirty = require_clean_work_tree("rebase", NULL, 1, 1);
diff --git a/t/helper/test-lazy-init-name-hash.c b/t/helper/test-lazy-init-name-hash.c
index bd747dcbcd..5512c97647 100644
--- a/t/helper/test-lazy-init-name-hash.c
+++ b/t/helper/test-lazy-init-name-hash.c
@@ -52,7 +52,7 @@ static void dump_run(void)
 		ce = hashmap_iter_next(&iter_cache);
 	}
 
-	discard_cache();
+	discard_index(&the_index);
 }
 
 /*
@@ -92,7 +92,7 @@ static uint64_t time_runs(int try_threaded)
 				   the_index.cache_nr);
 		fflush(stdout);
 
-		discard_cache();
+		discard_index(&the_index);
 	}
 
 	avg = sum / count;
@@ -118,7 +118,7 @@ static void analyze_run(void)
 
 	read_index(&the_index);
 	cache_nr_limit = the_index.cache_nr;
-	discard_cache();
+	discard_index(&the_index);
 
 	nr = analyze;
 	while (1) {
@@ -138,7 +138,7 @@ static void analyze_run(void)
 			t2s = getnanotime();
 			sum_single += (t2s - t1s);
 			the_index.cache_nr = cache_nr_limit;
-			discard_cache();
+			discard_index(&the_index);
 
 			read_index(&the_index);
 			the_index.cache_nr = nr; /* cheap truncate of index */
@@ -147,7 +147,7 @@ static void analyze_run(void)
 			t2m = getnanotime();
 			sum_multi += (t2m - t1m);
 			the_index.cache_nr = cache_nr_limit;
-			discard_cache();
+			discard_index(&the_index);
 
 			if (!nr_threads_used)
 				printf("    [size %8d] [single %f]   non-threaded code path used\n",
diff --git a/t/helper/test-read-cache.c b/t/helper/test-read-cache.c
index b4aa339ddb..084778c52f 100644
--- a/t/helper/test-read-cache.c
+++ b/t/helper/test-read-cache.c
@@ -8,7 +8,7 @@ int cmd_main(int argc, const char **argv)
 	setup_git_directory();
 	for (i = 0; i < cnt; i++) {
 		read_index(&the_index);
-		discard_cache();
+		discard_index(&the_index);
 	}
 	return 0;
 }
diff --git a/wt-status.c b/wt-status.c
index ff0e70a25a..d17d4cb6ca 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -2247,7 +2247,7 @@ int has_uncommitted_changes(int ignore_submodules)
 	struct rev_info rev_info;
 	int result;
 
-	if (is_cache_unborn())
+	if (is_index_unborn(&the_index))
 		return 0;
 
 	init_revisions(&rev_info, NULL);
-- 
2.13.0.rc1.39.ga6db8bfa24


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 14/24] cache.h: drop cache_name_pos
  2017-05-02 22:22 [PATCH 00/24] Retire NO_THE_INDEX_COMPATIBILITY_MACROS Stefan Beller
                   ` (12 preceding siblings ...)
  2017-05-02 22:23 ` [PATCH 13/24] cache.h: drop is_cache_unborn(), discard_cache(), unmerged_cache() Stefan Beller
@ 2017-05-02 22:23 ` Stefan Beller
  2017-05-02 22:23 ` [PATCH 15/24] cache.h: drop add_cache_entry Stefan Beller
                   ` (9 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: Stefan Beller @ 2017-05-02 22:23 UTC (permalink / raw)
  To: gitster, git; +Cc: git, Stefan Beller

coccinelle patch:
@@ expression name, namelen; @@
-cache_name_pos(name, namelen)
+index_name_pos(&the_index, name, namelen)

Additionally manual editing:
 * drop the define from cache.h.

Signed-off-by: Stefan Beller <sbeller@google.com>
---
 apply.c                  |  9 +++++----
 builtin/blame.c          |  4 ++--
 builtin/checkout-index.c |  2 +-
 builtin/checkout.c       |  2 +-
 builtin/ls-files.c       |  7 ++++---
 builtin/merge-index.c    |  2 +-
 builtin/mv.c             |  8 ++++----
 builtin/rm.c             |  4 ++--
 builtin/update-index.c   | 10 +++++-----
 cache.h                  |  1 -
 diff.c                   |  2 +-
 dir.c                    |  8 ++++----
 merge-recursive.c        |  4 ++--
 pathspec.c               |  2 +-
 rerere.c                 |  2 +-
 sha1_name.c              |  6 +++---
 submodule.c              |  2 +-
 wt-status.c              |  4 ++--
 18 files changed, 40 insertions(+), 39 deletions(-)

diff --git a/apply.c b/apply.c
index eb8eaeabec..bb1cd77c66 100644
--- a/apply.c
+++ b/apply.c
@@ -3496,7 +3496,7 @@ static int load_current(struct apply_state *state,
 	if (!patch->is_new)
 		die("BUG: patch to %s is not a creation", patch->old_name);
 
-	pos = cache_name_pos(name, strlen(name));
+	pos = index_name_pos(&the_index, name, strlen(name));
 	if (pos < 0)
 		return error(_("%s: does not exist in index"), name);
 	ce = the_index.cache[pos];
@@ -3665,7 +3665,8 @@ static int check_preimage(struct apply_state *state,
 	}
 
 	if (state->check_index && !previous) {
-		int pos = cache_name_pos(old_name, strlen(old_name));
+		int pos = index_name_pos(&the_index, old_name,
+					 strlen(old_name));
 		if (pos < 0) {
 			if (patch->is_new < 0)
 				goto is_new;
@@ -3721,7 +3722,7 @@ static int check_to_create(struct apply_state *state,
 	struct stat nst;
 
 	if (state->check_index &&
-	    cache_name_pos(new_name, strlen(new_name)) >= 0 &&
+	    index_name_pos(&the_index, new_name, strlen(new_name)) >= 0 &&
 	    !ok_if_exists)
 		return EXISTS_IN_INDEX;
 	if (state->cached)
@@ -3998,7 +3999,7 @@ static int get_current_oid(struct apply_state *state, const char *path,
 
 	if (read_apply_cache(state) < 0)
 		return -1;
-	pos = cache_name_pos(path, strlen(path));
+	pos = index_name_pos(&the_index, path, strlen(path));
 	if (pos < 0)
 		return -1;
 	oidcpy(oid, &the_index.cache[pos]->oid);
diff --git a/builtin/blame.c b/builtin/blame.c
index b47aae25d4..c71d9a3340 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -2239,7 +2239,7 @@ static void verify_working_tree_path(struct commit *work_tree, const char *path)
 			return;
 	}
 
-	pos = cache_name_pos(path, strlen(path));
+	pos = index_name_pos(&the_index, path, strlen(path));
 	if (pos >= 0)
 		; /* path is in the index */
 	else if (-1 - pos < the_index.cache_nr &&
@@ -2399,7 +2399,7 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,
 
 	len = strlen(path);
 	if (!mode) {
-		int pos = cache_name_pos(path, len);
+		int pos = index_name_pos(&the_index, path, len);
 		if (0 <= pos)
 			mode = the_index.cache[pos]->ce_mode;
 		else
diff --git a/builtin/checkout-index.c b/builtin/checkout-index.c
index 1c3dcc1a8b..e8fc24b2ce 100644
--- a/builtin/checkout-index.c
+++ b/builtin/checkout-index.c
@@ -46,7 +46,7 @@ static void write_tempfile_record(const char *name, const char *prefix)
 static int checkout_file(const char *name, const char *prefix)
 {
 	int namelen = strlen(name);
-	int pos = cache_name_pos(name, namelen);
+	int pos = index_name_pos(&the_index, name, namelen);
 	int has_same_name = 0;
 	int did_checkout = 0;
 	int errs = 0;
diff --git a/builtin/checkout.c b/builtin/checkout.c
index a6cd8c0f37..039d3d296b 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -107,7 +107,7 @@ static int update_some(const unsigned char *sha1, struct strbuf *base,
 	 * entry in place. Whether it is UPTODATE or not, checkout_entry will
 	 * do the right thing.
 	 */
-	pos = cache_name_pos(ce->name, ce->ce_namelen);
+	pos = index_name_pos(&the_index, ce->name, ce->ce_namelen);
 	if (pos >= 0) {
 		struct cache_entry *old = the_index.cache[pos];
 		if (ce->ce_mode == old->ce_mode &&
diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index 6f7ecec1b0..3507490d3e 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -134,7 +134,8 @@ static void show_killed_files(struct dir_struct *dir)
 				/* If ent->name is prefix of an entry in the
 				 * cache, it will be killed.
 				 */
-				pos = cache_name_pos(ent->name, ent->len);
+				pos = index_name_pos(&the_index, ent->name,
+						     ent->len);
 				if (0 <= pos)
 					die("BUG: killed-file %.*s not found",
 						ent->len, ent->name);
@@ -156,7 +157,7 @@ static void show_killed_files(struct dir_struct *dir)
 					killed = 1;
 				break;
 			}
-			if (0 <= cache_name_pos(ent->name, sp - ent->name)) {
+			if (0 <= index_name_pos(&the_index, ent->name, sp - ent->name)) {
 				/* If any of the leading directories in
 				 * ent->name is registered in the cache,
 				 * ent->name will be killed.
@@ -384,7 +385,7 @@ static void prune_cache(const char *prefix, size_t prefixlen)
 
 	if (!prefix)
 		return;
-	pos = cache_name_pos(prefix, prefixlen);
+	pos = index_name_pos(&the_index, prefix, prefixlen);
 	if (pos < 0)
 		pos = -pos-1;
 	first = pos;
diff --git a/builtin/merge-index.c b/builtin/merge-index.c
index d867ee73f0..ec7104614c 100644
--- a/builtin/merge-index.c
+++ b/builtin/merge-index.c
@@ -44,7 +44,7 @@ static int merge_entry(int pos, const char *path)
 
 static void merge_one_path(const char *path)
 {
-	int pos = cache_name_pos(path, strlen(path));
+	int pos = index_name_pos(&the_index, path, strlen(path));
 
 	/*
 	 * If it already exists in the cache as stage0, it's
diff --git a/builtin/mv.c b/builtin/mv.c
index 3b887a9490..40e40bb098 100644
--- a/builtin/mv.c
+++ b/builtin/mv.c
@@ -97,7 +97,7 @@ static int index_range_of_same_dir(const char *src, int length,
 	const char *src_w_slash = add_slash(src);
 	int first, last, len_w_slash = length + 1;
 
-	first = cache_name_pos(src_w_slash, len_w_slash);
+	first = index_name_pos(&the_index, src_w_slash, len_w_slash);
 	if (first >= 0)
 		die(_("%.*s is in index"), len_w_slash, src_w_slash);
 
@@ -187,7 +187,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
 				&& lstat(dst, &st) == 0)
 			bad = _("cannot move directory over file");
 		else if (src_is_dir) {
-			int first = cache_name_pos(src, length), last;
+			int first = index_name_pos(&the_index, src, length), last;
 
 			if (first >= 0)
 				prepare_move_submodule(src, first,
@@ -218,7 +218,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
 				}
 				argc += last - first;
 			}
-		} else if (cache_name_pos(src, length) < 0)
+		} else if (index_name_pos(&the_index, src, length) < 0)
 			bad = _("not under version control");
 		else if (lstat(dst, &st) == 0 &&
 			 (!ignore_case || strcasecmp(src, dst))) {
@@ -284,7 +284,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
 		if (mode == WORKING_DIRECTORY)
 			continue;
 
-		pos = cache_name_pos(src, strlen(src));
+		pos = index_name_pos(&the_index, src, strlen(src));
 		assert(pos >= 0);
 		if (!show_only)
 			rename_cache_entry_at(pos, dst);
diff --git a/builtin/rm.c b/builtin/rm.c
index 0813d0a853..c77c941ef0 100644
--- a/builtin/rm.c
+++ b/builtin/rm.c
@@ -67,7 +67,7 @@ static void submodules_absorb_gitdir_if_needed(const char *prefix)
 		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)
@@ -112,7 +112,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
diff --git a/builtin/update-index.c b/builtin/update-index.c
index c9f06169c0..d7a117c674 100644
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
@@ -225,7 +225,7 @@ static int test_if_untracked_cache_is_supported(void)
 static int mark_ce_flags(const char *path, int flag, int mark)
 {
 	int namelen = strlen(path);
-	int pos = cache_name_pos(path, namelen);
+	int pos = index_name_pos(&the_index, path, namelen);
 	if (0 <= pos) {
 		if (mark)
 			the_index.cache[pos]->ce_flags |= flag;
@@ -317,7 +317,7 @@ static int add_one_path(const struct cache_entry *old, const char *path, int len
 static int process_directory(const char *path, int len, struct stat *st)
 {
 	struct object_id oid;
-	int pos = cache_name_pos(path, len);
+	int pos = index_name_pos(&the_index, path, len);
 
 	/* Exact match: file or existing gitlink */
 	if (pos >= 0) {
@@ -368,7 +368,7 @@ static int process_path(const char *path)
 	if (has_symlink_leading_path(path, len))
 		return error("'%s' is beyond a symbolic link", path);
 
-	pos = cache_name_pos(path, len);
+	pos = index_name_pos(&the_index, path, len);
 	ce = pos < 0 ? NULL : the_index.cache[pos];
 	if (ce && ce_skip_worktree(ce)) {
 		/*
@@ -428,7 +428,7 @@ static void chmod_path(char flip, const char *path)
 	int pos;
 	struct cache_entry *ce;
 
-	pos = cache_name_pos(path, strlen(path));
+	pos = index_name_pos(&the_index, path, strlen(path));
 	if (pos < 0)
 		goto fail;
 	ce = the_index.cache[pos];
@@ -610,7 +610,7 @@ static int unresolve_one(const char *path)
 	struct cache_entry *ce_2 = NULL, *ce_3 = NULL;
 
 	/* See if there is such entry in the index. */
-	pos = cache_name_pos(path, namelen);
+	pos = index_name_pos(&the_index, path, namelen);
 	if (0 <= pos) {
 		/* already merged */
 		pos = unmerge_index_entry_at(&the_index, pos);
diff --git a/cache.h b/cache.h
index a021d6e988..a18ebf263a 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 cache_name_pos(name, namelen) index_name_pos(&the_index,(name),(namelen))
 #define add_cache_entry(ce, option) add_index_entry(&the_index, (ce), (option))
 #define rename_cache_entry_at(pos, new_name) rename_index_entry_at(&the_index, (pos), (new_name))
 #define remove_cache_entry_at(pos) remove_index_entry_at(&the_index, (pos))
diff --git a/diff.c b/diff.c
index 37083914c5..f2ee40fe21 100644
--- a/diff.c
+++ b/diff.c
@@ -2759,7 +2759,7 @@ static int reuse_worktree_file(const char *name, const unsigned char *sha1, int
 		return 0;
 
 	len = strlen(name);
-	pos = cache_name_pos(name, len);
+	pos = index_name_pos(&the_index, name, len);
 	if (pos < 0)
 		return 0;
 	ce = the_index.cache[pos];
diff --git a/dir.c b/dir.c
index 63edaec2ef..47890b3d3b 100644
--- a/dir.c
+++ b/dir.c
@@ -596,7 +596,7 @@ static void *read_skip_worktree_file_from_index(const char *path, size_t *size,
 	void *data;
 
 	len = strlen(path);
-	pos = cache_name_pos(path, len);
+	pos = index_name_pos(&the_index, path, len);
 	if (pos < 0)
 		return NULL;
 	if (!ce_skip_worktree(the_index.cache[pos]))
@@ -785,7 +785,7 @@ static int add_excludes(const char *fname, const char *base, int baselen,
 			    !match_stat_data_racy(&the_index, &sha1_stat->stat, &st))
 				; /* no content change, ss->sha1 still good */
 			else if (check_index &&
-				 (pos = cache_name_pos(fname, strlen(fname))) >= 0 &&
+				 (pos = index_name_pos(&the_index, fname, strlen(fname))) >= 0 &&
 				 !ce_stage(the_index.cache[pos]) &&
 				 ce_uptodate(the_index.cache[pos]) &&
 				 !would_convert_to_git(fname))
@@ -1290,7 +1290,7 @@ static enum exist_status directory_exists_in_index(const char *dirname, int len)
 	if (ignore_case)
 		return directory_exists_in_index_icase(dirname, len);
 
-	pos = cache_name_pos(dirname, len);
+	pos = index_name_pos(&the_index, dirname, len);
 	if (pos < 0)
 		pos = -pos-1;
 	while (pos < the_index.cache_nr) {
@@ -1474,7 +1474,7 @@ static int get_index_dtype(const char *path, int len)
 	}
 
 	/* Try to look it up as a directory */
-	pos = cache_name_pos(path, len);
+	pos = index_name_pos(&the_index, path, len);
 	if (pos >= 0)
 		return DT_UNKNOWN;
 	pos = -pos-1;
diff --git a/merge-recursive.c b/merge-recursive.c
index eb0f0c6960..163d37866e 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -680,7 +680,7 @@ static int dir_in_way(const char *path, int check_working_copy, int empty_ok)
 	strbuf_addstr(&dirpath, path);
 	strbuf_addch(&dirpath, '/');
 
-	pos = cache_name_pos(dirpath.buf, dirpath.len);
+	pos = index_name_pos(&the_index, dirpath.buf, dirpath.len);
 
 	if (pos < 0)
 		pos = -1 - pos;
@@ -697,7 +697,7 @@ static int dir_in_way(const char *path, int check_working_copy, int empty_ok)
 
 static int was_tracked(const char *path)
 {
-	int pos = cache_name_pos(path, strlen(path));
+	int pos = index_name_pos(&the_index, path, strlen(path));
 
 	if (0 <= pos)
 		/* we have been tracking this path */
diff --git a/pathspec.c b/pathspec.c
index 25c2afef30..28b5f8b606 100644
--- a/pathspec.c
+++ b/pathspec.c
@@ -389,7 +389,7 @@ static const char *parse_element_magic(unsigned *magic, int *prefix_len,
 static void strip_submodule_slash_cheap(struct pathspec_item *item)
 {
 	if (item->len >= 1 && item->match[item->len - 1] == '/') {
-		int i = cache_name_pos(item->match, item->len - 1);
+		int i = index_name_pos(&the_index, item->match, item->len - 1);
 
 		if (i >= 0 && S_ISGITLINK(the_index.cache[i]->ce_mode)) {
 			item->len--;
diff --git a/rerere.c b/rerere.c
index 03218166ab..b6d84b8461 100644
--- a/rerere.c
+++ b/rerere.c
@@ -966,7 +966,7 @@ static int handle_cache(const char *path, unsigned char *sha1, const char *outpu
 	 * Reproduce the conflicted merge in-core
 	 */
 	len = strlen(path);
-	pos = cache_name_pos(path, len);
+	pos = index_name_pos(&the_index, path, len);
 	if (0 <= pos)
 		return -1;
 	pos = -pos - 1;
diff --git a/sha1_name.c b/sha1_name.c
index b73e261498..41ab9d9f1a 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -1441,7 +1441,7 @@ static void diagnose_invalid_index_path(int stage,
 		prefix = "";
 
 	/* Wrong stage number? */
-	pos = cache_name_pos(filename, namelen);
+	pos = index_name_pos(&the_index, filename, namelen);
 	if (pos < 0)
 		pos = -pos - 1;
 	if (pos < the_index.cache_nr) {
@@ -1457,7 +1457,7 @@ static void diagnose_invalid_index_path(int stage,
 	/* Confusion between relative and absolute filenames? */
 	strbuf_addstr(&fullname, prefix);
 	strbuf_addstr(&fullname, filename);
-	pos = cache_name_pos(fullname.buf, fullname.len);
+	pos = index_name_pos(&the_index, fullname.buf, fullname.len);
 	if (pos < 0)
 		pos = -pos - 1;
 	if (pos < the_index.cache_nr) {
@@ -1553,7 +1553,7 @@ static int get_sha1_with_context_1(const char *name,
 
 		if (!the_index.cache)
 			read_index(&the_index);
-		pos = cache_name_pos(cp, namelen);
+		pos = index_name_pos(&the_index, cp, namelen);
 		if (pos < 0)
 			pos = -pos - 1;
 		while (pos < the_index.cache_nr) {
diff --git a/submodule.c b/submodule.c
index b225ff6d1f..148194831d 100644
--- a/submodule.c
+++ b/submodule.c
@@ -179,7 +179,7 @@ void gitmodules_config(void)
 		strbuf_addstr(&gitmodules_path, "/.gitmodules");
 		if (read_index(&the_index) < 0)
 			die("index file corrupt");
-		pos = cache_name_pos(".gitmodules", 11);
+		pos = index_name_pos(&the_index, ".gitmodules", 11);
 		if (pos < 0) { /* .gitmodules not found or isn't merged */
 			pos = -1 - pos;
 			if (the_index.cache_nr > pos) {  /* there is a .gitmodules */
diff --git a/wt-status.c b/wt-status.c
index d17d4cb6ca..59cdf09a07 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -481,7 +481,7 @@ static int unmerged_mask(const char *path)
 	int pos, mask;
 	const struct cache_entry *ce;
 
-	pos = cache_name_pos(path, strlen(path));
+	pos = index_name_pos(&the_index, path, strlen(path));
 	if (0 <= pos)
 		return 0;
 
@@ -2096,7 +2096,7 @@ static void wt_porcelain_v2_print_unmerged_entry(
 	 */
 	memset(stages, 0, sizeof(stages));
 	sum = 0;
-	pos = cache_name_pos(it->string, strlen(it->string));
+	pos = index_name_pos(&the_index, it->string, strlen(it->string));
 	assert(pos < 0);
 	pos = -pos-1;
 	while (pos < the_index.cache_nr) {
-- 
2.13.0.rc1.39.ga6db8bfa24


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 15/24] cache.h: drop add_cache_entry
  2017-05-02 22:22 [PATCH 00/24] Retire NO_THE_INDEX_COMPATIBILITY_MACROS Stefan Beller
                   ` (13 preceding siblings ...)
  2017-05-02 22:23 ` [PATCH 14/24] cache.h: drop cache_name_pos Stefan Beller
@ 2017-05-02 22:23 ` Stefan Beller
  2017-05-02 22:23 ` [PATCH 16/24] cache.h: drop rename_cache_entry_at Stefan Beller
                   ` (8 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: Stefan Beller @ 2017-05-02 22:23 UTC (permalink / raw)
  To: gitster, git; +Cc: git, Stefan Beller

coccinelle patch
-add_cache_entry(ce, option)
+add_index_entry(&the_index, ce, option)

Additionally drop the define from cache.h manually.

Signed-off-by: Stefan Beller <sbeller@google.com>
---
 apply.c                | 4 ++--
 builtin/blame.c        | 3 ++-
 builtin/checkout.c     | 3 ++-
 builtin/reset.c        | 3 ++-
 builtin/update-index.c | 8 ++++----
 cache.h                | 1 -
 merge-recursive.c      | 4 ++--
 tree.c                 | 2 +-
 8 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/apply.c b/apply.c
index bb1cd77c66..66d4969e72 100644
--- a/apply.c
+++ b/apply.c
@@ -4284,7 +4284,7 @@ static int build_fake_ancestor(struct apply_state *state, struct patch *list)
 				       "for newly created file %s"), path);
 		}
 	}
-	if (add_cache_entry(ce, ADD_CACHE_OK_TO_ADD) < 0) {
+	if (add_index_entry(&the_index, ce, ADD_CACHE_OK_TO_ADD) < 0) {
 		free(ce);
 		return error(_("unable to add cache entry for %s"), path);
 	}
@@ -4428,7 +4428,7 @@ static int add_conflicted_stages_file(struct apply_state *state,
 		ce->ce_flags = create_ce_flags(stage);
 		ce->ce_namelen = namelen;
 		oidcpy(&ce->oid, &patch->threeway_stage[stage - 1]);
-		if (add_cache_entry(ce, ADD_CACHE_OK_TO_ADD) < 0) {
+		if (add_index_entry(&the_index, ce, ADD_CACHE_OK_TO_ADD) < 0) {
 			free(ce);
 			return error(_("unable to add cache entry for %s"),
 				     patch->new_name);
diff --git a/builtin/blame.c b/builtin/blame.c
index c71d9a3340..5140015cc0 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -2413,7 +2413,8 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,
 	ce->ce_flags = create_ce_flags(0);
 	ce->ce_namelen = len;
 	ce->ce_mode = create_ce_mode(mode);
-	add_cache_entry(ce, ADD_CACHE_OK_TO_ADD|ADD_CACHE_OK_TO_REPLACE);
+	add_index_entry(&the_index, ce,
+			ADD_CACHE_OK_TO_ADD | ADD_CACHE_OK_TO_REPLACE);
 
 	cache_tree_invalidate_path(&the_index, path);
 
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 039d3d296b..34ec9f7e32 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -118,7 +118,8 @@ static int update_some(const unsigned char *sha1, struct strbuf *base,
 		}
 	}
 
-	add_cache_entry(ce, ADD_CACHE_OK_TO_ADD | ADD_CACHE_OK_TO_REPLACE);
+	add_index_entry(&the_index, ce,
+			ADD_CACHE_OK_TO_ADD | ADD_CACHE_OK_TO_REPLACE);
 	return 0;
 }
 
diff --git a/builtin/reset.c b/builtin/reset.c
index f8073b1caa..0e19d6e8d5 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -138,7 +138,8 @@ static void update_index_from_diff(struct diff_queue_struct *q,
 			ce->ce_flags |= CE_INTENT_TO_ADD;
 			set_object_name_for_intent_to_add_entry(ce);
 		}
-		add_cache_entry(ce, ADD_CACHE_OK_TO_ADD | ADD_CACHE_OK_TO_REPLACE);
+		add_index_entry(&the_index, ce,
+				ADD_CACHE_OK_TO_ADD | ADD_CACHE_OK_TO_REPLACE);
 	}
 }
 
diff --git a/builtin/update-index.c b/builtin/update-index.c
index d7a117c674..e0738f74bf 100644
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
@@ -286,7 +286,7 @@ static int add_one_path(const struct cache_entry *old, const char *path, int len
 	}
 	option = allow_add ? ADD_CACHE_OK_TO_ADD : 0;
 	option |= allow_replace ? ADD_CACHE_OK_TO_REPLACE : 0;
-	if (add_cache_entry(ce, option))
+	if (add_index_entry(&the_index, ce, option))
 		return error("%s: cannot add to the index - missing --add option?", path);
 	return 0;
 }
@@ -416,7 +416,7 @@ static int add_cacheinfo(unsigned int mode, const struct object_id *oid,
 		ce->ce_flags |= CE_VALID;
 	option = allow_add ? ADD_CACHE_OK_TO_ADD : 0;
 	option |= allow_replace ? ADD_CACHE_OK_TO_REPLACE : 0;
-	if (add_cache_entry(ce, option))
+	if (add_index_entry(&the_index, ce, option))
 		return error("%s: cannot add to the index - missing --add option?",
 			     path);
 	report("add '%s'", path);
@@ -659,12 +659,12 @@ static int unresolve_one(const char *path)
 	}
 
 	remove_file_from_cache(path);
-	if (add_cache_entry(ce_2, ADD_CACHE_OK_TO_ADD)) {
+	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;
 		goto free_return;
 	}
-	if (!add_cache_entry(ce_3, ADD_CACHE_OK_TO_ADD))
+	if (!add_index_entry(&the_index, ce_3, ADD_CACHE_OK_TO_ADD))
 		return 0;
 	error("%s: cannot add their version to the index.", path);
 	ret = -1;
diff --git a/cache.h b/cache.h
index a18ebf263a..54c1bbf0d1 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 add_cache_entry(ce, option) add_index_entry(&the_index, (ce), (option))
 #define rename_cache_entry_at(pos, new_name) rename_index_entry_at(&the_index, (pos), (new_name))
 #define remove_cache_entry_at(pos) remove_index_entry_at(&the_index, (pos))
 #define remove_file_from_cache(path) remove_file_from_index(&the_index, (path))
diff --git a/merge-recursive.c b/merge-recursive.c
index 163d37866e..6420dc1951 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -230,7 +230,7 @@ static int add_cacheinfo(struct merge_options *o,
 	if (!ce)
 		return err(o, _("addinfo_cache failed for path '%s'"), path);
 
-	ret = add_cache_entry(ce, options);
+	ret = add_index_entry(&the_index, ce, options);
 	if (refresh) {
 		struct cache_entry *nce;
 
@@ -238,7 +238,7 @@ static int add_cacheinfo(struct merge_options *o,
 		if (!nce)
 			return err(o, _("addinfo_cache failed for path '%s'"), path);
 		if (nce != ce)
-			ret = add_cache_entry(nce, options);
+			ret = add_index_entry(&the_index, nce, options);
 	}
 	return ret;
 }
diff --git a/tree.c b/tree.c
index 82a6ae2a19..5f9a322ddd 100644
--- a/tree.c
+++ b/tree.c
@@ -27,7 +27,7 @@ static int read_one_entry_opt(const unsigned char *sha1, const char *base, int b
 	memcpy(ce->name, base, baselen);
 	memcpy(ce->name + baselen, pathname, len+1);
 	hashcpy(ce->oid.hash, sha1);
-	return add_cache_entry(ce, opt);
+	return add_index_entry(&the_index, ce, opt);
 }
 
 static int read_one_entry(const unsigned char *sha1, struct strbuf *base,
-- 
2.13.0.rc1.39.ga6db8bfa24


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 16/24] cache.h: drop rename_cache_entry_at
  2017-05-02 22:22 [PATCH 00/24] Retire NO_THE_INDEX_COMPATIBILITY_MACROS Stefan Beller
                   ` (14 preceding siblings ...)
  2017-05-02 22:23 ` [PATCH 15/24] cache.h: drop add_cache_entry Stefan Beller
@ 2017-05-02 22:23 ` Stefan Beller
  2017-05-02 22:23 ` [PATCH 17/24] cache.h: drop remove_file_from_cache Stefan Beller
                   ` (7 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: Stefan Beller @ 2017-05-02 22:23 UTC (permalink / raw)
  To: gitster, git; +Cc: git, Stefan Beller

One define was unused, the other occurs just once. Easy patch.

Signed-off-by: Stefan Beller <sbeller@google.com>
---
 builtin/mv.c | 2 +-
 cache.h      | 2 --
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/builtin/mv.c b/builtin/mv.c
index 40e40bb098..1a3c61994c 100644
--- a/builtin/mv.c
+++ b/builtin/mv.c
@@ -287,7 +287,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
 		pos = index_name_pos(&the_index, src, strlen(src));
 		assert(pos >= 0);
 		if (!show_only)
-			rename_cache_entry_at(pos, dst);
+			rename_index_entry_at(&the_index, pos, dst);
 	}
 
 	if (gitmodules_modified)
diff --git a/cache.h b/cache.h
index 54c1bbf0d1..4c12ff265e 100644
--- a/cache.h
+++ b/cache.h
@@ -354,8 +354,6 @@ extern void free_name_hash(struct index_state *istate);
 
 
 #ifndef NO_THE_INDEX_COMPATIBILITY_MACROS
-#define rename_cache_entry_at(pos, new_name) rename_index_entry_at(&the_index, (pos), (new_name))
-#define remove_cache_entry_at(pos) remove_index_entry_at(&the_index, (pos))
 #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))
-- 
2.13.0.rc1.39.ga6db8bfa24


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 17/24] cache.h: drop remove_file_from_cache
  2017-05-02 22:22 [PATCH 00/24] Retire NO_THE_INDEX_COMPATIBILITY_MACROS Stefan Beller
                   ` (15 preceding siblings ...)
  2017-05-02 22:23 ` [PATCH 16/24] cache.h: drop rename_cache_entry_at Stefan Beller
@ 2017-05-02 22:23 ` Stefan Beller
  2017-05-02 22:23 ` [PATCH 18/24] cache.h: drop add_to_cache Stefan Beller
                   ` (6 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: Stefan Beller @ 2017-05-02 22:23 UTC (permalink / raw)
  To: gitster, git; +Cc: git, Stefan Beller

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@google.com>
---
 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


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 18/24] cache.h: drop add_to_cache
  2017-05-02 22:22 [PATCH 00/24] Retire NO_THE_INDEX_COMPATIBILITY_MACROS Stefan Beller
                   ` (16 preceding siblings ...)
  2017-05-02 22:23 ` [PATCH 17/24] cache.h: drop remove_file_from_cache Stefan Beller
@ 2017-05-02 22:23 ` Stefan Beller
  2017-05-02 22:23 ` [PATCH 19/24] cache.h: drop add_file_to_cache Stefan Beller
                   ` (5 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: Stefan Beller @ 2017-05-02 22:23 UTC (permalink / raw)
  To: gitster, git; +Cc: git, Stefan Beller

Signed-off-by: Stefan Beller <sbeller@google.com>
---
 builtin/commit.c | 2 +-
 cache.h          | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/builtin/commit.c b/builtin/commit.c
index fa962c4f86..ac4fe97d36 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -287,7 +287,7 @@ static void add_remove_files(struct string_list *list)
 			continue;
 
 		if (!lstat(p->string, &st)) {
-			if (add_to_cache(p->string, &st, 0))
+			if (add_to_index(&the_index, p->string, &st, 0))
 				die(_("updating files failed"));
 		} else
 			remove_file_from_index(&the_index, p->string);
diff --git a/cache.h b/cache.h
index 88c6f8a7df..bc49defc27 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 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))
 #define refresh_cache(flags) refresh_index(&the_index, (flags), NULL, NULL, NULL)
-- 
2.13.0.rc1.39.ga6db8bfa24


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 19/24] cache.h: drop add_file_to_cache
  2017-05-02 22:22 [PATCH 00/24] Retire NO_THE_INDEX_COMPATIBILITY_MACROS Stefan Beller
                   ` (17 preceding siblings ...)
  2017-05-02 22:23 ` [PATCH 18/24] cache.h: drop add_to_cache Stefan Beller
@ 2017-05-02 22:23 ` Stefan Beller
  2017-05-02 22:23 ` [PATCH 20/24] cache.h: drop chmod_cache_entry Stefan Beller
                   ` (4 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: Stefan Beller @ 2017-05-02 22:23 UTC (permalink / raw)
  To: gitster, git; +Cc: git, Stefan Beller

Signed-off-by: Stefan Beller <sbeller@google.com>
---
 cache.h     | 1 -
 rerere.c    | 2 +-
 submodule.c | 2 +-
 3 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/cache.h b/cache.h
index bc49defc27..a9b059913e 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 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))
 #define refresh_cache(flags) refresh_index(&the_index, (flags), NULL, NULL, NULL)
 #define ce_match_stat(ce, st, options) ie_match_stat(&the_index, (ce), (st), (options))
diff --git a/rerere.c b/rerere.c
index b6d84b8461..0ada0ef247 100644
--- a/rerere.c
+++ b/rerere.c
@@ -712,7 +712,7 @@ static void update_paths(struct string_list *update)
 
 	for (i = 0; i < update->nr; i++) {
 		struct string_list_item *item = &update->items[i];
-		if (add_file_to_cache(item->string, 0))
+		if (add_file_to_index(&the_index, item->string, 0))
 			exit(128);
 		fprintf(stderr, "Staged '%s' using previous resolution.\n",
 			item->string);
diff --git a/submodule.c b/submodule.c
index 148194831d..6587bc0d84 100644
--- a/submodule.c
+++ b/submodule.c
@@ -119,7 +119,7 @@ int remove_path_from_gitmodules(const char *path)
 
 void stage_updated_gitmodules(void)
 {
-	if (add_file_to_cache(".gitmodules", 0))
+	if (add_file_to_index(&the_index, ".gitmodules", 0))
 		die(_("staging updated .gitmodules failed"));
 }
 
-- 
2.13.0.rc1.39.ga6db8bfa24


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 20/24] cache.h: drop chmod_cache_entry
  2017-05-02 22:22 [PATCH 00/24] Retire NO_THE_INDEX_COMPATIBILITY_MACROS Stefan Beller
                   ` (18 preceding siblings ...)
  2017-05-02 22:23 ` [PATCH 19/24] cache.h: drop add_file_to_cache Stefan Beller
@ 2017-05-02 22:23 ` Stefan Beller
  2017-05-02 22:23 ` [PATCH 21/24] cache.h: drop refresh_cache Stefan Beller
                   ` (3 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: Stefan Beller @ 2017-05-02 22:23 UTC (permalink / raw)
  To: gitster, git; +Cc: git, Stefan Beller

Signed-off-by: Stefan Beller <sbeller@google.com>
---
 builtin/add.c          | 2 +-
 builtin/update-index.c | 2 +-
 cache.h                | 1 -
 3 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/builtin/add.c b/builtin/add.c
index f6d71b10d0..288b1f5bb3 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -40,7 +40,7 @@ static void chmod_pathspec(struct pathspec *pathspec, int force_mode)
 		if (pathspec && !ce_path_match(ce, pathspec, NULL))
 			continue;
 
-		if (chmod_cache_entry(ce, force_mode) < 0)
+		if (chmod_index_entry(&the_index, ce, force_mode) < 0)
 			fprintf(stderr, "cannot chmod '%s'", ce->name);
 	}
 }
diff --git a/builtin/update-index.c b/builtin/update-index.c
index 8c4911e920..f1c52a5531 100644
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
@@ -432,7 +432,7 @@ static void chmod_path(char flip, const char *path)
 	if (pos < 0)
 		goto fail;
 	ce = the_index.cache[pos];
-	if (chmod_cache_entry(ce, flip) < 0)
+	if (chmod_index_entry(&the_index, ce, flip) < 0)
 		goto fail;
 
 	report("chmod %cx '%s'", flip, path);
diff --git a/cache.h b/cache.h
index a9b059913e..07ad23d912 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 chmod_cache_entry(ce, flip) chmod_index_entry(&the_index, (ce), (flip))
 #define refresh_cache(flags) refresh_index(&the_index, (flags), NULL, NULL, NULL)
 #define ce_match_stat(ce, st, options) ie_match_stat(&the_index, (ce), (st), (options))
 #define ce_modified(ce, st, options) ie_modified(&the_index, (ce), (st), (options))
-- 
2.13.0.rc1.39.ga6db8bfa24


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 21/24] cache.h: drop refresh_cache
  2017-05-02 22:22 [PATCH 00/24] Retire NO_THE_INDEX_COMPATIBILITY_MACROS Stefan Beller
                   ` (19 preceding siblings ...)
  2017-05-02 22:23 ` [PATCH 20/24] cache.h: drop chmod_cache_entry Stefan Beller
@ 2017-05-02 22:23 ` Stefan Beller
  2017-05-02 22:23 ` [PATCH 22/24] cache.h: drop ce_modified Stefan Beller
                   ` (2 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: Stefan Beller @ 2017-05-02 22:23 UTC (permalink / raw)
  To: gitster, git; +Cc: git, Stefan Beller

coccinelle patch:
@@ expression flags; @@
-refresh_cache(flags)
+refresh_index(&the_index, flags, NULL, NULL, NULL)

Additionally drop the define from cache.h manually.

This is a commit where I think the macro expansion is maybe silly, but
for reasons outlined in the first patch of the series, we still follow
through.

Signed-off-by: Stefan Beller <sbeller@google.com>
---
 builtin/am.c           | 4 ++--
 builtin/checkout.c     | 2 +-
 builtin/commit.c       | 6 +++---
 builtin/diff.c         | 3 ++-
 builtin/merge.c        | 8 ++++----
 builtin/update-index.c | 3 ++-
 cache.h                | 1 -
 merge.c                | 2 +-
 wt-status.c            | 2 +-
 9 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/builtin/am.c b/builtin/am.c
index 38fc4566f7..a7388ec4e0 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -1122,7 +1122,7 @@ static void refresh_and_write_cache(void)
 	struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));
 
 	hold_locked_index(lock_file, LOCK_DIE_ON_ERROR);
-	refresh_cache(REFRESH_QUIET);
+	refresh_index(&the_index, REFRESH_QUIET, NULL, NULL, NULL);
 	if (write_locked_index(&the_index, lock_file, COMMIT_LOCK))
 		die(_("unable to write index file"));
 }
@@ -1977,7 +1977,7 @@ static int fast_forward_to(struct tree *head, struct tree *remote, int reset)
 	lock_file = xcalloc(1, sizeof(struct lock_file));
 	hold_locked_index(lock_file, LOCK_DIE_ON_ERROR);
 
-	refresh_cache(REFRESH_QUIET);
+	refresh_index(&the_index, REFRESH_QUIET, NULL, NULL, NULL);
 
 	memset(&opts, 0, sizeof(opts));
 	opts.head_idx = 1;
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 34ec9f7e32..49a8b3a7ff 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -509,7 +509,7 @@ static int merge_working_tree(const struct checkout_opts *opts,
 
 		setup_unpack_trees_porcelain(&topts, "checkout");
 
-		refresh_cache(REFRESH_QUIET);
+		refresh_index(&the_index, REFRESH_QUIET, NULL, NULL, NULL);
 
 		if (unmerged_index(&the_index)) {
 			error(_("you need to resolve your current index first"));
diff --git a/builtin/commit.c b/builtin/commit.c
index ac4fe97d36..4b95ff181b 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -328,7 +328,7 @@ static void refresh_cache_or_die(int refresh_flags)
 	 * refresh_flags contains REFRESH_QUIET, so the only errors
 	 * are for unmerged entries.
 	 */
-	if (refresh_cache(refresh_flags | REFRESH_IN_PORCELAIN))
+	if (refresh_index(&the_index, refresh_flags | REFRESH_IN_PORCELAIN, NULL, NULL, NULL))
 		die_resolve_conflict("commit");
 }
 
@@ -470,7 +470,7 @@ static const char *prepare_index(int argc, const char **argv, const char *prefix
 
 	hold_locked_index(&index_lock, LOCK_DIE_ON_ERROR);
 	add_remove_files(&partial);
-	refresh_cache(REFRESH_QUIET);
+	refresh_index(&the_index, REFRESH_QUIET, NULL, NULL, NULL);
 	update_main_cache_tree(WRITE_TREE_SILENT);
 	if (write_locked_index(&the_index, &index_lock, CLOSE_LOCK))
 		die(_("unable to write new_index file"));
@@ -482,7 +482,7 @@ static const char *prepare_index(int argc, const char **argv, const char *prefix
 
 	create_base_index(current_head);
 	add_remove_files(&partial);
-	refresh_cache(REFRESH_QUIET);
+	refresh_index(&the_index, REFRESH_QUIET, NULL, NULL, NULL);
 
 	if (write_locked_index(&the_index, &false_lock, CLOSE_LOCK))
 		die(_("unable to write temporary index file"));
diff --git a/builtin/diff.c b/builtin/diff.c
index 1efd0d6b61..b11b94b214 100644
--- a/builtin/diff.c
+++ b/builtin/diff.c
@@ -211,7 +211,8 @@ static void refresh_index_quietly(void)
 		return;
 	discard_index(&the_index);
 	read_index(&the_index);
-	refresh_cache(REFRESH_QUIET|REFRESH_UNMERGED);
+	refresh_index(&the_index, REFRESH_QUIET | REFRESH_UNMERGED, NULL,
+		      NULL, NULL);
 	update_index_if_able(&the_index, lock_file);
 }
 
diff --git a/builtin/merge.c b/builtin/merge.c
index b023107d26..4e219cb9e8 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -324,7 +324,7 @@ static void restore_state(const struct object_id *head,
 	run_command_v_opt(args, RUN_GIT_CMD);
 
 	strbuf_release(&sb);
-	refresh_cache(REFRESH_QUIET);
+	refresh_index(&the_index, REFRESH_QUIET, NULL, NULL, NULL);
 }
 
 /* This is called when no merge was necessary. */
@@ -639,7 +639,7 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
 	const char *head_arg = "HEAD";
 
 	hold_locked_index(&lock, LOCK_DIE_ON_ERROR);
-	refresh_cache(REFRESH_QUIET);
+	refresh_index(&the_index, REFRESH_QUIET, NULL, NULL, NULL);
 	if (the_index.cache_changed &&
 	    write_locked_index(&the_index, &lock, COMMIT_LOCK))
 		return error(_("Unable to write index."));
@@ -786,7 +786,7 @@ static int merge_trivial(struct commit *head, struct commit_list *remoteheads)
 	static struct lock_file lock;
 
 	hold_locked_index(&lock, LOCK_DIE_ON_ERROR);
-	refresh_cache(REFRESH_QUIET);
+	refresh_index(&the_index, REFRESH_QUIET, NULL, NULL, NULL);
 	if (the_index.cache_changed &&
 	    write_locked_index(&the_index, &lock, COMMIT_LOCK))
 		return error(_("Unable to write index."));
@@ -1393,7 +1393,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 		 * We are not doing octopus, not fast-forward, and have
 		 * only one common.
 		 */
-		refresh_cache(REFRESH_QUIET);
+		refresh_index(&the_index, REFRESH_QUIET, NULL, NULL, NULL);
 		if (allow_trivial && fast_forward != FF_ONLY) {
 			/* See if it is really trivial. */
 			git_committer_info(IDENT_STRICT);
diff --git a/builtin/update-index.c b/builtin/update-index.c
index f1c52a5531..9cbd346f95 100644
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
@@ -767,7 +767,8 @@ static int refresh(struct refresh_params *o, unsigned int flag)
 {
 	setup_work_tree();
 	read_index_preload(&the_index, NULL);
-	*o->has_errors |= refresh_cache(o->flags | flag);
+	*o->has_errors |= refresh_index(&the_index, o->flags | flag, NULL,
+					NULL, NULL);
 	return 0;
 }
 
diff --git a/cache.h b/cache.h
index 07ad23d912..23c9c1697c 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 refresh_cache(flags) refresh_index(&the_index, (flags), NULL, NULL, NULL)
 #define ce_match_stat(ce, st, options) ie_match_stat(&the_index, (ce), (st), (options))
 #define ce_modified(ce, st, options) ie_modified(&the_index, (ce), (st), (options))
 #endif
diff --git a/merge.c b/merge.c
index e1f93e9714..2e468b507d 100644
--- a/merge.c
+++ b/merge.c
@@ -55,7 +55,7 @@ int checkout_fast_forward(const unsigned char *head,
 	struct dir_struct dir;
 	struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));
 
-	refresh_cache(REFRESH_QUIET);
+	refresh_index(&the_index, REFRESH_QUIET, NULL, NULL, NULL);
 
 	if (hold_locked_index(lock_file, LOCK_REPORT_ON_ERROR) < 0)
 		return -1;
diff --git a/wt-status.c b/wt-status.c
index 59cdf09a07..1c5dcd172e 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -2270,7 +2270,7 @@ int require_clean_work_tree(const char *action, const char *hint, int ignore_sub
 	int err = 0, fd;
 
 	fd = hold_locked_index(lock_file, 0);
-	refresh_cache(REFRESH_QUIET);
+	refresh_index(&the_index, REFRESH_QUIET, NULL, NULL, NULL);
 	if (0 <= fd)
 		update_index_if_able(&the_index, lock_file);
 	rollback_lock_file(lock_file);
-- 
2.13.0.rc1.39.ga6db8bfa24


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 22/24] cache.h: drop ce_modified
  2017-05-02 22:22 [PATCH 00/24] Retire NO_THE_INDEX_COMPATIBILITY_MACROS Stefan Beller
                   ` (20 preceding siblings ...)
  2017-05-02 22:23 ` [PATCH 21/24] cache.h: drop refresh_cache Stefan Beller
@ 2017-05-02 22:23 ` Stefan Beller
  2017-05-02 22:23 ` [PATCH 23/24] cache.h: drop ce_match_stat Stefan Beller
  2017-05-02 22:23 ` [PATCH 24/24] cache.h: retire NO_THE_INDEX_COMPATIBILITY_MACROS Stefan Beller
  23 siblings, 0 replies; 25+ messages in thread
From: Stefan Beller @ 2017-05-02 22:23 UTC (permalink / raw)
  To: gitster, git; +Cc: git, Stefan Beller

Signed-off-by: Stefan Beller <sbeller@google.com>
---
 builtin/ls-files.c | 2 +-
 cache.h            | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index 3507490d3e..89fac7ddf5 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -369,7 +369,7 @@ static void show_files(struct dir_struct *dir)
 			err = lstat(ce->name, &st);
 			if (show_deleted && err)
 				show_ce_entry(tag_removed, ce);
-			if (show_modified && ce_modified(ce, &st, 0))
+			if (show_modified && ie_modified(&the_index, ce, &st, 0))
 				show_ce_entry(tag_modified, ce);
 		}
 	}
diff --git a/cache.h b/cache.h
index 23c9c1697c..c34fc4fd40 100644
--- a/cache.h
+++ b/cache.h
@@ -355,7 +355,6 @@ extern void free_name_hash(struct index_state *istate);
 
 #ifndef NO_THE_INDEX_COMPATIBILITY_MACROS
 #define ce_match_stat(ce, st, options) ie_match_stat(&the_index, (ce), (st), (options))
-#define ce_modified(ce, st, options) ie_modified(&the_index, (ce), (st), (options))
 #endif
 
 enum object_type {
-- 
2.13.0.rc1.39.ga6db8bfa24


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 23/24] cache.h: drop ce_match_stat
  2017-05-02 22:22 [PATCH 00/24] Retire NO_THE_INDEX_COMPATIBILITY_MACROS Stefan Beller
                   ` (21 preceding siblings ...)
  2017-05-02 22:23 ` [PATCH 22/24] cache.h: drop ce_modified Stefan Beller
@ 2017-05-02 22:23 ` Stefan Beller
  2017-05-02 22:23 ` [PATCH 24/24] cache.h: retire NO_THE_INDEX_COMPATIBILITY_MACROS Stefan Beller
  23 siblings, 0 replies; 25+ messages in thread
From: Stefan Beller @ 2017-05-02 22:23 UTC (permalink / raw)
  To: gitster, git; +Cc: git, Stefan Beller

coccinelle patch:
@@ expression ce, st, options; @@
-ce_match_stat(ce, st, options)
+ie_match_stat(&the_index, ce, st, options)

Additionally drop the define from cache.h manually.

Note that there is an empty define section in cache.h now.
The cleanup of that is done in a later patch.

Signed-off-by: Stefan Beller <sbeller@google.com>
---
 apply.c                | 3 ++-
 builtin/rm.c           | 2 +-
 builtin/update-index.c | 2 +-
 cache.h                | 1 -
 check-racy.c           | 4 ++--
 diff-lib.c             | 2 +-
 diff.c                 | 2 +-
 entry.c                | 3 ++-
 submodule.c            | 2 +-
 9 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/apply.c b/apply.c
index 8a61f19d03..46bc5a20b9 100644
--- a/apply.c
+++ b/apply.c
@@ -3364,7 +3364,8 @@ static int verify_index_match(const struct cache_entry *ce, struct stat *st)
 			return -1;
 		return 0;
 	}
-	return ce_match_stat(ce, st, CE_MATCH_IGNORE_VALID|CE_MATCH_IGNORE_SKIP_WORKTREE);
+	return ie_match_stat(&the_index, ce, st,
+			     CE_MATCH_IGNORE_VALID | CE_MATCH_IGNORE_SKIP_WORKTREE);
 }
 
 #define SUBMODULE_PATCH_WITHOUT_INDEX 1
diff --git a/builtin/rm.c b/builtin/rm.c
index f479100298..51b64f2bae 100644
--- a/builtin/rm.c
+++ b/builtin/rm.c
@@ -163,7 +163,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 |
diff --git a/builtin/update-index.c b/builtin/update-index.c
index 9cbd346f95..042f4c94cf 100644
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
@@ -268,7 +268,7 @@ static int add_one_path(const struct cache_entry *old, const char *path, int len
 	struct cache_entry *ce;
 
 	/* Was the old index entry already up-to-date? */
-	if (old && !ce_stage(old) && !ce_match_stat(old, st, 0))
+	if (old && !ce_stage(old) && !ie_match_stat(&the_index, old, st, 0))
 		return 0;
 
 	size = cache_entry_size(len);
diff --git a/cache.h b/cache.h
index c34fc4fd40..f2a45eda9a 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 ce_match_stat(ce, st, options) ie_match_stat(&the_index, (ce), (st), (options))
 #endif
 
 enum object_type {
diff --git a/check-racy.c b/check-racy.c
index 6599ae84cf..485d7ab8f8 100644
--- a/check-racy.c
+++ b/check-racy.c
@@ -16,9 +16,9 @@ int main(int ac, char **av)
 			continue;
 		}
 
-		if (ce_match_stat(ce, &st, 0))
+		if (ie_match_stat(&the_index, ce, &st, 0))
 			dirty++;
-		else if (ce_match_stat(ce, &st, CE_MATCH_RACY_IS_DIRTY))
+		else if (ie_match_stat(&the_index, ce, &st, CE_MATCH_RACY_IS_DIRTY))
 			racy++;
 		else
 			clean++;
diff --git a/diff-lib.c b/diff-lib.c
index de59ec0459..4ca3ce9c90 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -69,7 +69,7 @@ static int match_stat_with_submodule(struct diff_options *diffopt,
 				     struct stat *st, unsigned ce_option,
 				     unsigned *dirty_submodule)
 {
-	int changed = ce_match_stat(ce, st, ce_option);
+	int changed = ie_match_stat(&the_index, ce, st, ce_option);
 	if (S_ISGITLINK(ce->ce_mode)) {
 		unsigned orig_flags = diffopt->flags;
 		if (!DIFF_OPT_TST(diffopt, OVERRIDE_SUBMODULE_CONFIG))
diff --git a/diff.c b/diff.c
index f2ee40fe21..bd1478f6c9 100644
--- a/diff.c
+++ b/diff.c
@@ -2782,7 +2782,7 @@ static int reuse_worktree_file(const char *name, const unsigned char *sha1, int
 	 * If ce matches the file in the work tree, we can reuse it.
 	 */
 	if (ce_uptodate(ce) ||
-	    (!lstat(name, &st) && !ce_match_stat(ce, &st, 0)))
+	    (!lstat(name, &st) && !ie_match_stat(&the_index, ce, &st, 0)))
 		return 1;
 
 	return 0;
diff --git a/entry.c b/entry.c
index d2b512da90..d3a34c9cc4 100644
--- a/entry.c
+++ b/entry.c
@@ -266,7 +266,8 @@ int checkout_entry(struct cache_entry *ce,
 
 	if (!check_path(path.buf, path.len, &st, state->base_dir_len)) {
 		const struct submodule *sub;
-		unsigned changed = ce_match_stat(ce, &st, CE_MATCH_IGNORE_VALID|CE_MATCH_IGNORE_SKIP_WORKTREE);
+		unsigned changed = ie_match_stat(&the_index, ce, &st,
+						 CE_MATCH_IGNORE_VALID | CE_MATCH_IGNORE_SKIP_WORKTREE);
 		/*
 		 * Needs to be checked before !changed returns early,
 		 * as the possibly empty directory was not changed
diff --git a/submodule.c b/submodule.c
index 6587bc0d84..43997f237e 100644
--- a/submodule.c
+++ b/submodule.c
@@ -191,7 +191,7 @@ void gitmodules_config(void)
 		} else if (pos < the_index.cache_nr) {
 			struct stat st;
 			if (lstat(".gitmodules", &st) == 0 &&
-			    ce_match_stat(the_index.cache[pos], &st, 0) & DATA_CHANGED)
+			    ie_match_stat(&the_index, the_index.cache[pos], &st, 0) & DATA_CHANGED)
 				gitmodules_is_modified = 1;
 		}
 
-- 
2.13.0.rc1.39.ga6db8bfa24


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 24/24] cache.h: retire NO_THE_INDEX_COMPATIBILITY_MACROS
  2017-05-02 22:22 [PATCH 00/24] Retire NO_THE_INDEX_COMPATIBILITY_MACROS Stefan Beller
                   ` (22 preceding siblings ...)
  2017-05-02 22:23 ` [PATCH 23/24] cache.h: drop ce_match_stat Stefan Beller
@ 2017-05-02 22:23 ` Stefan Beller
  23 siblings, 0 replies; 25+ messages in thread
From: Stefan Beller @ 2017-05-02 22:23 UTC (permalink / raw)
  To: gitster, git; +Cc: git, Stefan Beller

The NO_THE_INDEX_COMPATIBILITY_MACROS pre processor setting was introduced
in 4aab5b46f4 (Make read-cache.c "the_index" free., 2007-04-01), stating:

    This makes all low-level functions defined in read-cache.c to
    take an explicit index_state structure as their first parameter,
    to specify which index to work on.

The reasoning is very vague, maybe indicating that having the index
specified to work on is easier to for the new reader to understand what
is going on.

All preceding patches worked on retiring functions that do not take an
explicit index as to where to perform its work. Spelling out the reasons
why we want to specify the index at each call:

1)  Ease of understanding:
   The recent patches dropped a lot of macros that may confuse new people
   diving into the code base.
2a) Spelling out global state explicitly:
   Anything you do in submodule land today needs to spawn new processes in
   the submodule. This is cumbersome and not performant. So we may want to
   have an abstraction of a repo, i.e. all repository state in one struct.
   That way we can open a submodule in-process and perform the required
   actions without spawning a process. The road to this future is a long
   road, and we have to start somewhere. Exposing the global state seems
   like a good starter point.
2b) Spelling out global state explicitly (II): (Jeff Hostetler wrote)
   In addition to (eventually) allowing multiple repos be open at the same
   time for submodules, it would also help with various multi-threading
   efforts.  For example, we have loops that do a
   "for (k = 0, k < active_nr; k++) {...}"  There is no visual clue in that
   code that it references "the_index" and therefore should be subject to
   the same locking.  Granted, this is a trivial example, but goes to the
   argument that the code has lots of subtle global variables and macros
   that make it difficult to reason about the code.

   This step would help un-hide this.

Signed-off-by: Stefan Beller <sbeller@google.com>
---
 attr.c         | 1 -
 cache.h        | 4 ----
 name-hash.c    | 1 -
 read-cache.c   | 1 -
 unpack-trees.c | 1 -
 5 files changed, 8 deletions(-)

diff --git a/attr.c b/attr.c
index 7e2134471c..3decf432b8 100644
--- a/attr.c
+++ b/attr.c
@@ -7,7 +7,6 @@
  * an insanely large number of attributes.
  */
 
-#define NO_THE_INDEX_COMPATIBILITY_MACROS
 #include "cache.h"
 #include "exec_cmd.h"
 #include "attr.h"
diff --git a/cache.h b/cache.h
index f2a45eda9a..f4b7b8621c 100644
--- a/cache.h
+++ b/cache.h
@@ -352,10 +352,6 @@ extern void add_name_hash(struct index_state *istate, struct cache_entry *ce);
 extern void remove_name_hash(struct index_state *istate, struct cache_entry *ce);
 extern void free_name_hash(struct index_state *istate);
 
-
-#ifndef NO_THE_INDEX_COMPATIBILITY_MACROS
-#endif
-
 enum object_type {
 	OBJ_BAD = -1,
 	OBJ_NONE = 0,
diff --git a/name-hash.c b/name-hash.c
index 39309efb7f..02870c1d19 100644
--- a/name-hash.c
+++ b/name-hash.c
@@ -5,7 +5,6 @@
  *
  * Copyright (C) 2008 Linus Torvalds
  */
-#define NO_THE_INDEX_COMPATIBILITY_MACROS
 #include "cache.h"
 
 struct dir_entry {
diff --git a/read-cache.c b/read-cache.c
index 6681376f5b..e0c6f3ca11 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -3,7 +3,6 @@
  *
  * Copyright (C) Linus Torvalds, 2005
  */
-#define NO_THE_INDEX_COMPATIBILITY_MACROS
 #include "cache.h"
 #include "tempfile.h"
 #include "lockfile.h"
diff --git a/unpack-trees.c b/unpack-trees.c
index 3dd8f60fc1..41956c4b37 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -1,4 +1,3 @@
-#define NO_THE_INDEX_COMPATIBILITY_MACROS
 #include "cache.h"
 #include "dir.h"
 #include "tree.h"
-- 
2.13.0.rc1.39.ga6db8bfa24


^ permalink raw reply related	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2017-05-02 22:24 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-02 22:22 [PATCH 00/24] Retire NO_THE_INDEX_COMPATIBILITY_MACROS Stefan Beller
2017-05-02 22:22 ` [PATCH 01/24] cache.h: drop read_cache() Stefan Beller
2017-05-02 22:23 ` [PATCH 02/24] cache.h: drop active_* macros Stefan Beller
2017-05-02 22:23 ` [PATCH 03/24] cache.h: drop read_cache_from Stefan Beller
2017-05-02 22:23 ` [PATCH 04/24] cache.h: drop read_cache_preload(pathspec) Stefan Beller
2017-05-02 22:23 ` [PATCH 05/24] cache.h: drop read_cache_unmerged() Stefan Beller
2017-05-02 22:23 ` [PATCH 06/24] unpack-trees.c: rename parameter 'the_index' Stefan Beller
2017-05-02 22:23 ` [PATCH 07/24] cache.h: drop read_blob_data_from_cache Stefan Beller
2017-05-02 22:23 ` [PATCH 08/24] cache.h: drop unmerge_cache[_entry_at] Stefan Beller
2017-05-02 22:23 ` [PATCH 09/24] cache.h: drop resolve_undo_clear Stefan Beller
2017-05-02 22:23 ` [PATCH 10/24] cache.h: drop cache_name_is_other Stefan Beller
2017-05-02 22:23 ` [PATCH 11/24] cache.h: drop cache_file_exists Stefan Beller
2017-05-02 22:23 ` [PATCH 12/24] cache.h: drop cache_dir_exists Stefan Beller
2017-05-02 22:23 ` [PATCH 13/24] cache.h: drop is_cache_unborn(), discard_cache(), unmerged_cache() Stefan Beller
2017-05-02 22:23 ` [PATCH 14/24] cache.h: drop cache_name_pos Stefan Beller
2017-05-02 22:23 ` [PATCH 15/24] cache.h: drop add_cache_entry Stefan Beller
2017-05-02 22:23 ` [PATCH 16/24] cache.h: drop rename_cache_entry_at Stefan Beller
2017-05-02 22:23 ` [PATCH 17/24] cache.h: drop remove_file_from_cache Stefan Beller
2017-05-02 22:23 ` [PATCH 18/24] cache.h: drop add_to_cache Stefan Beller
2017-05-02 22:23 ` [PATCH 19/24] cache.h: drop add_file_to_cache Stefan Beller
2017-05-02 22:23 ` [PATCH 20/24] cache.h: drop chmod_cache_entry Stefan Beller
2017-05-02 22:23 ` [PATCH 21/24] cache.h: drop refresh_cache Stefan Beller
2017-05-02 22:23 ` [PATCH 22/24] cache.h: drop ce_modified Stefan Beller
2017-05-02 22:23 ` [PATCH 23/24] cache.h: drop ce_match_stat Stefan Beller
2017-05-02 22:23 ` [PATCH 24/24] cache.h: retire NO_THE_INDEX_COMPATIBILITY_MACROS Stefan Beller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.