{"thread":{"id":"45853","subject":"[PATCH 00/24] Retire NO_THE_INDEX_COMPATIBILITY_MACROS","startedAt":"2017-05-02T22:23:38Z","lastAt":"2017-05-02T22:24:45Z","messageCount":25,"participants":["Stefan Beller"],"isPatch":true,"patchVersion":1,"patchTotal":24},"messages":[{"id":"318570","messageId":"20170502222322.21055-1-sbeller@google.com","threadId":"45853","inReplyTo":null,"subject":"[PATCH 00/24] Retire NO_THE_INDEX_COMPATIBILITY_MACROS","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-05-02T22:22:58Z","receivedAt":"2017-05-02T22:23:38Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"This is the follow up to [1], but actually completed now.\n\nThe reasoning why this series is a good idea is in the commit message of the\nlast patch, quoted here:\n\nThe NO_THE_INDEX_COMPATIBILITY_MACROS pre processor setting was introduced\nin 4aab5b46f4 (Make read-cache.c \"the_index\" free., 2007-04-01), stating:\n\n    This makes all low-level functions defined in read-cache.c to\n    take an explicit index_state structure as their first parameter,\n    to specify which index to work on.\n\nThe reasoning is very vague, maybe indicating that having the index\nspecified to work on is easier to for the new reader to understand what\nis going on.\n\nAll preceding patches worked on retiring functions that do not take an\nexplicit index as to where to perform its work. Spelling out the reasons\nwhy we want to specify the index at each call:\n\n1)  Ease of understanding:\n   The recent patches dropped a lot of macros that may confuse new people\n   diving into the code base.\n2a) Spelling out global state explicitly:\n   Anything you do in submodule land today needs to spawn new processes in\n   the submodule. This is cumbersome and not performant. So we may want to\n   have an abstraction of a repo, i.e. all repository state in one struct.\n   That way we can open a submodule in-process and perform the required\n   actions without spawning a process. The road to this future is a long\n   road, and we have to start somewhere. Exposing the global state seems\n   like a good starter point.\n2b) Spelling out global state explicitly (II): (Jeff Hostetler wrote)\n   In addition to (eventually) allowing multiple repos be open at the same\n   time for submodules, it would also help with various multi-threading\n   efforts.  For example, we have loops that do a\n   \"for (k = 0, k < active_nr; k++) {...}\"  There is no visual clue in that\n   code that it references \"the_index\" and therefore should be subject to\n   the same locking.  Granted, this is a trivial example, but goes to the\n   argument that the code has lots of subtle global variables and macros\n   that make it difficult to reason about the code.\n\n   This step would help un-hide this.\n   \n\nReview as well as critique if this is the right approach to an endgame with\nless globals splattered throughout the codebase is welcome.\n\nThanks,\nStefan\n\n[1] https://public-inbox.org/git/20170501190719.10669-1-sbeller@google.com/\n\nStefan Beller (24):\n  cache.h: drop read_cache()\n  cache.h: drop active_* macros\n  cache.h: drop read_cache_from\n  cache.h: drop read_cache_preload(pathspec)\n  cache.h: drop read_cache_unmerged()\n  unpack-trees.c: rename parameter 'the_index'\n  cache.h: drop read_blob_data_from_cache\n  cache.h: drop unmerge_cache[_entry_at]\n  cache.h: drop resolve_undo_clear\n  cache.h: drop cache_name_is_other\n  cache.h: drop cache_file_exists\n  cache.h: drop cache_dir_exists\n  cache.h: drop is_cache_unborn(), discard_cache(), unmerged_cache()\n  cache.h: drop cache_name_pos\n  cache.h: drop add_cache_entry\n  cache.h: drop rename_cache_entry_at\n  cache.h: drop remove_file_from_cache\n  cache.h: drop add_to_cache\n  cache.h: drop add_file_to_cache\n  cache.h: drop chmod_cache_entry\n  cache.h: drop refresh_cache\n  cache.h: drop ce_modified\n  cache.h: drop ce_match_stat\n  cache.h: retire NO_THE_INDEX_COMPATIBILITY_MACROS\n\n apply.c                              | 32 +++++++------\n attr.c                               |  1 -\n builtin/add.c                        | 12 ++---\n builtin/am.c                         | 26 +++++------\n builtin/blame.c                      | 19 ++++----\n builtin/check-attr.c                 |  2 +-\n builtin/check-ignore.c               |  4 +-\n builtin/checkout-index.c             | 12 ++---\n builtin/checkout.c                   | 66 +++++++++++++-------------\n builtin/clean.c                      |  4 +-\n builtin/commit.c                     | 52 ++++++++++-----------\n builtin/describe.c                   |  2 +-\n builtin/diff-files.c                 |  4 +-\n builtin/diff-index.c                 |  6 +--\n builtin/diff.c                       | 19 ++++----\n builtin/fsck.c                       | 14 +++---\n builtin/grep.c                       | 10 ++--\n builtin/ls-files.c                   | 49 +++++++++----------\n builtin/merge-index.c                | 14 +++---\n builtin/merge.c                      | 24 +++++-----\n builtin/mv.c                         | 22 ++++-----\n builtin/pull.c                       |  4 +-\n builtin/read-tree.c                  |  8 ++--\n builtin/reset.c                      | 11 +++--\n builtin/rev-parse.c                  |  2 +-\n builtin/rm.c                         | 26 +++++------\n builtin/submodule--helper.c          | 10 ++--\n builtin/update-index.c               | 91 +++++++++++++++++++-----------------\n cache.h                              | 35 --------------\n check-racy.c                         | 10 ++--\n convert.c                            |  4 +-\n diff-lib.c                           |  8 ++--\n diff.c                               | 14 +++---\n dir.c                                | 41 ++++++++--------\n entry.c                              |  3 +-\n merge-recursive.c                    | 65 +++++++++++++-------------\n merge.c                              |  8 ++--\n name-hash.c                          |  1 -\n pathspec.c                           | 16 +++----\n read-cache.c                         |  5 +-\n rerere.c                             | 38 +++++++--------\n revision.c                           | 22 ++++-----\n sequencer.c                          | 29 ++++++------\n sha1_name.c                          | 22 ++++-----\n submodule.c                          | 20 ++++----\n t/helper/test-dump-cache-tree.c      |  4 +-\n t/helper/test-dump-untracked-cache.c |  2 +-\n t/helper/test-lazy-init-name-hash.c  | 20 ++++----\n t/helper/test-read-cache.c           |  4 +-\n t/helper/test-scrap-cache-tree.c     |  4 +-\n t/t2107-update-index-basic.sh        |  2 +-\n tree.c                               | 10 ++--\n unpack-trees.c                       |  9 ++--\n wt-status.c                          | 24 +++++-----\n 54 files changed, 471 insertions(+), 495 deletions(-)\n\n-- \n2.13.0.rc1.39.ga6db8bfa24\n\n"},{"id":"318571","messageId":"20170502222322.21055-2-sbeller@google.com","threadId":"45853","inReplyTo":"20170502222322.21055-1-sbeller@google.com","subject":"[PATCH 01/24] cache.h: drop read_cache()","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-05-02T22:22:59Z","receivedAt":"2017-05-02T22:23:40Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"This patch is produced via coccinelle using this semantic patch:\n\n@@ @@\n-read_cache()\n+read_index(&the_index)\n\nAdditional manual editing:\n* drop define in cache.h\n* a comment in builtin/check-ignore.c and read-cache.c were\n  converted\n* builtin/diff.c: fix error message referencing the function.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n apply.c                              |  2 +-\n builtin/add.c                        |  4 ++--\n builtin/am.c                         |  2 +-\n builtin/blame.c                      |  4 ++--\n builtin/check-attr.c                 |  2 +-\n builtin/check-ignore.c               |  4 ++--\n builtin/checkout-index.c             |  2 +-\n builtin/clean.c                      |  2 +-\n builtin/commit.c                     |  4 ++--\n builtin/diff-index.c                 |  2 +-\n builtin/diff.c                       |  6 +++---\n builtin/fsck.c                       |  2 +-\n builtin/grep.c                       |  2 +-\n builtin/ls-files.c                   |  2 +-\n builtin/merge-index.c                |  2 +-\n builtin/mv.c                         |  2 +-\n builtin/reset.c                      |  2 +-\n builtin/rev-parse.c                  |  2 +-\n builtin/rm.c                         |  2 +-\n builtin/submodule--helper.c          |  2 +-\n builtin/update-index.c               |  2 +-\n cache.h                              |  1 -\n check-racy.c                         |  2 +-\n diff.c                               |  2 +-\n merge-recursive.c                    |  2 +-\n merge.c                              |  2 +-\n read-cache.c                         |  2 +-\n rerere.c                             |  6 +++---\n revision.c                           |  4 ++--\n sequencer.c                          |  6 +++---\n sha1_name.c                          |  2 +-\n submodule.c                          |  4 ++--\n t/helper/test-dump-cache-tree.c      |  2 +-\n t/helper/test-dump-untracked-cache.c |  2 +-\n t/helper/test-lazy-init-name-hash.c  | 10 +++++-----\n t/helper/test-read-cache.c           |  2 +-\n t/helper/test-scrap-cache-tree.c     |  2 +-\n 37 files changed, 52 insertions(+), 53 deletions(-)\n\ndiff --git a/apply.c b/apply.c\nindex e6dbab26ad..82701d6580 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -3987,7 +3987,7 @@ static int read_apply_cache(struct apply_state *state)\n \tif (state->index_file)\n \t\treturn read_cache_from(state->index_file);\n \telse\n-\t\treturn read_cache();\n+\t\treturn read_index(&the_index);\n }\n \n /* This function tries to read the object name from the current index */\ndiff --git a/builtin/add.c b/builtin/add.c\nindex 9f53f020d0..ab6d04e8db 100644\n--- a/builtin/add.c\n+++ b/builtin/add.c\n@@ -205,7 +205,7 @@ static int edit_patch(int argc, const char **argv, const char *prefix)\n \n \tgit_config(git_diff_basic_config, NULL); /* no \"diff\" UI options */\n \n-\tif (read_cache() < 0)\n+\tif (read_index(&the_index) < 0)\n \t\tdie(_(\"Could not read the index\"));\n \n \tinit_revisions(&rev, prefix);\n@@ -376,7 +376,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)\n \t\treturn 0;\n \t}\n \n-\tif (read_cache() < 0)\n+\tif (read_index(&the_index) < 0)\n \t\tdie(_(\"index file corrupt\"));\n \n \t/*\ndiff --git a/builtin/am.c b/builtin/am.c\nindex a95dd8b4e6..4405d7307c 100644\n--- a/builtin/am.c\n+++ b/builtin/am.c\n@@ -1633,7 +1633,7 @@ static int fall_back_threeway(const struct am_state *state, const char *index_pa\n \tsay(state, stdout, _(\"Falling back to patching base and 3-way merge...\"));\n \n \tdiscard_cache();\n-\tread_cache();\n+\tread_index(&the_index);\n \n \t/*\n \t * This is not so wrong. Depending on which base we picked, orig_tree\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex 07506a3e45..59955208fd 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -2313,7 +2313,7 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,\n \tunsigned mode;\n \tstruct strbuf msg = STRBUF_INIT;\n \n-\tread_cache();\n+\tread_index(&the_index);\n \ttime(&now);\n \tcommit = alloc_commit_node();\n \tcommit->object.parsed = 1;\n@@ -2395,7 +2395,7 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,\n \t * want to run \"diff-index --cached\".\n \t */\n \tdiscard_cache();\n-\tread_cache();\n+\tread_index(&the_index);\n \n \tlen = strlen(path);\n \tif (!mode) {\ndiff --git a/builtin/check-attr.c b/builtin/check-attr.c\nindex 4d01ca0c8b..9cc3675d62 100644\n--- a/builtin/check-attr.c\n+++ b/builtin/check-attr.c\n@@ -114,7 +114,7 @@ int cmd_check_attr(int argc, const char **argv, const char *prefix)\n \targc = parse_options(argc, argv, prefix, check_attr_options,\n \t\t\t     check_attr_usage, PARSE_OPT_KEEP_DASHDASH);\n \n-\tif (read_cache() < 0) {\n+\tif (read_index(&the_index) < 0) {\n \t\tdie(\"invalid cache\");\n \t}\n \ndiff --git a/builtin/check-ignore.c b/builtin/check-ignore.c\nindex 1d73d3ca3d..e526b27151 100644\n--- a/builtin/check-ignore.c\n+++ b/builtin/check-ignore.c\n@@ -167,8 +167,8 @@ int cmd_check_ignore(int argc, const char **argv, const char *prefix)\n \tif (show_non_matching && !verbose)\n \t\tdie(_(\"--non-matching is only valid with --verbose\"));\n \n-\t/* read_cache() is only necessary so we can watch out for submodules. */\n-\tif (!no_index && read_cache() < 0)\n+\t/* read_index() is only necessary so we can watch out for submodules. */\n+\tif (!no_index && read_index(&the_index) < 0)\n \t\tdie(_(\"index file corrupt\"));\n \n \tmemset(&dir, 0, sizeof(dir));\ndiff --git a/builtin/checkout-index.c b/builtin/checkout-index.c\nindex 07631d0c9c..676b9419f0 100644\n--- a/builtin/checkout-index.c\n+++ b/builtin/checkout-index.c\n@@ -185,7 +185,7 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix)\n \tgit_config(git_default_config, NULL);\n \tprefix_length = prefix ? strlen(prefix) : 0;\n \n-\tif (read_cache() < 0) {\n+\tif (read_index(&the_index) < 0) {\n \t\tdie(\"invalid cache\");\n \t}\n \ndiff --git a/builtin/clean.c b/builtin/clean.c\nindex d861f836a2..9bdefca6dc 100644\n--- a/builtin/clean.c\n+++ b/builtin/clean.c\n@@ -916,7 +916,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix)\n \n \tdir.flags |= DIR_SHOW_OTHER_DIRECTORIES;\n \n-\tif (read_cache() < 0)\n+\tif (read_index(&the_index) < 0)\n \t\tdie(_(\"index file corrupt\"));\n \n \tif (!ignored)\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 1d805f5da8..7cd08841a1 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -465,7 +465,7 @@ static const char *prepare_index(int argc, const char **argv, const char *prefix\n \t\texit(1);\n \n \tdiscard_cache();\n-\tif (read_cache() < 0)\n+\tif (read_index(&the_index) < 0)\n \t\tdie(_(\"cannot read the index\"));\n \n \thold_locked_index(&index_lock, LOCK_DIE_ON_ERROR);\n@@ -888,7 +888,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,\n \t\tstruct object_id oid;\n \t\tconst char *parent = \"HEAD\";\n \n-\t\tif (!active_nr && read_cache() < 0)\n+\t\tif (!active_nr && read_index(&the_index) < 0)\n \t\t\tdie(_(\"Cannot read index\"));\n \n \t\tif (amend)\ndiff --git a/builtin/diff-index.c b/builtin/diff-index.c\nindex 1af373d002..49fd64d4ce 100644\n--- a/builtin/diff-index.c\n+++ b/builtin/diff-index.c\n@@ -48,7 +48,7 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix)\n \t\t\tperror(\"read_cache_preload\");\n \t\t\treturn -1;\n \t\t}\n-\t} else if (read_cache() < 0) {\n+\t} else if (read_index(&the_index) < 0) {\n \t\tperror(\"read_cache\");\n \t\treturn -1;\n \t}\ndiff --git a/builtin/diff.c b/builtin/diff.c\nindex d184aafab9..ed9edb2d0c 100644\n--- a/builtin/diff.c\n+++ b/builtin/diff.c\n@@ -148,8 +148,8 @@ static int builtin_diff_index(struct rev_info *revs,\n \t\t\tperror(\"read_cache_preload\");\n \t\t\treturn -1;\n \t\t}\n-\t} else if (read_cache() < 0) {\n-\t\tperror(\"read_cache\");\n+\t} else if (read_index(&the_index) < 0) {\n+\t\tperror(\"read_index\");\n \t\treturn -1;\n \t}\n \treturn run_diff_index(revs, cached);\n@@ -210,7 +210,7 @@ static void refresh_index_quietly(void)\n \tif (fd < 0)\n \t\treturn;\n \tdiscard_cache();\n-\tread_cache();\n+\tread_index(&the_index);\n \trefresh_cache(REFRESH_QUIET|REFRESH_UNMERGED);\n \tupdate_index_if_able(&the_index, lock_file);\n }\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex b5e13a4556..35e03556cb 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -772,7 +772,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)\n \n \tif (keep_cache_objects) {\n \t\tverify_index_checksum = 1;\n-\t\tread_cache();\n+\t\tread_index(&the_index);\n \t\tfor (i = 0; i < active_nr; i++) {\n \t\t\tunsigned int mode;\n \t\t\tstruct blob *blob;\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 3ffb5b4e81..5153dbf262 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -676,7 +676,7 @@ static int grep_cache(struct grep_opt *opt, const struct pathspec *pathspec,\n \t\tstrbuf_addstr(&name, super_prefix);\n \t}\n \n-\tread_cache();\n+\tread_index(&the_index);\n \n \tfor (nr = 0; nr < active_nr; nr++) {\n \t\tconst struct cache_entry *ce = active_cache[nr];\ndiff --git a/builtin/ls-files.c b/builtin/ls-files.c\nindex a6c70dbe9e..da4779ec0b 100644\n--- a/builtin/ls-files.c\n+++ b/builtin/ls-files.c\n@@ -578,7 +578,7 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)\n \tsuper_prefix = get_super_prefix();\n \tgit_config(git_default_config, NULL);\n \n-\tif (read_cache() < 0)\n+\tif (read_index(&the_index) < 0)\n \t\tdie(\"index file corrupt\");\n \n \targc = parse_options(argc, argv, prefix, builtin_ls_files_options,\ndiff --git a/builtin/merge-index.c b/builtin/merge-index.c\nindex c99443b095..51fb590dfa 100644\n--- a/builtin/merge-index.c\n+++ b/builtin/merge-index.c\n@@ -77,7 +77,7 @@ int cmd_merge_index(int argc, const char **argv, const char *prefix)\n \tif (argc < 3)\n \t\tusage(\"git merge-index [-o] [-q] <merge-program> (-a | [--] [<filename>...])\");\n \n-\tread_cache();\n+\tread_index(&the_index);\n \n \ti = 1;\n \tif (!strcmp(argv[i], \"-o\")) {\ndiff --git a/builtin/mv.c b/builtin/mv.c\nindex 61d20037ad..6fd7a3a9d8 100644\n--- a/builtin/mv.c\n+++ b/builtin/mv.c\n@@ -139,7 +139,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)\n \t\tusage_with_options(builtin_mv_usage, builtin_mv_options);\n \n \thold_locked_index(&lock_file, LOCK_DIE_ON_ERROR);\n-\tif (read_cache() < 0)\n+\tif (read_index(&the_index) < 0)\n \t\tdie(_(\"index file corrupt\"));\n \n \tsource = internal_prefix_pathspec(prefix, argv, argc, 0);\ndiff --git a/builtin/reset.c b/builtin/reset.c\nindex fc3b906c47..03c5498d6e 100644\n--- a/builtin/reset.c\n+++ b/builtin/reset.c\n@@ -231,7 +231,7 @@ static void parse_args(struct pathspec *pathspec,\n \t}\n \t*rev_ret = rev;\n \n-\tif (read_cache() < 0)\n+\tif (read_index(&the_index) < 0)\n \t\tdie(_(\"index file corrupt\"));\n \n \tparse_pathspec(pathspec, 0,\ndiff --git a/builtin/rev-parse.c b/builtin/rev-parse.c\nindex 0513330910..0c6352a018 100644\n--- a/builtin/rev-parse.c\n+++ b/builtin/rev-parse.c\n@@ -868,7 +868,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)\n \t\t\t\tcontinue;\n \t\t\t}\n \t\t\tif (!strcmp(arg, \"--shared-index-path\")) {\n-\t\t\t\tif (read_cache() < 0)\n+\t\t\t\tif (read_index(&the_index) < 0)\n \t\t\t\t\tdie(_(\"Could not read the index\"));\n \t\t\t\tif (the_index.split_index) {\n \t\t\t\t\tconst unsigned char *sha1 = the_index.split_index->base_sha1;\ndiff --git a/builtin/rm.c b/builtin/rm.c\nindex fb79dcab18..d0eecbdaac 100644\n--- a/builtin/rm.c\n+++ b/builtin/rm.c\n@@ -267,7 +267,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)\n \n \thold_locked_index(&lock_file, LOCK_DIE_ON_ERROR);\n \n-\tif (read_cache() < 0)\n+\tif (read_index(&the_index) < 0)\n \t\tdie(_(\"index file corrupt\"));\n \n \tparse_pathspec(&pathspec, 0,\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 566a5b6a6f..1281056312 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -240,7 +240,7 @@ static int module_list_compute(int argc, const char **argv,\n \tif (pathspec->nr)\n \t\tps_matched = xcalloc(pathspec->nr, 1);\n \n-\tif (read_cache() < 0)\n+\tif (read_index(&the_index) < 0)\n \t\tdie(_(\"index file corrupt\"));\n \n \tfor (i = 0; i < active_nr; i++) {\ndiff --git a/builtin/update-index.c b/builtin/update-index.c\nindex ebfc09faa0..7a4b914af4 100644\n--- a/builtin/update-index.c\n+++ b/builtin/update-index.c\n@@ -1021,7 +1021,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)\n \tif (newfd < 0)\n \t\tlock_error = errno;\n \n-\tentries = read_cache();\n+\tentries = read_index(&the_index);\n \tif (entries < 0)\n \t\tdie(\"cache corrupted\");\n \ndiff --git a/cache.h b/cache.h\nindex e1f0e182ad..9a1ea38a14 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -360,7 +360,6 @@ extern void free_name_hash(struct index_state *istate);\n #define active_cache_changed (the_index.cache_changed)\n #define active_cache_tree (the_index.cache_tree)\n \n-#define read_cache() read_index(&the_index)\n #define read_cache_from(path) read_index_from(&the_index, (path))\n #define read_cache_preload(pathspec) read_index_preload(&the_index, (pathspec))\n #define is_cache_unborn() is_index_unborn(&the_index)\ndiff --git a/check-racy.c b/check-racy.c\nindex 24b6542352..f50b21cb06 100644\n--- a/check-racy.c\n+++ b/check-racy.c\n@@ -6,7 +6,7 @@ int main(int ac, char **av)\n \tint dirty, clean, racy;\n \n \tdirty = clean = racy = 0;\n-\tread_cache();\n+\tread_index(&the_index);\n \tfor (i = 0; i < active_nr; i++) {\n \t\tstruct cache_entry *ce = active_cache[i];\n \t\tstruct stat st;\ndiff --git a/diff.c b/diff.c\nindex 11eef1c85d..05d0312265 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -3497,7 +3497,7 @@ void diff_setup_done(struct diff_options *options)\n \t\t\t * when it fails, so we do not have to worry about\n \t\t\t * cleaning it up ourselves either.\n \t\t\t */\n-\t\t\tread_cache();\n+\t\t\tread_index(&the_index);\n \t}\n \tif (40 < options->abbrev)\n \t\toptions->abbrev = 40; /* full */\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 62decd51cc..3cfaf33faa 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -2075,7 +2075,7 @@ int merge_recursive(struct merge_options *o,\n \n \tdiscard_cache();\n \tif (!o->call_depth)\n-\t\tread_cache();\n+\t\tread_index(&the_index);\n \n \to->ancestor = \"merged common ancestors\";\n \tclean = merge_trees(o, h1->tree, h2->tree, merged_common_ancestors->tree,\ndiff --git a/merge.c b/merge.c\nindex 04ee5fc911..748305031e 100644\n--- a/merge.c\n+++ b/merge.c\n@@ -37,7 +37,7 @@ int try_merge_command(const char *strategy, size_t xopts_nr,\n \targv_array_clear(&args);\n \n \tdiscard_cache();\n-\tif (read_cache() < 0)\n+\tif (read_index(&the_index) < 0)\n \t\tdie(_(\"failed to read the cache\"));\n \tresolve_undo_clear();\n \ndiff --git a/read-cache.c b/read-cache.c\nindex b3d0f3c30b..f1bdb006f4 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -2506,7 +2506,7 @@ int write_locked_index(struct index_state *istate, struct lock_file *lock,\n  * index_state, dropping any unmerged entries.  Returns true if\n  * the index is unmerged.  Callers who want to refuse to work\n  * from an unmerged state can call this and check its return value,\n- * instead of calling read_cache().\n+ * instead of calling read_index().\n  */\n int read_index_unmerged(struct index_state *istate)\n {\ndiff --git a/rerere.c b/rerere.c\nindex 3bd55caf3b..770b34a5c9 100644\n--- a/rerere.c\n+++ b/rerere.c\n@@ -566,7 +566,7 @@ static int check_one_conflict(int i, int *type)\n static int find_conflict(struct string_list *conflict)\n {\n \tint i;\n-\tif (read_cache() < 0)\n+\tif (read_index(&the_index) < 0)\n \t\treturn error(\"Could not read index\");\n \n \tfor (i = 0; i < active_nr;) {\n@@ -599,7 +599,7 @@ int rerere_remaining(struct string_list *merge_rr)\n \tint i;\n \tif (setup_rerere(merge_rr, RERERE_READONLY))\n \t\treturn 0;\n-\tif (read_cache() < 0)\n+\tif (read_index(&the_index) < 0)\n \t\treturn error(\"Could not read index\");\n \n \tfor (i = 0; i < active_nr;) {\n@@ -1104,7 +1104,7 @@ int rerere_forget(struct pathspec *pathspec)\n \tstruct string_list conflict = STRING_LIST_INIT_DUP;\n \tstruct string_list merge_rr = STRING_LIST_INIT_DUP;\n \n-\tif (read_cache() < 0)\n+\tif (read_index(&the_index) < 0)\n \t\treturn error(\"Could not read index\");\n \n \tfd = setup_rerere(&merge_rr, RERERE_NOAUTOUPDATE);\ndiff --git a/revision.c b/revision.c\nindex 7ff61ff5f7..bb6250ef02 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -1267,7 +1267,7 @@ void add_index_objects_to_pending(struct rev_info *revs, unsigned flags)\n {\n \tint i;\n \n-\tread_cache();\n+\tread_index(&the_index);\n \tfor (i = 0; i < active_nr; i++) {\n \t\tstruct cache_entry *ce = active_cache[i];\n \t\tstruct blob *blob;\n@@ -1408,7 +1408,7 @@ static void prepare_show_merge(struct rev_info *revs)\n \thead->object.flags |= SYMMETRIC_LEFT;\n \n \tif (!active_nr)\n-\t\tread_cache();\n+\t\tread_index(&the_index);\n \tfor (i = 0; i < active_nr; i++) {\n \t\tconst struct cache_entry *ce = active_cache[i];\n \t\tif (!ce_stage(ce))\ndiff --git a/sequencer.c b/sequencer.c\nindex 10c3b4ff81..b7ec4e3221 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -381,7 +381,7 @@ static int fast_forward_to(const unsigned char *to, const unsigned char *from,\n \tstruct strbuf sb = STRBUF_INIT;\n \tstruct strbuf err = STRBUF_INIT;\n \n-\tread_cache();\n+\tread_index(&the_index);\n \tif (checkout_fast_forward(from, to, 1))\n \t\treturn -1; /* the callee should have complained already */\n \n@@ -437,7 +437,7 @@ static int do_recursive_merge(struct commit *base, struct commit *next,\n \n \thold_locked_index(&index_lock, LOCK_DIE_ON_ERROR);\n \n-\tread_cache();\n+\tread_index(&the_index);\n \n \tinit_merge_options(&o);\n \to.ancestor = base ? base_label : \"(empty tree)\";\n@@ -1844,7 +1844,7 @@ static int do_exec(const char *command_line)\n \tstatus = run_command_v_opt(child_argv, RUN_USING_SHELL);\n \n \t/* force re-reading of the cache */\n-\tif (discard_cache() < 0 || read_cache() < 0)\n+\tif (discard_cache() < 0 || read_index(&the_index) < 0)\n \t\treturn error(_(\"could not read index\"));\n \n \tdirty = require_clean_work_tree(\"rebase\", NULL, 1, 1);\ndiff --git a/sha1_name.c b/sha1_name.c\nindex 8eec9f7c1b..38473b1e6d 100644\n--- a/sha1_name.c\n+++ b/sha1_name.c\n@@ -1552,7 +1552,7 @@ static int get_sha1_with_context_1(const char *name,\n \t\tstrlcpy(oc->path, cp, sizeof(oc->path));\n \n \t\tif (!active_cache)\n-\t\t\tread_cache();\n+\t\t\tread_index(&the_index);\n \t\tpos = cache_name_pos(cp, namelen);\n \t\tif (pos < 0)\n \t\t\tpos = -pos - 1;\ndiff --git a/submodule.c b/submodule.c\nindex d3299e29c0..4d77291b11 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -177,7 +177,7 @@ void gitmodules_config(void)\n \t\tint pos;\n \t\tstrbuf_addstr(&gitmodules_path, work_tree);\n \t\tstrbuf_addstr(&gitmodules_path, \"/.gitmodules\");\n-\t\tif (read_cache() < 0)\n+\t\tif (read_index(&the_index) < 0)\n \t\t\tdie(\"index file corrupt\");\n \t\tpos = cache_name_pos(\".gitmodules\", 11);\n \t\tif (pos < 0) { /* .gitmodules not found or isn't merged */\n@@ -1151,7 +1151,7 @@ int fetch_populated_submodules(const struct argv_array *options,\n \tif (!spf.work_tree)\n \t\tgoto out;\n \n-\tif (read_cache() < 0)\n+\tif (read_index(&the_index) < 0)\n \t\tdie(\"index file corrupt\");\n \n \targv_array_push(&spf.args, \"fetch\");\ndiff --git a/t/helper/test-dump-cache-tree.c b/t/helper/test-dump-cache-tree.c\nindex 7af116d49e..ed037a52f4 100644\n--- a/t/helper/test-dump-cache-tree.c\n+++ b/t/helper/test-dump-cache-tree.c\n@@ -59,7 +59,7 @@ int cmd_main(int ac, const char **av)\n \tstruct index_state istate;\n \tstruct cache_tree *another = cache_tree();\n \tsetup_git_directory();\n-\tif (read_cache() < 0)\n+\tif (read_index(&the_index) < 0)\n \t\tdie(\"unable to read index file\");\n \tistate = the_index;\n \tistate.cache_tree = another;\ndiff --git a/t/helper/test-dump-untracked-cache.c b/t/helper/test-dump-untracked-cache.c\nindex f752532ffb..7832e833af 100644\n--- a/t/helper/test-dump-untracked-cache.c\n+++ b/t/helper/test-dump-untracked-cache.c\n@@ -47,7 +47,7 @@ int cmd_main(int ac, const char **av)\n \tignore_untracked_cache_config = 1;\n \n \tsetup_git_directory();\n-\tif (read_cache() < 0)\n+\tif (read_index(&the_index) < 0)\n \t\tdie(\"unable to read index file\");\n \tuc = the_index.untracked;\n \tif (!uc) {\ndiff --git a/t/helper/test-lazy-init-name-hash.c b/t/helper/test-lazy-init-name-hash.c\nindex 6368a89345..bd747dcbcd 100644\n--- a/t/helper/test-lazy-init-name-hash.c\n+++ b/t/helper/test-lazy-init-name-hash.c\n@@ -31,7 +31,7 @@ static void dump_run(void)\n \tstruct dir_entry *dir;\n \tstruct cache_entry *ce;\n \n-\tread_cache();\n+\tread_index(&the_index);\n \tif (single) {\n \t\ttest_lazy_init_name_hash(&the_index, 0);\n \t} else {\n@@ -69,7 +69,7 @@ static uint64_t time_runs(int try_threaded)\n \n \tfor (i = 0; i < count; i++) {\n \t\tt0 = getnanotime();\n-\t\tread_cache();\n+\t\tread_index(&the_index);\n \t\tt1 = getnanotime();\n \t\tnr_threads_used = test_lazy_init_name_hash(&the_index, try_threaded);\n \t\tt2 = getnanotime();\n@@ -116,7 +116,7 @@ static void analyze_run(void)\n \tint i;\n \tint nr;\n \n-\tread_cache();\n+\tread_index(&the_index);\n \tcache_nr_limit = the_index.cache_nr;\n \tdiscard_cache();\n \n@@ -131,7 +131,7 @@ static void analyze_run(void)\n \t\t\tnr = cache_nr_limit;\n \n \t\tfor (i = 0; i < count; i++) {\n-\t\t\tread_cache();\n+\t\t\tread_index(&the_index);\n \t\t\tthe_index.cache_nr = nr; /* cheap truncate of index */\n \t\t\tt1s = getnanotime();\n \t\t\ttest_lazy_init_name_hash(&the_index, 0);\n@@ -140,7 +140,7 @@ static void analyze_run(void)\n \t\t\tthe_index.cache_nr = cache_nr_limit;\n \t\t\tdiscard_cache();\n \n-\t\t\tread_cache();\n+\t\t\tread_index(&the_index);\n \t\t\tthe_index.cache_nr = nr; /* cheap truncate of index */\n \t\t\tt1m = getnanotime();\n \t\t\tnr_threads_used = test_lazy_init_name_hash(&the_index, 1);\ndiff --git a/t/helper/test-read-cache.c b/t/helper/test-read-cache.c\nindex 48255eef31..b4aa339ddb 100644\n--- a/t/helper/test-read-cache.c\n+++ b/t/helper/test-read-cache.c\n@@ -7,7 +7,7 @@ int cmd_main(int argc, const char **argv)\n \t\tcnt = strtol(argv[1], NULL, 0);\n \tsetup_git_directory();\n \tfor (i = 0; i < cnt; i++) {\n-\t\tread_cache();\n+\t\tread_index(&the_index);\n \t\tdiscard_cache();\n \t}\n \treturn 0;\ndiff --git a/t/helper/test-scrap-cache-tree.c b/t/helper/test-scrap-cache-tree.c\nindex d2a63bea43..b02a679166 100644\n--- a/t/helper/test-scrap-cache-tree.c\n+++ b/t/helper/test-scrap-cache-tree.c\n@@ -9,7 +9,7 @@ int cmd_main(int ac, const char **av)\n {\n \tsetup_git_directory();\n \thold_locked_index(&index_lock, LOCK_DIE_ON_ERROR);\n-\tif (read_cache() < 0)\n+\tif (read_index(&the_index) < 0)\n \t\tdie(\"unable to read index file\");\n \tactive_cache_tree = NULL;\n \tif (write_locked_index(&the_index, &index_lock, COMMIT_LOCK))\n-- \n2.13.0.rc1.39.ga6db8bfa24\n\n"},{"id":"318572","messageId":"20170502222322.21055-4-sbeller@google.com","threadId":"45853","inReplyTo":"20170502222322.21055-1-sbeller@google.com","subject":"[PATCH 03/24] cache.h: drop read_cache_from","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-05-02T22:23:01Z","receivedAt":"2017-05-02T22:23:42Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"coccinelle patch:\n@@ expression E; @@\n-read_cache_from(E)\n+read_index_from(&the_index, E)\n\nadditionally drop the define from cache.h manually\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n apply.c          | 2 +-\n builtin/am.c     | 4 ++--\n builtin/commit.c | 6 +++---\n cache.h          | 1 -\n 4 files changed, 6 insertions(+), 7 deletions(-)\n\ndiff --git a/apply.c b/apply.c\nindex ae1b659b68..159e039a18 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -3985,7 +3985,7 @@ static int check_patch_list(struct apply_state *state, struct patch *patch)\n static int read_apply_cache(struct apply_state *state)\n {\n \tif (state->index_file)\n-\t\treturn read_cache_from(state->index_file);\n+\t\treturn read_index_from(&the_index, state->index_file);\n \telse\n \t\treturn read_index(&the_index);\n }\ndiff --git a/builtin/am.c b/builtin/am.c\nindex c6a679d8e1..cb3e4dff63 100644\n--- a/builtin/am.c\n+++ b/builtin/am.c\n@@ -1557,7 +1557,7 @@ static int run_apply(const struct am_state *state, const char *index_file)\n \tif (index_file) {\n \t\t/* Reload index as apply_all_patches() will have modified it. */\n \t\tdiscard_cache();\n-\t\tread_cache_from(index_file);\n+\t\tread_index_from(&the_index, index_file);\n \t}\n \n \treturn 0;\n@@ -1600,7 +1600,7 @@ static int fall_back_threeway(const struct am_state *state, const char *index_pa\n \t\treturn error(\"could not build fake ancestor\");\n \n \tdiscard_cache();\n-\tread_cache_from(index_path);\n+\tread_index_from(&the_index, index_path);\n \n \tif (write_index_as_tree(orig_tree.hash, &the_index, index_path, 0, NULL))\n \t\treturn error(_(\"Repository lacks necessary blobs to fall back on 3-way merge.\"));\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 01d298c836..65a04ac199 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -370,7 +370,7 @@ static const char *prepare_index(int argc, const char **argv, const char *prefix\n \t\t\tunsetenv(INDEX_ENVIRONMENT);\n \n \t\tdiscard_cache();\n-\t\tread_cache_from(get_lock_file_path(&index_lock));\n+\t\tread_index_from(&the_index, get_lock_file_path(&index_lock));\n \t\tif (update_main_cache_tree(WRITE_TREE_SILENT) == 0) {\n \t\t\tif (reopen_lock_file(&index_lock) < 0)\n \t\t\t\tdie(_(\"unable to write index file\"));\n@@ -489,7 +489,7 @@ static const char *prepare_index(int argc, const char **argv, const char *prefix\n \n \tdiscard_cache();\n \tret = get_lock_file_path(&false_lock);\n-\tread_cache_from(ret);\n+\tread_index_from(&the_index, ret);\n \treturn ret;\n }\n \n@@ -949,7 +949,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,\n \t * the editor and after we invoke run_status above.\n \t */\n \tdiscard_cache();\n-\tread_cache_from(index_file);\n+\tread_index_from(&the_index, index_file);\n \tif (update_main_cache_tree(0)) {\n \t\terror(_(\"Error building trees\"));\n \t\treturn 0;\ndiff --git a/cache.h b/cache.h\nindex 4e913d1346..6abf48dcc3 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -354,7 +354,6 @@ extern void free_name_hash(struct index_state *istate);\n \n \n #ifndef NO_THE_INDEX_COMPATIBILITY_MACROS\n-#define read_cache_from(path) read_index_from(&the_index, (path))\n #define read_cache_preload(pathspec) read_index_preload(&the_index, (pathspec))\n #define is_cache_unborn() is_index_unborn(&the_index)\n #define read_cache_unmerged() read_index_unmerged(&the_index)\n-- \n2.13.0.rc1.39.ga6db8bfa24\n\n"},{"id":"318573","messageId":"20170502222322.21055-3-sbeller@google.com","threadId":"45853","inReplyTo":"20170502222322.21055-1-sbeller@google.com","subject":"[PATCH 02/24] cache.h: drop active_* macros","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-05-02T22:23:00Z","receivedAt":"2017-05-02T22:23:50Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Based on the coccinelle patch:\n\n@@ @@\n-active_cache\n+the_index.cache\n@@ @@\n-active_nr\n+the_index.cache_nr\n@@ @@\n-active_alloc\n+the_index.cache_alloc\n@@ @@\n-active_cache_changed\n+the_index.cache_changed\n@@ @@\n-active_cache_tree\n+the_index.cache_tree\n\nAdditional manual editing:\n* drop the macros from cache.h\n* fix the whitespace issue that apply complained about in\n  builtin/checkout.c\n* builtin/commit.c had an occurrence of active_cache_tree->sha1, which\n  was not picked up with the coccinelle patch.\n* diff.c and t/t2107-update-index-basic.sh referenced\n  active_cache[_changed] in comments, fix them up.\n* ative_nr was referenced in comments in read-cache.c and\n  builtin/update-index.c, fix them.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n apply.c                          |  6 ++---\n builtin/add.c                    |  6 ++---\n builtin/am.c                     |  6 ++---\n builtin/blame.c                  |  6 ++---\n builtin/checkout-index.c         |  8 +++----\n builtin/checkout.c               | 49 ++++++++++++++++++++--------------------\n builtin/commit.c                 | 20 ++++++++--------\n builtin/fsck.c                   | 12 +++++-----\n builtin/grep.c                   |  8 +++----\n builtin/ls-files.c               | 36 ++++++++++++++---------------\n builtin/merge-index.c            | 10 ++++----\n builtin/merge.c                  | 12 +++++-----\n builtin/mv.c                     | 10 ++++----\n builtin/read-tree.c              |  2 +-\n builtin/rm.c                     | 16 ++++++-------\n builtin/submodule--helper.c      |  8 +++----\n builtin/update-index.c           | 48 ++++++++++++++++++++-------------------\n cache.h                          |  6 -----\n check-racy.c                     |  4 ++--\n diff-lib.c                       |  6 ++---\n diff.c                           |  8 +++----\n dir.c                            | 20 ++++++++--------\n merge-recursive.c                | 28 +++++++++++------------\n pathspec.c                       | 14 ++++++------\n read-cache.c                     |  2 +-\n rerere.c                         | 26 ++++++++++-----------\n revision.c                       | 18 +++++++--------\n sequencer.c                      | 19 ++++++++--------\n sha1_name.c                      | 14 ++++++------\n submodule.c                      | 12 +++++-----\n t/helper/test-dump-cache-tree.c  |  2 +-\n t/helper/test-scrap-cache-tree.c |  2 +-\n t/t2107-update-index-basic.sh    |  2 +-\n tree.c                           |  8 +++----\n wt-status.c                      | 12 +++++-----\n 35 files changed, 232 insertions(+), 234 deletions(-)\n\ndiff --git a/apply.c b/apply.c\nindex 82701d6580..ae1b659b68 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -3499,7 +3499,7 @@ static int load_current(struct apply_state *state,\n \tpos = cache_name_pos(name, strlen(name));\n \tif (pos < 0)\n \t\treturn error(_(\"%s: does not exist in index\"), name);\n-\tce = active_cache[pos];\n+\tce = the_index.cache[pos];\n \tif (lstat(name, &st)) {\n \t\tif (errno != ENOENT)\n \t\t\treturn error_errno(\"%s\", name);\n@@ -3671,7 +3671,7 @@ static int check_preimage(struct apply_state *state,\n \t\t\t\tgoto is_new;\n \t\t\treturn error(_(\"%s: does not exist in index\"), old_name);\n \t\t}\n-\t\t*ce = active_cache[pos];\n+\t\t*ce = the_index.cache[pos];\n \t\tif (stat_ret < 0) {\n \t\t\tif (checkout_target(&the_index, *ce, st))\n \t\t\t\treturn -1;\n@@ -4001,7 +4001,7 @@ static int get_current_oid(struct apply_state *state, const char *path,\n \tpos = cache_name_pos(path, strlen(path));\n \tif (pos < 0)\n \t\treturn -1;\n-\toidcpy(oid, &active_cache[pos]->oid);\n+\toidcpy(oid, &the_index.cache[pos]->oid);\n \treturn 0;\n }\n \ndiff --git a/builtin/add.c b/builtin/add.c\nindex ab6d04e8db..f6d71b10d0 100644\n--- a/builtin/add.c\n+++ b/builtin/add.c\n@@ -34,8 +34,8 @@ static void chmod_pathspec(struct pathspec *pathspec, int force_mode)\n {\n \tint i;\n \n-\tfor (i = 0; i < active_nr; i++) {\n-\t\tstruct cache_entry *ce = active_cache[i];\n+\tfor (i = 0; i < the_index.cache_nr; i++) {\n+\t\tstruct cache_entry *ce = the_index.cache[i];\n \n \t\tif (pathspec && !ce_path_match(ce, pathspec, NULL))\n \t\t\tcontinue;\n@@ -458,7 +458,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)\n \tunplug_bulk_checkin();\n \n finish:\n-\tif (active_cache_changed) {\n+\tif (the_index.cache_changed) {\n \t\tif (write_locked_index(&the_index, &lock_file, COMMIT_LOCK))\n \t\t\tdie(_(\"Unable to write new index file\"));\n \t}\ndiff --git a/builtin/am.c b/builtin/am.c\nindex 4405d7307c..c6a679d8e1 100644\n--- a/builtin/am.c\n+++ b/builtin/am.c\n@@ -1155,12 +1155,12 @@ static int index_has_changes(struct strbuf *sb)\n \t\tdiff_flush(&opt);\n \t\treturn DIFF_OPT_TST(&opt, HAS_CHANGES) != 0;\n \t} else {\n-\t\tfor (i = 0; sb && i < active_nr; i++) {\n+\t\tfor (i = 0; sb && i < the_index.cache_nr; i++) {\n \t\t\tif (i)\n \t\t\t\tstrbuf_addch(sb, ' ');\n-\t\t\tstrbuf_addstr(sb, active_cache[i]->name);\n+\t\t\tstrbuf_addstr(sb, the_index.cache[i]->name);\n \t\t}\n-\t\treturn !!active_nr;\n+\t\treturn !!the_index.cache_nr;\n \t}\n }\n \ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex 59955208fd..cbb7c1fd9d 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -2242,8 +2242,8 @@ static void verify_working_tree_path(struct commit *work_tree, const char *path)\n \tpos = cache_name_pos(path, strlen(path));\n \tif (pos >= 0)\n \t\t; /* path is in the index */\n-\telse if (-1 - pos < active_nr &&\n-\t\t !strcmp(active_cache[-1 - pos]->name, path))\n+\telse if (-1 - pos < the_index.cache_nr &&\n+\t\t !strcmp(the_index.cache[-1 - pos]->name, path))\n \t\t; /* path is in the index, unmerged */\n \telse\n \t\tdie(\"no such path '%s' in HEAD\", path);\n@@ -2401,7 +2401,7 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,\n \tif (!mode) {\n \t\tint pos = cache_name_pos(path, len);\n \t\tif (0 <= pos)\n-\t\t\tmode = active_cache[pos]->ce_mode;\n+\t\t\tmode = the_index.cache[pos]->ce_mode;\n \t\telse\n \t\t\t/* Let's not bother reading from HEAD tree */\n \t\t\tmode = S_IFREG | 0644;\ndiff --git a/builtin/checkout-index.c b/builtin/checkout-index.c\nindex 676b9419f0..1c3dcc1a8b 100644\n--- a/builtin/checkout-index.c\n+++ b/builtin/checkout-index.c\n@@ -54,8 +54,8 @@ static int checkout_file(const char *name, const char *prefix)\n \tif (pos < 0)\n \t\tpos = -pos - 1;\n \n-\twhile (pos < active_nr) {\n-\t\tstruct cache_entry *ce = active_cache[pos];\n+\twhile (pos < the_index.cache_nr) {\n+\t\tstruct cache_entry *ce = the_index.cache[pos];\n \t\tif (ce_namelen(ce) != namelen ||\n \t\t    memcmp(ce->name, name, namelen))\n \t\t\tbreak;\n@@ -95,8 +95,8 @@ static void checkout_all(const char *prefix, int prefix_length)\n \tint i, errs = 0;\n \tstruct cache_entry *last_ce = NULL;\n \n-\tfor (i = 0; i < active_nr ; i++) {\n-\t\tstruct cache_entry *ce = active_cache[i];\n+\tfor (i = 0; i < the_index.cache_nr ; i++) {\n+\t\tstruct cache_entry *ce = the_index.cache[i];\n \t\tif (ce_stage(ce) != checkout_stage\n \t\t    && (CHECKOUT_ALL != checkout_stage || !ce_stage(ce)))\n \t\t\tcontinue;\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex bfa5419f33..0aac616ad6 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -109,7 +109,7 @@ static int update_some(const unsigned char *sha1, struct strbuf *base,\n \t */\n \tpos = cache_name_pos(ce->name, ce->ce_namelen);\n \tif (pos >= 0) {\n-\t\tstruct cache_entry *old = active_cache[pos];\n+\t\tstruct cache_entry *old = the_index.cache[pos];\n \t\tif (ce->ce_mode == old->ce_mode &&\n \t\t    !oidcmp(&ce->oid, &old->oid)) {\n \t\t\told->ce_flags |= CE_UPDATE;\n@@ -135,17 +135,17 @@ static int read_tree_some(struct tree *tree, const struct pathspec *pathspec)\n \n static int skip_same_name(const struct cache_entry *ce, int pos)\n {\n-\twhile (++pos < active_nr &&\n-\t       !strcmp(active_cache[pos]->name, ce->name))\n+\twhile (++pos < the_index.cache_nr &&\n+\t       !strcmp(the_index.cache[pos]->name, ce->name))\n \t\t; /* skip */\n \treturn pos;\n }\n \n static int check_stage(int stage, const struct cache_entry *ce, int pos)\n {\n-\twhile (pos < active_nr &&\n-\t       !strcmp(active_cache[pos]->name, ce->name)) {\n-\t\tif (ce_stage(active_cache[pos]) == stage)\n+\twhile (pos < the_index.cache_nr &&\n+\t       !strcmp(the_index.cache[pos]->name, ce->name)) {\n+\t\tif (ce_stage(the_index.cache[pos]) == stage)\n \t\t\treturn 0;\n \t\tpos++;\n \t}\n@@ -160,8 +160,8 @@ static int check_stages(unsigned stages, const struct cache_entry *ce, int pos)\n \tunsigned seen = 0;\n \tconst char *name = ce->name;\n \n-\twhile (pos < active_nr) {\n-\t\tce = active_cache[pos];\n+\twhile (pos < the_index.cache_nr) {\n+\t\tce = the_index.cache[pos];\n \t\tif (strcmp(name, ce->name))\n \t\t\tbreak;\n \t\tseen |= (1 << ce_stage(ce));\n@@ -176,10 +176,11 @@ static int check_stages(unsigned stages, const struct cache_entry *ce, int pos)\n static int checkout_stage(int stage, const struct cache_entry *ce, int pos,\n \t\t\t  const struct checkout *state)\n {\n-\twhile (pos < active_nr &&\n-\t       !strcmp(active_cache[pos]->name, ce->name)) {\n-\t\tif (ce_stage(active_cache[pos]) == stage)\n-\t\t\treturn checkout_entry(active_cache[pos], state, NULL);\n+\twhile (pos < the_index.cache_nr &&\n+\t       !strcmp(the_index.cache[pos]->name, ce->name)) {\n+\t\tif (ce_stage(the_index.cache[pos]) == stage)\n+\t\t\treturn checkout_entry(the_index.cache[pos], state,\n+\t\t\t\t\t      NULL);\n \t\tpos++;\n \t}\n \tif (stage == 2)\n@@ -190,7 +191,7 @@ static int checkout_stage(int stage, const struct cache_entry *ce, int pos,\n \n static int checkout_merged(int pos, const struct checkout *state)\n {\n-\tstruct cache_entry *ce = active_cache[pos];\n+\tstruct cache_entry *ce = the_index.cache[pos];\n \tconst char *path = ce->name;\n \tmmfile_t ancestor, ours, theirs;\n \tint status;\n@@ -200,7 +201,7 @@ static int checkout_merged(int pos, const struct checkout *state)\n \tunsigned mode = 0;\n \n \tmemset(threeway, 0, sizeof(threeway));\n-\twhile (pos < active_nr) {\n+\twhile (pos < the_index.cache_nr) {\n \t\tint stage;\n \t\tstage = ce_stage(ce);\n \t\tif (!stage || strcmp(path, ce->name))\n@@ -209,7 +210,7 @@ static int checkout_merged(int pos, const struct checkout *state)\n \t\tif (stage == 2)\n \t\t\tmode = create_ce_mode(ce->ce_mode);\n \t\tpos++;\n-\t\tce = active_cache[pos];\n+\t\tce = the_index.cache[pos];\n \t}\n \tif (is_null_oid(&threeway[1]) || is_null_oid(&threeway[2]))\n \t\treturn error(_(\"path '%s' does not have necessary versions\"), path);\n@@ -306,8 +307,8 @@ static int checkout_paths(const struct checkout_opts *opts,\n \t * Make sure all pathspecs participated in locating the paths\n \t * to be checked out.\n \t */\n-\tfor (pos = 0; pos < active_nr; pos++) {\n-\t\tstruct cache_entry *ce = active_cache[pos];\n+\tfor (pos = 0; pos < the_index.cache_nr; pos++) {\n+\t\tstruct cache_entry *ce = the_index.cache[pos];\n \t\tce->ce_flags &= ~CE_MATCHED;\n \t\tif (!opts->ignore_skipworktree && ce_skip_worktree(ce))\n \t\t\tcontinue;\n@@ -349,8 +350,8 @@ static int checkout_paths(const struct checkout_opts *opts,\n \t\tunmerge_marked_index(&the_index);\n \n \t/* Any unmerged paths? */\n-\tfor (pos = 0; pos < active_nr; pos++) {\n-\t\tconst struct cache_entry *ce = active_cache[pos];\n+\tfor (pos = 0; pos < the_index.cache_nr; pos++) {\n+\t\tconst struct cache_entry *ce = the_index.cache[pos];\n \t\tif (ce->ce_flags & CE_MATCHED) {\n \t\t\tif (!ce_stage(ce))\n \t\t\t\tcontinue;\n@@ -374,8 +375,8 @@ static int checkout_paths(const struct checkout_opts *opts,\n \tstate.force = 1;\n \tstate.refresh_cache = 1;\n \tstate.istate = &the_index;\n-\tfor (pos = 0; pos < active_nr; pos++) {\n-\t\tstruct cache_entry *ce = active_cache[pos];\n+\tfor (pos = 0; pos < the_index.cache_nr; pos++) {\n+\t\tstruct cache_entry *ce = the_index.cache[pos];\n \t\tif (ce->ce_flags & CE_MATCHED) {\n \t\t\tif (!ce_stage(ce)) {\n \t\t\t\terrs |= checkout_entry(ce, &state, NULL);\n@@ -597,10 +598,10 @@ static int merge_working_tree(const struct checkout_opts *opts,\n \t\t}\n \t}\n \n-\tif (!active_cache_tree)\n-\t\tactive_cache_tree = cache_tree();\n+\tif (!the_index.cache_tree)\n+\t\tthe_index.cache_tree = cache_tree();\n \n-\tif (!cache_tree_fully_valid(active_cache_tree))\n+\tif (!cache_tree_fully_valid(the_index.cache_tree))\n \t\tcache_tree_update(&the_index, WRITE_TREE_SILENT | WRITE_TREE_REPAIR);\n \n \tif (write_locked_index(&the_index, lock_file, COMMIT_LOCK))\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 7cd08841a1..01d298c836 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -257,8 +257,8 @@ static int list_paths(struct string_list *list, const char *with_tree,\n \t\tfree(max_prefix);\n \t}\n \n-\tfor (i = 0; i < active_nr; i++) {\n-\t\tconst struct cache_entry *ce = active_cache[i];\n+\tfor (i = 0; i < the_index.cache_nr; i++) {\n+\t\tconst struct cache_entry *ce = the_index.cache[i];\n \t\tstruct string_list_item *item;\n \n \t\tif (ce->ce_flags & CE_UPDATE)\n@@ -418,10 +418,10 @@ static const char *prepare_index(int argc, const char **argv, const char *prefix\n \tif (!only && !pathspec.nr) {\n \t\thold_locked_index(&index_lock, LOCK_DIE_ON_ERROR);\n \t\trefresh_cache_or_die(refresh_flags);\n-\t\tif (active_cache_changed\n-\t\t    || !cache_tree_fully_valid(active_cache_tree))\n+\t\tif (the_index.cache_changed\n+\t\t    || !cache_tree_fully_valid(the_index.cache_tree))\n \t\t\tupdate_main_cache_tree(WRITE_TREE_SILENT);\n-\t\tif (active_cache_changed) {\n+\t\tif (the_index.cache_changed) {\n \t\t\tif (write_locked_index(&the_index, &index_lock,\n \t\t\t\t\t       COMMIT_LOCK))\n \t\t\t\tdie(_(\"unable to write new_index file\"));\n@@ -888,7 +888,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,\n \t\tstruct object_id oid;\n \t\tconst char *parent = \"HEAD\";\n \n-\t\tif (!active_nr && read_index(&the_index) < 0)\n+\t\tif (!the_index.cache_nr && read_index(&the_index) < 0)\n \t\t\tdie(_(\"Cannot read index\"));\n \n \t\tif (amend)\n@@ -897,10 +897,10 @@ static int prepare_to_commit(const char *index_file, const char *prefix,\n \t\tif (get_sha1(parent, oid.hash)) {\n \t\t\tint i, ita_nr = 0;\n \n-\t\t\tfor (i = 0; i < active_nr; i++)\n-\t\t\t\tif (ce_intent_to_add(active_cache[i]))\n+\t\t\tfor (i = 0; i < the_index.cache_nr; i++)\n+\t\t\t\tif (ce_intent_to_add(the_index.cache[i]))\n \t\t\t\t\tita_nr++;\n-\t\t\tcommitable = active_nr - ita_nr > 0;\n+\t\t\tcommitable = the_index.cache_nr - ita_nr > 0;\n \t\t} else {\n \t\t\t/*\n \t\t\t * Unless the user did explicitly request a submodule\n@@ -1758,7 +1758,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)\n \t\tappend_merge_tag_headers(parents, &tail);\n \t}\n \n-\tif (commit_tree_extended(sb.buf, sb.len, active_cache_tree->sha1,\n+\tif (commit_tree_extended(sb.buf, sb.len, the_index.cache_tree->sha1,\n \t\t\t parents, oid.hash, author_ident.buf, sign_commit, extra)) {\n \t\trollback_index_files();\n \t\tdie(_(\"failed to write commit object\"));\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex 35e03556cb..c5d6593d30 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -773,15 +773,15 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)\n \tif (keep_cache_objects) {\n \t\tverify_index_checksum = 1;\n \t\tread_index(&the_index);\n-\t\tfor (i = 0; i < active_nr; i++) {\n+\t\tfor (i = 0; i < the_index.cache_nr; i++) {\n \t\t\tunsigned int mode;\n \t\t\tstruct blob *blob;\n \t\t\tstruct object *obj;\n \n-\t\t\tmode = active_cache[i]->ce_mode;\n+\t\t\tmode = the_index.cache[i]->ce_mode;\n \t\t\tif (S_ISGITLINK(mode))\n \t\t\t\tcontinue;\n-\t\t\tblob = lookup_blob(active_cache[i]->oid.hash);\n+\t\t\tblob = lookup_blob(the_index.cache[i]->oid.hash);\n \t\t\tif (!blob)\n \t\t\t\tcontinue;\n \t\t\tobj = &blob->object;\n@@ -789,11 +789,11 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)\n \t\t\tif (name_objects)\n \t\t\t\tadd_decoration(fsck_walk_options.object_names,\n \t\t\t\t\tobj,\n-\t\t\t\t\txstrfmt(\":%s\", active_cache[i]->name));\n+\t\t\t\t\txstrfmt(\":%s\", the_index.cache[i]->name));\n \t\t\tmark_object_reachable(obj);\n \t\t}\n-\t\tif (active_cache_tree)\n-\t\t\tfsck_cache_tree(active_cache_tree);\n+\t\tif (the_index.cache_tree)\n+\t\t\tfsck_cache_tree(the_index.cache_tree);\n \t}\n \n \tcheck_connectivity();\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 5153dbf262..a1150e6f87 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -678,8 +678,8 @@ static int grep_cache(struct grep_opt *opt, const struct pathspec *pathspec,\n \n \tread_index(&the_index);\n \n-\tfor (nr = 0; nr < active_nr; nr++) {\n-\t\tconst struct cache_entry *ce = active_cache[nr];\n+\tfor (nr = 0; nr < the_index.cache_nr; nr++) {\n+\t\tconst struct cache_entry *ce = the_index.cache[nr];\n \t\tstrbuf_setlen(&name, name_base_len);\n \t\tstrbuf_addstr(&name, ce->name);\n \n@@ -711,8 +711,8 @@ static int grep_cache(struct grep_opt *opt, const struct pathspec *pathspec,\n \t\tif (ce_stage(ce)) {\n \t\t\tdo {\n \t\t\t\tnr++;\n-\t\t\t} while (nr < active_nr &&\n-\t\t\t\t !strcmp(ce->name, active_cache[nr]->name));\n+\t\t\t} while (nr < the_index.cache_nr &&\n+\t\t\t\t !strcmp(ce->name, the_index.cache[nr]->name));\n \t\t\tnr--; /* compensate for loop control */\n \t\t}\n \t\tif (hit && opt->status_only)\ndiff --git a/builtin/ls-files.c b/builtin/ls-files.c\nindex da4779ec0b..edcad6e8e1 100644\n--- a/builtin/ls-files.c\n+++ b/builtin/ls-files.c\n@@ -139,20 +139,20 @@ static void show_killed_files(struct dir_struct *dir)\n \t\t\t\t\tdie(\"BUG: killed-file %.*s not found\",\n \t\t\t\t\t\tent->len, ent->name);\n \t\t\t\tpos = -pos - 1;\n-\t\t\t\twhile (pos < active_nr &&\n-\t\t\t\t       ce_stage(active_cache[pos]))\n+\t\t\t\twhile (pos < the_index.cache_nr &&\n+\t\t\t\t       ce_stage(the_index.cache[pos]))\n \t\t\t\t\tpos++; /* skip unmerged */\n-\t\t\t\tif (active_nr <= pos)\n+\t\t\t\tif (the_index.cache_nr <= pos)\n \t\t\t\t\tbreak;\n \t\t\t\t/* pos points at a name immediately after\n \t\t\t\t * ent->name in the cache.  Does it expect\n \t\t\t\t * ent->name to be a directory?\n \t\t\t\t */\n-\t\t\t\tlen = ce_namelen(active_cache[pos]);\n+\t\t\t\tlen = ce_namelen(the_index.cache[pos]);\n \t\t\t\tif ((ent->len < len) &&\n-\t\t\t\t    !strncmp(active_cache[pos]->name,\n+\t\t\t\t    !strncmp(the_index.cache[pos]->name,\n \t\t\t\t\t     ent->name, ent->len) &&\n-\t\t\t\t    active_cache[pos]->name[ent->len] == '/')\n+\t\t\t\t    the_index.cache[pos]->name[ent->len] == '/')\n \t\t\t\t\tkilled = 1;\n \t\t\t\tbreak;\n \t\t\t}\n@@ -340,8 +340,8 @@ static void show_files(struct dir_struct *dir)\n \t\t\tshow_killed_files(dir);\n \t}\n \tif (show_cached || show_stage) {\n-\t\tfor (i = 0; i < active_nr; i++) {\n-\t\t\tconst struct cache_entry *ce = active_cache[i];\n+\t\tfor (i = 0; i < the_index.cache_nr; i++) {\n+\t\t\tconst struct cache_entry *ce = the_index.cache[i];\n \t\t\tif ((dir->flags & DIR_SHOW_IGNORED) &&\n \t\t\t    !ce_excluded(dir, ce))\n \t\t\t\tcontinue;\n@@ -354,8 +354,8 @@ static void show_files(struct dir_struct *dir)\n \t\t}\n \t}\n \tif (show_deleted || show_modified) {\n-\t\tfor (i = 0; i < active_nr; i++) {\n-\t\t\tconst struct cache_entry *ce = active_cache[i];\n+\t\tfor (i = 0; i < the_index.cache_nr; i++) {\n+\t\t\tconst struct cache_entry *ce = the_index.cache[i];\n \t\t\tstruct stat st;\n \t\t\tint err;\n \t\t\tif ((dir->flags & DIR_SHOW_IGNORED) &&\n@@ -388,19 +388,19 @@ static void prune_cache(const char *prefix, size_t prefixlen)\n \tif (pos < 0)\n \t\tpos = -pos-1;\n \tfirst = pos;\n-\tlast = active_nr;\n+\tlast = the_index.cache_nr;\n \twhile (last > first) {\n \t\tint next = (last + first) >> 1;\n-\t\tconst struct cache_entry *ce = active_cache[next];\n+\t\tconst struct cache_entry *ce = the_index.cache[next];\n \t\tif (!strncmp(ce->name, prefix, prefixlen)) {\n \t\t\tfirst = next+1;\n \t\t\tcontinue;\n \t\t}\n \t\tlast = next;\n \t}\n-\tmemmove(active_cache, active_cache + pos,\n+\tmemmove(the_index.cache, the_index.cache + pos,\n \t\t(last - pos) * sizeof(struct cache_entry *));\n-\tactive_nr = last - pos;\n+\tthe_index.cache_nr = last - pos;\n }\n \n /*\n@@ -426,8 +426,8 @@ void overlay_tree_on_cache(const char *tree_name, const char *prefix)\n \t\tdie(\"bad tree-ish %s\", tree_name);\n \n \t/* Hoist the unmerged entries up to stage #3 to make room */\n-\tfor (i = 0; i < active_nr; i++) {\n-\t\tstruct cache_entry *ce = active_cache[i];\n+\tfor (i = 0; i < the_index.cache_nr; i++) {\n+\t\tstruct cache_entry *ce = the_index.cache[i];\n \t\tif (!ce_stage(ce))\n \t\t\tcontinue;\n \t\tce->ce_flags |= CE_STAGEMASK;\n@@ -443,8 +443,8 @@ void overlay_tree_on_cache(const char *tree_name, const char *prefix)\n \tif (read_tree(tree, 1, &pathspec))\n \t\tdie(\"unable to read tree entries %s\", tree_name);\n \n-\tfor (i = 0; i < active_nr; i++) {\n-\t\tstruct cache_entry *ce = active_cache[i];\n+\tfor (i = 0; i < the_index.cache_nr; i++) {\n+\t\tstruct cache_entry *ce = the_index.cache[i];\n \t\tswitch (ce_stage(ce)) {\n \t\tcase 0:\n \t\t\tlast_stage0 = ce;\ndiff --git a/builtin/merge-index.c b/builtin/merge-index.c\nindex 51fb590dfa..d867ee73f0 100644\n--- a/builtin/merge-index.c\n+++ b/builtin/merge-index.c\n@@ -12,11 +12,11 @@ static int merge_entry(int pos, const char *path)\n \tchar hexbuf[4][GIT_MAX_HEXSZ + 1];\n \tchar ownbuf[4][60];\n \n-\tif (pos >= active_nr)\n+\tif (pos >= the_index.cache_nr)\n \t\tdie(\"git merge-index: %s not in the cache\", path);\n \tfound = 0;\n \tdo {\n-\t\tconst struct cache_entry *ce = active_cache[pos];\n+\t\tconst struct cache_entry *ce = the_index.cache[pos];\n \t\tint stage = ce_stage(ce);\n \n \t\tif (strcmp(ce->name, path))\n@@ -26,7 +26,7 @@ static int merge_entry(int pos, const char *path)\n \t\txsnprintf(ownbuf[stage], sizeof(ownbuf[stage]), \"%o\", ce->ce_mode);\n \t\targuments[stage] = hexbuf[stage];\n \t\targuments[stage + 4] = ownbuf[stage];\n-\t} while (++pos < active_nr);\n+\t} while (++pos < the_index.cache_nr);\n \tif (!found)\n \t\tdie(\"git merge-index: %s not in the cache\", path);\n \n@@ -57,8 +57,8 @@ static void merge_one_path(const char *path)\n static void merge_all(void)\n {\n \tint i;\n-\tfor (i = 0; i < active_nr; i++) {\n-\t\tconst struct cache_entry *ce = active_cache[i];\n+\tfor (i = 0; i < the_index.cache_nr; i++) {\n+\t\tconst struct cache_entry *ce = the_index.cache[i];\n \t\tif (!ce_stage(ce))\n \t\t\tcontinue;\n \t\ti += merge_entry(i, ce->name)-1;\ndiff --git a/builtin/merge.c b/builtin/merge.c\nindex 703827f006..4d4c56050c 100644\n--- a/builtin/merge.c\n+++ b/builtin/merge.c\n@@ -615,7 +615,7 @@ static int read_tree_trivial(struct object_id *common, struct object_id *head,\n \tif (!trees[nr_trees++])\n \t\treturn -1;\n \topts.fn = threeway_merge;\n-\tcache_tree_free(&active_cache_tree);\n+\tcache_tree_free(&the_index.cache_tree);\n \tfor (i = 0; i < nr_trees; i++) {\n \t\tparse_tree(trees[i]);\n \t\tinit_tree_desc(t+i, trees[i]->buffer, trees[i]->size);\n@@ -640,7 +640,7 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,\n \n \thold_locked_index(&lock, LOCK_DIE_ON_ERROR);\n \trefresh_cache(REFRESH_QUIET);\n-\tif (active_cache_changed &&\n+\tif (the_index.cache_changed &&\n \t    write_locked_index(&the_index, &lock, COMMIT_LOCK))\n \t\treturn error(_(\"Unable to write index.\"));\n \trollback_lock_file(&lock);\n@@ -680,7 +680,7 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,\n \t\t\t\tremoteheads->item, reversed, &result);\n \t\tif (clean < 0)\n \t\t\texit(128);\n-\t\tif (active_cache_changed &&\n+\t\tif (the_index.cache_changed &&\n \t\t    write_locked_index(&the_index, &lock, COMMIT_LOCK))\n \t\t\tdie (_(\"unable to write %s\"), get_index_file());\n \t\trollback_lock_file(&lock);\n@@ -703,8 +703,8 @@ static int count_unmerged_entries(void)\n {\n \tint i, ret = 0;\n \n-\tfor (i = 0; i < active_nr; i++)\n-\t\tif (ce_stage(active_cache[i]))\n+\tfor (i = 0; i < the_index.cache_nr; i++)\n+\t\tif (ce_stage(the_index.cache[i]))\n \t\t\tret++;\n \n \treturn ret;\n@@ -787,7 +787,7 @@ static int merge_trivial(struct commit *head, struct commit_list *remoteheads)\n \n \thold_locked_index(&lock, LOCK_DIE_ON_ERROR);\n \trefresh_cache(REFRESH_QUIET);\n-\tif (active_cache_changed &&\n+\tif (the_index.cache_changed &&\n \t    write_locked_index(&the_index, &lock, COMMIT_LOCK))\n \t\treturn error(_(\"Unable to write index.\"));\n \trollback_lock_file(&lock);\ndiff --git a/builtin/mv.c b/builtin/mv.c\nindex 6fd7a3a9d8..3b887a9490 100644\n--- a/builtin/mv.c\n+++ b/builtin/mv.c\n@@ -78,7 +78,7 @@ static void prepare_move_submodule(const char *src, int first,\n \t\t\t\t   const char **submodule_gitfile)\n {\n \tstruct strbuf submodule_dotgit = STRBUF_INIT;\n-\tif (!S_ISGITLINK(active_cache[first]->ce_mode))\n+\tif (!S_ISGITLINK(the_index.cache[first]->ce_mode))\n \t\tdie(_(\"Directory %s is in index and no submodule?\"), src);\n \tif (!is_staging_gitmodules_ok())\n \t\tdie(_(\"Please stage your changes to .gitmodules or stash them to proceed\"));\n@@ -102,8 +102,8 @@ static int index_range_of_same_dir(const char *src, int length,\n \t\tdie(_(\"%.*s is in index\"), len_w_slash, src_w_slash);\n \n \tfirst = -1 - first;\n-\tfor (last = first; last < active_nr; last++) {\n-\t\tconst char *path = active_cache[last]->name;\n+\tfor (last = first; last < the_index.cache_nr; last++) {\n+\t\tconst char *path = the_index.cache[last]->name;\n \t\tif (strncmp(path, src_w_slash, len_w_slash))\n \t\t\tbreak;\n \t}\n@@ -209,7 +209,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)\n \t\t\t\tdst_len = strlen(dst);\n \n \t\t\t\tfor (j = 0; j < last - first; j++) {\n-\t\t\t\t\tconst char *path = active_cache[first + j]->name;\n+\t\t\t\t\tconst char *path = the_index.cache[first + j]->name;\n \t\t\t\t\tsource[argc + j] = path;\n \t\t\t\t\tdestination[argc + j] =\n \t\t\t\t\t\tprefix_path(dst, dst_len, path + length + 1);\n@@ -293,7 +293,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)\n \tif (gitmodules_modified)\n \t\tstage_updated_gitmodules();\n \n-\tif (active_cache_changed &&\n+\tif (the_index.cache_changed &&\n \t    write_locked_index(&the_index, &lock_file, COMMIT_LOCK))\n \t\tdie(_(\"Unable to write new index file\"));\n \ndiff --git a/builtin/read-tree.c b/builtin/read-tree.c\nindex 23e212ee8c..f997814933 100644\n--- a/builtin/read-tree.c\n+++ b/builtin/read-tree.c\n@@ -251,7 +251,7 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)\n \tif (opts.debug_unpack)\n \t\topts.fn = debug_merge;\n \n-\tcache_tree_free(&active_cache_tree);\n+\tcache_tree_free(&the_index.cache_tree);\n \tfor (i = 0; i < nr_trees; i++) {\n \t\tstruct tree *tree = trees[i];\n \t\tparse_tree(tree);\ndiff --git a/builtin/rm.c b/builtin/rm.c\nindex d0eecbdaac..0813d0a853 100644\n--- a/builtin/rm.c\n+++ b/builtin/rm.c\n@@ -30,8 +30,8 @@ static int get_ours_cache_pos(const char *path, int pos)\n {\n \tint i = -pos - 1;\n \n-\twhile ((i < active_nr) && !strcmp(active_cache[i]->name, path)) {\n-\t\tif (ce_stage(active_cache[i]) == 2)\n+\twhile ((i < the_index.cache_nr) && !strcmp(the_index.cache[i]->name, path)) {\n+\t\tif (ce_stage(the_index.cache[i]) == 2)\n \t\t\treturn i;\n \t\ti++;\n \t}\n@@ -73,7 +73,7 @@ static void submodules_absorb_gitdir_if_needed(const char *prefix)\n \t\t\tif (pos < 0)\n \t\t\t\tcontinue;\n \t\t}\n-\t\tce = active_cache[pos];\n+\t\tce = the_index.cache[pos];\n \n \t\tif (!S_ISGITLINK(ce->ce_mode) ||\n \t\t    !file_exists(ce->name) ||\n@@ -122,11 +122,11 @@ static int check_local_mod(struct object_id *head, int index_only)\n \t\t\tif (pos < 0)\n \t\t\t\tcontinue;\n \n-\t\t\tif (!S_ISGITLINK(active_cache[pos]->ce_mode) ||\n+\t\t\tif (!S_ISGITLINK(the_index.cache[pos]->ce_mode) ||\n \t\t\t    is_empty_dir(name))\n \t\t\t\tcontinue;\n \t\t}\n-\t\tce = active_cache[pos];\n+\t\tce = the_index.cache[pos];\n \n \t\tif (lstat(ce->name, &st) < 0) {\n \t\t\tif (errno != ENOENT && errno != ENOTDIR)\n@@ -278,8 +278,8 @@ int cmd_rm(int argc, const char **argv, const char *prefix)\n \n \tseen = xcalloc(pathspec.nr, 1);\n \n-\tfor (i = 0; i < active_nr; i++) {\n-\t\tconst struct cache_entry *ce = active_cache[i];\n+\tfor (i = 0; i < the_index.cache_nr; i++) {\n+\t\tconst struct cache_entry *ce = the_index.cache[i];\n \t\tif (!ce_path_match(ce, &pathspec, seen))\n \t\t\tcontinue;\n \t\tALLOC_GROW(list.entry, list.nr + 1, list.alloc);\n@@ -386,7 +386,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)\n \t\t\tstage_updated_gitmodules();\n \t}\n \n-\tif (active_cache_changed) {\n+\tif (the_index.cache_changed) {\n \t\tif (write_locked_index(&the_index, &lock_file, COMMIT_LOCK))\n \t\t\tdie(_(\"Unable to write new index file\"));\n \t}\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 1281056312..822c3b3e57 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -243,8 +243,8 @@ static int module_list_compute(int argc, const char **argv,\n \tif (read_index(&the_index) < 0)\n \t\tdie(_(\"index file corrupt\"));\n \n-\tfor (i = 0; i < active_nr; i++) {\n-\t\tconst struct cache_entry *ce = active_cache[i];\n+\tfor (i = 0; i < the_index.cache_nr; i++) {\n+\t\tconst struct cache_entry *ce = the_index.cache[i];\n \n \t\tif (!match_pathspec(pathspec, ce->name, ce_namelen(ce),\n \t\t\t\t    0, ps_matched, 1) ||\n@@ -253,8 +253,8 @@ static int module_list_compute(int argc, const char **argv,\n \n \t\tALLOC_GROW(list->entries, list->nr + 1, list->alloc);\n \t\tlist->entries[list->nr++] = ce;\n-\t\twhile (i + 1 < active_nr &&\n-\t\t       !strcmp(ce->name, active_cache[i + 1]->name))\n+\t\twhile (i + 1 < the_index.cache_nr &&\n+\t\t       !strcmp(ce->name, the_index.cache[i + 1]->name))\n \t\t\t/*\n \t\t\t * Skip entries with the same name in different stages\n \t\t\t * to make sure an entry is returned only once.\ndiff --git a/builtin/update-index.c b/builtin/update-index.c\nindex 7a4b914af4..9b93e09765 100644\n--- a/builtin/update-index.c\n+++ b/builtin/update-index.c\n@@ -228,12 +228,12 @@ static int mark_ce_flags(const char *path, int flag, int mark)\n \tint pos = cache_name_pos(path, namelen);\n \tif (0 <= pos) {\n \t\tif (mark)\n-\t\t\tactive_cache[pos]->ce_flags |= flag;\n+\t\t\tthe_index.cache[pos]->ce_flags |= flag;\n \t\telse\n-\t\t\tactive_cache[pos]->ce_flags &= ~flag;\n-\t\tactive_cache[pos]->ce_flags |= CE_UPDATE_IN_BASE;\n+\t\t\tthe_index.cache[pos]->ce_flags &= ~flag;\n+\t\tthe_index.cache[pos]->ce_flags |= CE_UPDATE_IN_BASE;\n \t\tcache_tree_invalidate_path(&the_index, path);\n-\t\tactive_cache_changed |= CE_ENTRY_CHANGED;\n+\t\tthe_index.cache_changed |= CE_ENTRY_CHANGED;\n \t\treturn 0;\n \t}\n \treturn -1;\n@@ -321,7 +321,7 @@ static int process_directory(const char *path, int len, struct stat *st)\n \n \t/* Exact match: file or existing gitlink */\n \tif (pos >= 0) {\n-\t\tconst struct cache_entry *ce = active_cache[pos];\n+\t\tconst struct cache_entry *ce = the_index.cache[pos];\n \t\tif (S_ISGITLINK(ce->ce_mode)) {\n \n \t\t\t/* Do nothing to the index if there is no HEAD! */\n@@ -336,8 +336,8 @@ static int process_directory(const char *path, int len, struct stat *st)\n \n \t/* Inexact match: is there perhaps a subdirectory match? */\n \tpos = -pos-1;\n-\twhile (pos < active_nr) {\n-\t\tconst struct cache_entry *ce = active_cache[pos++];\n+\twhile (pos < the_index.cache_nr) {\n+\t\tconst struct cache_entry *ce = the_index.cache[pos++];\n \n \t\tif (strncmp(ce->name, path, len))\n \t\t\tbreak;\n@@ -369,7 +369,7 @@ static int process_path(const char *path)\n \t\treturn error(\"'%s' is beyond a symbolic link\", path);\n \n \tpos = cache_name_pos(path, len);\n-\tce = pos < 0 ? NULL : active_cache[pos];\n+\tce = pos < 0 ? NULL : the_index.cache[pos];\n \tif (ce && ce_skip_worktree(ce)) {\n \t\t/*\n \t\t * working directory version is assumed \"good\"\n@@ -431,7 +431,7 @@ static void chmod_path(char flip, const char *path)\n \tpos = cache_name_pos(path, strlen(path));\n \tif (pos < 0)\n \t\tgoto fail;\n-\tce = active_cache[pos];\n+\tce = the_index.cache[pos];\n \tif (chmod_cache_entry(ce, flip) < 0)\n \t\tgoto fail;\n \n@@ -614,8 +614,8 @@ static int unresolve_one(const char *path)\n \tif (0 <= pos) {\n \t\t/* already merged */\n \t\tpos = unmerge_cache_entry_at(pos);\n-\t\tif (pos < active_nr) {\n-\t\t\tconst struct cache_entry *ce = active_cache[pos];\n+\t\tif (pos < the_index.cache_nr) {\n+\t\t\tconst struct cache_entry *ce = the_index.cache[pos];\n \t\t\tif (ce_stage(ce) &&\n \t\t\t    ce_namelen(ce) == namelen &&\n \t\t\t    !memcmp(ce->name, path, namelen))\n@@ -628,8 +628,8 @@ static int unresolve_one(const char *path)\n \t\t * want to do anything in the former case.\n \t\t */\n \t\tpos = -pos-1;\n-\t\tif (pos < active_nr) {\n-\t\t\tconst struct cache_entry *ce = active_cache[pos];\n+\t\tif (pos < the_index.cache_nr) {\n+\t\t\tconst struct cache_entry *ce = the_index.cache[pos];\n \t\t\tif (ce_namelen(ce) == namelen &&\n \t\t\t    !memcmp(ce->name, path, namelen)) {\n \t\t\t\tfprintf(stderr,\n@@ -724,8 +724,8 @@ static int do_reupdate(int ac, const char **av,\n \t\t */\n \t\thas_head = 0;\n  redo:\n-\tfor (pos = 0; pos < active_nr; pos++) {\n-\t\tconst struct cache_entry *ce = active_cache[pos];\n+\tfor (pos = 0; pos < the_index.cache_nr; pos++) {\n+\t\tconst struct cache_entry *ce = the_index.cache[pos];\n \t\tstruct cache_entry *old = NULL;\n \t\tint save_nr;\n \t\tchar *path;\n@@ -740,16 +740,18 @@ static int do_reupdate(int ac, const char **av,\n \t\t\tfree(old);\n \t\t\tcontinue; /* unchanged */\n \t\t}\n-\t\t/* Be careful.  The working tree may not have the\n+\t\t/*\n+\t\t * Be careful.  The working tree may not have the\n \t\t * path anymore, in which case, under 'allow_remove',\n-\t\t * or worse yet 'allow_replace', active_nr may decrease.\n+\t\t * or worse yet 'allow_replace', the_index.cache_nr\n+\t\t * may decrease.\n \t\t */\n-\t\tsave_nr = active_nr;\n+\t\tsave_nr = the_index.cache_nr;\n \t\tpath = xstrdup(ce->name);\n \t\tupdate_one(path);\n \t\tfree(path);\n \t\tfree(old);\n-\t\tif (save_nr != active_nr)\n+\t\tif (save_nr != the_index.cache_nr)\n \t\t\tgoto redo;\n \t}\n \tclear_pathspec(&pathspec);\n@@ -878,7 +880,7 @@ static int unresolve_callback(struct parse_opt_ctx_t *ctx,\n \t*has_errors = do_unresolve(ctx->argc, ctx->argv,\n \t\t\t\tprefix, prefix ? strlen(prefix) : 0);\n \tif (*has_errors)\n-\t\tactive_cache_changed = 0;\n+\t\tthe_index.cache_changed = 0;\n \n \tctx->argv += ctx->argc - 1;\n \tctx->argc = 1;\n@@ -896,7 +898,7 @@ static int reupdate_callback(struct parse_opt_ctx_t *ctx,\n \t*has_errors = do_reupdate(ctx->argc, ctx->argv,\n \t\t\t\tprefix, prefix ? strlen(prefix) : 0);\n \tif (*has_errors)\n-\t\tactive_cache_changed = 0;\n+\t\tthe_index.cache_changed = 0;\n \n \tctx->argv += ctx->argc - 1;\n \tctx->argc = 1;\n@@ -1075,7 +1077,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)\n \t\t\t    INDEX_FORMAT_LB, INDEX_FORMAT_UB);\n \n \t\tif (the_index.version != preferred_index_format)\n-\t\t\tactive_cache_changed |= SOMETHING_CHANGED;\n+\t\t\tthe_index.cache_changed |= SOMETHING_CHANGED;\n \t\tthe_index.version = preferred_index_format;\n \t}\n \n@@ -1146,7 +1148,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)\n \t\tdie(\"BUG: bad untracked_cache value: %d\", untracked_cache);\n \t}\n \n-\tif (active_cache_changed) {\n+\tif (the_index.cache_changed) {\n \t\tif (newfd < 0) {\n \t\t\tif (refresh_args.flags & REFRESH_QUIET)\n \t\t\t\texit(128);\ndiff --git a/cache.h b/cache.h\nindex 9a1ea38a14..4e913d1346 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -354,12 +354,6 @@ extern void free_name_hash(struct index_state *istate);\n \n \n #ifndef NO_THE_INDEX_COMPATIBILITY_MACROS\n-#define active_cache (the_index.cache)\n-#define active_nr (the_index.cache_nr)\n-#define active_alloc (the_index.cache_alloc)\n-#define active_cache_changed (the_index.cache_changed)\n-#define active_cache_tree (the_index.cache_tree)\n-\n #define read_cache_from(path) read_index_from(&the_index, (path))\n #define read_cache_preload(pathspec) read_index_preload(&the_index, (pathspec))\n #define is_cache_unborn() is_index_unborn(&the_index)\ndiff --git a/check-racy.c b/check-racy.c\nindex f50b21cb06..6599ae84cf 100644\n--- a/check-racy.c\n+++ b/check-racy.c\n@@ -7,8 +7,8 @@ int main(int ac, char **av)\n \n \tdirty = clean = racy = 0;\n \tread_index(&the_index);\n-\tfor (i = 0; i < active_nr; i++) {\n-\t\tstruct cache_entry *ce = active_cache[i];\n+\tfor (i = 0; i < the_index.cache_nr; i++) {\n+\t\tstruct cache_entry *ce = the_index.cache[i];\n \t\tstruct stat st;\n \n \t\tif (lstat(ce->name, &st)) {\ndiff --git a/diff-lib.c b/diff-lib.c\nindex 52447466b5..de59ec0459 100644\n--- a/diff-lib.c\n+++ b/diff-lib.c\n@@ -95,10 +95,10 @@ int run_diff_files(struct rev_info *revs, unsigned int option)\n \n \tif (diff_unmerged_stage < 0)\n \t\tdiff_unmerged_stage = 2;\n-\tentries = active_nr;\n+\tentries = the_index.cache_nr;\n \tfor (i = 0; i < entries; i++) {\n \t\tunsigned int oldmode, newmode;\n-\t\tstruct cache_entry *ce = active_cache[i];\n+\t\tstruct cache_entry *ce = the_index.cache[i];\n \t\tint changed;\n \t\tunsigned dirty_submodule = 0;\n \t\tconst unsigned char *old_sha1, *new_sha1;\n@@ -142,7 +142,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)\n \t\t\tdpath->mode = wt_mode;\n \n \t\t\twhile (i < entries) {\n-\t\t\t\tstruct cache_entry *nce = active_cache[i];\n+\t\t\t\tstruct cache_entry *nce = the_index.cache[i];\n \t\t\t\tint stage;\n \n \t\t\t\tif (strcmp(ce->name, nce->name))\ndiff --git a/diff.c b/diff.c\nindex 05d0312265..37083914c5 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -2736,7 +2736,7 @@ static int reuse_worktree_file(const char *name, const unsigned char *sha1, int\n \t * by diff-cache --cached, which does read the cache before\n \t * calling us.\n \t */\n-\tif (!active_cache)\n+\tif (!the_index.cache)\n \t\treturn 0;\n \n \t/* We want to avoid the working directory if our caller\n@@ -2762,7 +2762,7 @@ static int reuse_worktree_file(const char *name, const unsigned char *sha1, int\n \tpos = cache_name_pos(name, len);\n \tif (pos < 0)\n \t\treturn 0;\n-\tce = active_cache[pos];\n+\tce = the_index.cache[pos];\n \n \t/*\n \t * This is not the sha1 we are looking for, or\n@@ -3490,10 +3490,10 @@ void diff_setup_done(struct diff_options *options)\n \tif (options->detect_rename && options->rename_limit < 0)\n \t\toptions->rename_limit = diff_rename_limit_default;\n \tif (options->setup & DIFF_SETUP_USE_CACHE) {\n-\t\tif (!active_cache)\n+\t\tif (!the_index.cache)\n \t\t\t/* read-cache does not die even when it fails\n \t\t\t * so it is safe for us to do this here.  Also\n-\t\t\t * it does not smudge active_cache or active_nr\n+\t\t\t * it does not smudge cache or nr of the_index\n \t\t\t * when it fails, so we do not have to worry about\n \t\t\t * cleaning it up ourselves either.\n \t\t\t */\ndiff --git a/dir.c b/dir.c\nindex f451bfa48c..8abad1b969 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -599,9 +599,9 @@ static void *read_skip_worktree_file_from_index(const char *path, size_t *size,\n \tpos = cache_name_pos(path, len);\n \tif (pos < 0)\n \t\treturn NULL;\n-\tif (!ce_skip_worktree(active_cache[pos]))\n+\tif (!ce_skip_worktree(the_index.cache[pos]))\n \t\treturn NULL;\n-\tdata = read_sha1_file(active_cache[pos]->oid.hash, &type, &sz);\n+\tdata = read_sha1_file(the_index.cache[pos]->oid.hash, &type, &sz);\n \tif (!data || type != OBJ_BLOB) {\n \t\tfree(data);\n \t\treturn NULL;\n@@ -609,7 +609,7 @@ static void *read_skip_worktree_file_from_index(const char *path, size_t *size,\n \t*size = xsize_t(sz);\n \tif (sha1_stat) {\n \t\tmemset(&sha1_stat->stat, 0, sizeof(sha1_stat->stat));\n-\t\thashcpy(sha1_stat->sha1, active_cache[pos]->oid.hash);\n+\t\thashcpy(sha1_stat->sha1, the_index.cache[pos]->oid.hash);\n \t}\n \treturn data;\n }\n@@ -786,11 +786,11 @@ static int add_excludes(const char *fname, const char *base, int baselen,\n \t\t\t\t; /* no content change, ss->sha1 still good */\n \t\t\telse if (check_index &&\n \t\t\t\t (pos = cache_name_pos(fname, strlen(fname))) >= 0 &&\n-\t\t\t\t !ce_stage(active_cache[pos]) &&\n-\t\t\t\t ce_uptodate(active_cache[pos]) &&\n+\t\t\t\t !ce_stage(the_index.cache[pos]) &&\n+\t\t\t\t ce_uptodate(the_index.cache[pos]) &&\n \t\t\t\t !would_convert_to_git(fname))\n \t\t\t\thashcpy(sha1_stat->sha1,\n-\t\t\t\t\tactive_cache[pos]->oid.hash);\n+\t\t\t\t\tthe_index.cache[pos]->oid.hash);\n \t\t\telse\n \t\t\t\thash_sha1_file(buf, size, \"blob\", sha1_stat->sha1);\n \t\t\tfill_stat_data(&sha1_stat->stat, &st);\n@@ -1293,8 +1293,8 @@ static enum exist_status directory_exists_in_index(const char *dirname, int len)\n \tpos = cache_name_pos(dirname, len);\n \tif (pos < 0)\n \t\tpos = -pos-1;\n-\twhile (pos < active_nr) {\n-\t\tconst struct cache_entry *ce = active_cache[pos++];\n+\twhile (pos < the_index.cache_nr) {\n+\t\tconst struct cache_entry *ce = the_index.cache[pos++];\n \t\tunsigned char endchar;\n \n \t\tif (strncmp(ce->name, dirname, len))\n@@ -1478,8 +1478,8 @@ static int get_index_dtype(const char *path, int len)\n \tif (pos >= 0)\n \t\treturn DT_UNKNOWN;\n \tpos = -pos-1;\n-\twhile (pos < active_nr) {\n-\t\tce = active_cache[pos++];\n+\twhile (pos < the_index.cache_nr) {\n+\t\tce = the_index.cache[pos++];\n \t\tif (strncmp(ce->name, path, len))\n \t\t\tbreak;\n \t\tif (ce->name[len] > '/')\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 3cfaf33faa..57ca250c88 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -275,7 +275,7 @@ static int git_merge_trees(int index_only,\n \tinit_tree_desc_from_tree(t+2, merge);\n \n \trc = unpack_trees(3, t, &opts);\n-\tcache_tree_free(&active_cache_tree);\n+\tcache_tree_free(&the_index.cache_tree);\n \treturn rc;\n }\n \n@@ -286,8 +286,8 @@ struct tree *write_tree_from_memory(struct merge_options *o)\n \tif (unmerged_cache()) {\n \t\tint i;\n \t\tfprintf(stderr, \"BUG: There are unmerged index entries:\\n\");\n-\t\tfor (i = 0; i < active_nr; i++) {\n-\t\t\tconst struct cache_entry *ce = active_cache[i];\n+\t\tfor (i = 0; i < the_index.cache_nr; i++) {\n+\t\t\tconst struct cache_entry *ce = the_index.cache[i];\n \t\t\tif (ce_stage(ce))\n \t\t\t\tfprintf(stderr, \"BUG: %d %.*s\\n\", ce_stage(ce),\n \t\t\t\t\t(int)ce_namelen(ce), ce->name);\n@@ -295,16 +295,16 @@ struct tree *write_tree_from_memory(struct merge_options *o)\n \t\tdie(\"BUG: unmerged index entries in merge-recursive.c\");\n \t}\n \n-\tif (!active_cache_tree)\n-\t\tactive_cache_tree = cache_tree();\n+\tif (!the_index.cache_tree)\n+\t\tthe_index.cache_tree = cache_tree();\n \n-\tif (!cache_tree_fully_valid(active_cache_tree) &&\n+\tif (!cache_tree_fully_valid(the_index.cache_tree) &&\n \t    cache_tree_update(&the_index, 0) < 0) {\n \t\terr(o, _(\"error building trees\"));\n \t\treturn NULL;\n \t}\n \n-\tresult = lookup_tree(active_cache_tree->sha1);\n+\tresult = lookup_tree(the_index.cache_tree->sha1);\n \n \treturn result;\n }\n@@ -370,10 +370,10 @@ static struct string_list *get_unmerged(void)\n \n \tunmerged->strdup_strings = 1;\n \n-\tfor (i = 0; i < active_nr; i++) {\n+\tfor (i = 0; i < the_index.cache_nr; i++) {\n \t\tstruct string_list_item *item;\n \t\tstruct stage_data *e;\n-\t\tconst struct cache_entry *ce = active_cache[i];\n+\t\tconst struct cache_entry *ce = the_index.cache[i];\n \t\tif (!ce_stage(ce))\n \t\t\tcontinue;\n \n@@ -683,8 +683,8 @@ static int dir_in_way(const char *path, int check_working_copy, int empty_ok)\n \n \tif (pos < 0)\n \t\tpos = -1 - pos;\n-\tif (pos < active_nr &&\n-\t    !strncmp(dirpath.buf, active_cache[pos]->name, dirpath.len)) {\n+\tif (pos < the_index.cache_nr &&\n+\t    !strncmp(dirpath.buf, the_index.cache[pos]->name, dirpath.len)) {\n \t\tstrbuf_release(&dirpath);\n \t\treturn 1;\n \t}\n@@ -709,9 +709,9 @@ static int was_tracked(const char *path)\n \t * had the path tracked (and resulted in a conflict).\n \t */\n \tfor (pos = -1 - pos;\n-\t     pos < active_nr && !strcmp(path, active_cache[pos]->name);\n+\t     pos < the_index.cache_nr && !strcmp(path, the_index.cache[pos]->name);\n \t     pos++)\n-\t\tif (ce_stage(active_cache[pos]) == 2)\n+\t\tif (ce_stage(the_index.cache[pos]) == 2)\n \t\t\treturn 1;\n \treturn 0;\n }\n@@ -2145,7 +2145,7 @@ int merge_recursive_generic(struct merge_options *o,\n \tif (clean < 0)\n \t\treturn clean;\n \n-\tif (active_cache_changed &&\n+\tif (the_index.cache_changed &&\n \t    write_locked_index(&the_index, lock, COMMIT_LOCK))\n \t\treturn err(o, _(\"Unable to write index.\"));\n \ndiff --git a/pathspec.c b/pathspec.c\nindex 50f76fff45..25c2afef30 100644\n--- a/pathspec.c\n+++ b/pathspec.c\n@@ -32,8 +32,8 @@ void add_pathspec_matches_against_index(const struct pathspec *pathspec,\n \t\t\tnum_unmatched++;\n \tif (!num_unmatched)\n \t\treturn;\n-\tfor (i = 0; i < active_nr; i++) {\n-\t\tconst struct cache_entry *ce = active_cache[i];\n+\tfor (i = 0; i < the_index.cache_nr; i++) {\n+\t\tconst struct cache_entry *ce = the_index.cache[i];\n \t\tce_path_match(ce, pathspec, seen);\n \t}\n }\n@@ -391,7 +391,7 @@ static void strip_submodule_slash_cheap(struct pathspec_item *item)\n \tif (item->len >= 1 && item->match[item->len - 1] == '/') {\n \t\tint i = cache_name_pos(item->match, item->len - 1);\n \n-\t\tif (i >= 0 && S_ISGITLINK(active_cache[i]->ce_mode)) {\n+\t\tif (i >= 0 && S_ISGITLINK(the_index.cache[i]->ce_mode)) {\n \t\t\titem->len--;\n \t\t\titem->match[item->len] = '\\0';\n \t\t}\n@@ -402,8 +402,8 @@ static void strip_submodule_slash_expensive(struct pathspec_item *item)\n {\n \tint i;\n \n-\tfor (i = 0; i < active_nr; i++) {\n-\t\tstruct cache_entry *ce = active_cache[i];\n+\tfor (i = 0; i < the_index.cache_nr; i++) {\n+\t\tstruct cache_entry *ce = the_index.cache[i];\n \t\tint ce_len = ce_namelen(ce);\n \n \t\tif (!S_ISGITLINK(ce->ce_mode))\n@@ -428,8 +428,8 @@ static void die_inside_submodule_path(struct pathspec_item *item)\n {\n \tint i;\n \n-\tfor (i = 0; i < active_nr; i++) {\n-\t\tstruct cache_entry *ce = active_cache[i];\n+\tfor (i = 0; i < the_index.cache_nr; i++) {\n+\t\tstruct cache_entry *ce = the_index.cache[i];\n \t\tint ce_len = ce_namelen(ce);\n \n \t\tif (!S_ISGITLINK(ce->ce_mode))\ndiff --git a/read-cache.c b/read-cache.c\nindex f1bdb006f4..6681376f5b 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -1791,7 +1791,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)\n \tistate->timestamp.nsec = ST_MTIME_NSEC(st);\n \n \twhile (src_offset <= mmap_size - 20 - 8) {\n-\t\t/* After an array of active_nr index entries,\n+\t\t/* After an array of the_index.cache_nr index entries,\n \t\t * there can be arbitrary number of extended\n \t\t * sections, each of which is prefixed with\n \t\t * extension name (4-byte) and section length\ndiff --git a/rerere.c b/rerere.c\nindex 770b34a5c9..b9b39a959e 100644\n--- a/rerere.c\n+++ b/rerere.c\n@@ -523,7 +523,7 @@ static int handle_file(const char *path, unsigned char *sha1, const char *output\n  */\n static int check_one_conflict(int i, int *type)\n {\n-\tconst struct cache_entry *e = active_cache[i];\n+\tconst struct cache_entry *e = the_index.cache[i];\n \n \tif (!ce_stage(e)) {\n \t\t*type = RESOLVED;\n@@ -531,13 +531,13 @@ static int check_one_conflict(int i, int *type)\n \t}\n \n \t*type = PUNTED;\n-\twhile (ce_stage(active_cache[i]) == 1)\n+\twhile (ce_stage(the_index.cache[i]) == 1)\n \t\ti++;\n \n \t/* Only handle regular files with both stages #2 and #3 */\n-\tif (i + 1 < active_nr) {\n-\t\tconst struct cache_entry *e2 = active_cache[i];\n-\t\tconst struct cache_entry *e3 = active_cache[i + 1];\n+\tif (i + 1 < the_index.cache_nr) {\n+\t\tconst struct cache_entry *e2 = the_index.cache[i];\n+\t\tconst struct cache_entry *e3 = the_index.cache[i + 1];\n \t\tif (ce_stage(e2) == 2 &&\n \t\t    ce_stage(e3) == 3 &&\n \t\t    ce_same_name(e, e3) &&\n@@ -547,7 +547,7 @@ static int check_one_conflict(int i, int *type)\n \t}\n \n \t/* Skip the entries with the same name */\n-\twhile (i < active_nr && ce_same_name(e, active_cache[i]))\n+\twhile (i < the_index.cache_nr && ce_same_name(e, the_index.cache[i]))\n \t\ti++;\n \treturn i;\n }\n@@ -569,9 +569,9 @@ static int find_conflict(struct string_list *conflict)\n \tif (read_index(&the_index) < 0)\n \t\treturn error(\"Could not read index\");\n \n-\tfor (i = 0; i < active_nr;) {\n+\tfor (i = 0; i < the_index.cache_nr;) {\n \t\tint conflict_type;\n-\t\tconst struct cache_entry *e = active_cache[i];\n+\t\tconst struct cache_entry *e = the_index.cache[i];\n \t\ti = check_one_conflict(i, &conflict_type);\n \t\tif (conflict_type == THREE_STAGED)\n \t\t\tstring_list_insert(conflict, (const char *)e->name);\n@@ -602,9 +602,9 @@ int rerere_remaining(struct string_list *merge_rr)\n \tif (read_index(&the_index) < 0)\n \t\treturn error(\"Could not read index\");\n \n-\tfor (i = 0; i < active_nr;) {\n+\tfor (i = 0; i < the_index.cache_nr;) {\n \t\tint conflict_type;\n-\t\tconst struct cache_entry *e = active_cache[i];\n+\t\tconst struct cache_entry *e = the_index.cache[i];\n \t\ti = check_one_conflict(i, &conflict_type);\n \t\tif (conflict_type == PUNTED)\n \t\t\tstring_list_insert(merge_rr, (const char *)e->name);\n@@ -718,7 +718,7 @@ static void update_paths(struct string_list *update)\n \t\t\titem->string);\n \t}\n \n-\tif (active_cache_changed) {\n+\tif (the_index.cache_changed) {\n \t\tif (write_locked_index(&the_index, &index_lock, COMMIT_LOCK))\n \t\t\tdie(\"Unable to write new index file\");\n \t} else\n@@ -971,11 +971,11 @@ static int handle_cache(const char *path, unsigned char *sha1, const char *outpu\n \t\treturn -1;\n \tpos = -pos - 1;\n \n-\twhile (pos < active_nr) {\n+\twhile (pos < the_index.cache_nr) {\n \t\tenum object_type type;\n \t\tunsigned long size;\n \n-\t\tce = active_cache[pos++];\n+\t\tce = the_index.cache[pos++];\n \t\tif (ce_namelen(ce) != len || memcmp(ce->name, path, len))\n \t\t\tbreak;\n \t\ti = ce_stage(ce) - 1;\ndiff --git a/revision.c b/revision.c\nindex bb6250ef02..57d71abdbf 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -1268,8 +1268,8 @@ void add_index_objects_to_pending(struct rev_info *revs, unsigned flags)\n \tint i;\n \n \tread_index(&the_index);\n-\tfor (i = 0; i < active_nr; i++) {\n-\t\tstruct cache_entry *ce = active_cache[i];\n+\tfor (i = 0; i < the_index.cache_nr; i++) {\n+\t\tstruct cache_entry *ce = the_index.cache[i];\n \t\tstruct blob *blob;\n \n \t\tif (S_ISGITLINK(ce->ce_mode))\n@@ -1282,9 +1282,9 @@ void add_index_objects_to_pending(struct rev_info *revs, unsigned flags)\n \t\t\t\t\t     ce->ce_mode, ce->name);\n \t}\n \n-\tif (active_cache_tree) {\n+\tif (the_index.cache_tree) {\n \t\tstruct strbuf path = STRBUF_INIT;\n-\t\tadd_cache_tree(active_cache_tree, revs, &path);\n+\t\tadd_cache_tree(the_index.cache_tree, revs, &path);\n \t\tstrbuf_release(&path);\n \t}\n }\n@@ -1407,10 +1407,10 @@ static void prepare_show_merge(struct rev_info *revs)\n \tfree_commit_list(bases);\n \thead->object.flags |= SYMMETRIC_LEFT;\n \n-\tif (!active_nr)\n+\tif (!the_index.cache_nr)\n \t\tread_index(&the_index);\n-\tfor (i = 0; i < active_nr; i++) {\n-\t\tconst struct cache_entry *ce = active_cache[i];\n+\tfor (i = 0; i < the_index.cache_nr; i++) {\n+\t\tconst struct cache_entry *ce = the_index.cache[i];\n \t\tif (!ce_stage(ce))\n \t\t\tcontinue;\n \t\tif (ce_path_match(ce, &revs->prune_data, NULL)) {\n@@ -1419,8 +1419,8 @@ static void prepare_show_merge(struct rev_info *revs)\n \t\t\tprune[prune_num-2] = ce->name;\n \t\t\tprune[prune_num-1] = NULL;\n \t\t}\n-\t\twhile ((i+1 < active_nr) &&\n-\t\t       ce_same_name(ce, active_cache[i+1]))\n+\t\twhile ((i+1 < the_index.cache_nr) &&\n+\t\t       ce_same_name(ce, the_index.cache[i+1]))\n \t\t\ti++;\n \t}\n \tclear_pathspec(&revs->prune_data);\ndiff --git a/sequencer.c b/sequencer.c\nindex b7ec4e3221..9409b65aaa 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -413,12 +413,12 @@ void append_conflicts_hint(struct strbuf *msgbuf)\n \n \tstrbuf_addch(msgbuf, '\\n');\n \tstrbuf_commented_addf(msgbuf, \"Conflicts:\\n\");\n-\tfor (i = 0; i < active_nr;) {\n-\t\tconst struct cache_entry *ce = active_cache[i++];\n+\tfor (i = 0; i < the_index.cache_nr;) {\n+\t\tconst struct cache_entry *ce = the_index.cache[i++];\n \t\tif (ce_stage(ce)) {\n \t\t\tstrbuf_commented_addf(msgbuf, \"\\t%s\\n\", ce->name);\n-\t\t\twhile (i < active_nr && !strcmp(ce->name,\n-\t\t\t\t\t\t\tactive_cache[i]->name))\n+\t\t\twhile (i < the_index.cache_nr && !strcmp(ce->name,\n+\t\t\t\t\t\t\tthe_index.cache[i]->name))\n \t\t\t\ti++;\n \t\t}\n \t}\n@@ -462,7 +462,7 @@ static int do_recursive_merge(struct commit *base, struct commit *next,\n \tif (clean < 0)\n \t\treturn clean;\n \n-\tif (active_cache_changed &&\n+\tif (the_index.cache_changed &&\n \t    write_locked_index(&the_index, &index_lock, COMMIT_LOCK))\n \t\t/* TRANSLATORS: %s will be \"revert\", \"cherry-pick\" or\n \t\t * \"rebase -i\".\n@@ -501,14 +501,15 @@ static int is_index_unchanged(void)\n \tif (parse_commit(head_commit))\n \t\treturn -1;\n \n-\tif (!active_cache_tree)\n-\t\tactive_cache_tree = cache_tree();\n+\tif (!the_index.cache_tree)\n+\t\tthe_index.cache_tree = cache_tree();\n \n-\tif (!cache_tree_fully_valid(active_cache_tree))\n+\tif (!cache_tree_fully_valid(the_index.cache_tree))\n \t\tif (cache_tree_update(&the_index, 0))\n \t\t\treturn error(_(\"unable to update cache tree\\n\"));\n \n-\treturn !hashcmp(active_cache_tree->sha1, head_commit->tree->object.oid.hash);\n+\treturn !hashcmp(the_index.cache_tree->sha1,\n+\t\t\thead_commit->tree->object.oid.hash);\n }\n \n static int write_author_script(const char *message)\ndiff --git a/sha1_name.c b/sha1_name.c\nindex 38473b1e6d..b73e261498 100644\n--- a/sha1_name.c\n+++ b/sha1_name.c\n@@ -1444,8 +1444,8 @@ static void diagnose_invalid_index_path(int stage,\n \tpos = cache_name_pos(filename, namelen);\n \tif (pos < 0)\n \t\tpos = -pos - 1;\n-\tif (pos < active_nr) {\n-\t\tce = active_cache[pos];\n+\tif (pos < the_index.cache_nr) {\n+\t\tce = the_index.cache[pos];\n \t\tif (ce_namelen(ce) == namelen &&\n \t\t    !memcmp(ce->name, filename, namelen))\n \t\t\tdie(\"Path '%s' is in the index, but not at stage %d.\\n\"\n@@ -1460,8 +1460,8 @@ static void diagnose_invalid_index_path(int stage,\n \tpos = cache_name_pos(fullname.buf, fullname.len);\n \tif (pos < 0)\n \t\tpos = -pos - 1;\n-\tif (pos < active_nr) {\n-\t\tce = active_cache[pos];\n+\tif (pos < the_index.cache_nr) {\n+\t\tce = the_index.cache[pos];\n \t\tif (ce_namelen(ce) == fullname.len &&\n \t\t    !memcmp(ce->name, fullname.buf, fullname.len))\n \t\t\tdie(\"Path '%s' is in the index, but not '%s'.\\n\"\n@@ -1551,13 +1551,13 @@ static int get_sha1_with_context_1(const char *name,\n \n \t\tstrlcpy(oc->path, cp, sizeof(oc->path));\n \n-\t\tif (!active_cache)\n+\t\tif (!the_index.cache)\n \t\t\tread_index(&the_index);\n \t\tpos = cache_name_pos(cp, namelen);\n \t\tif (pos < 0)\n \t\t\tpos = -pos - 1;\n-\t\twhile (pos < active_nr) {\n-\t\t\tce = active_cache[pos];\n+\t\twhile (pos < the_index.cache_nr) {\n+\t\t\tce = the_index.cache[pos];\n \t\t\tif (ce_namelen(ce) != namelen ||\n \t\t\t    memcmp(ce->name, cp, namelen))\n \t\t\t\tbreak;\ndiff --git a/submodule.c b/submodule.c\nindex 4d77291b11..b225ff6d1f 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -182,16 +182,16 @@ void gitmodules_config(void)\n \t\tpos = cache_name_pos(\".gitmodules\", 11);\n \t\tif (pos < 0) { /* .gitmodules not found or isn't merged */\n \t\t\tpos = -1 - pos;\n-\t\t\tif (active_nr > pos) {  /* there is a .gitmodules */\n-\t\t\t\tconst struct cache_entry *ce = active_cache[pos];\n+\t\t\tif (the_index.cache_nr > pos) {  /* there is a .gitmodules */\n+\t\t\t\tconst struct cache_entry *ce = the_index.cache[pos];\n \t\t\t\tif (ce_namelen(ce) == 11 &&\n \t\t\t\t    !memcmp(ce->name, \".gitmodules\", 11))\n \t\t\t\t\tgitmodules_is_unmerged = 1;\n \t\t\t}\n-\t\t} else if (pos < active_nr) {\n+\t\t} else if (pos < the_index.cache_nr) {\n \t\t\tstruct stat st;\n \t\t\tif (lstat(\".gitmodules\", &st) == 0 &&\n-\t\t\t    ce_match_stat(active_cache[pos], &st, 0) & DATA_CHANGED)\n+\t\t\t    ce_match_stat(the_index.cache[pos], &st, 0) & DATA_CHANGED)\n \t\t\t\tgitmodules_is_modified = 1;\n \t\t}\n \n@@ -1038,11 +1038,11 @@ static int get_next_submodule(struct child_process *cp,\n \tint ret = 0;\n \tstruct submodule_parallel_fetch *spf = data;\n \n-\tfor (; spf->count < active_nr; spf->count++) {\n+\tfor (; spf->count < the_index.cache_nr; spf->count++) {\n \t\tstruct strbuf submodule_path = STRBUF_INIT;\n \t\tstruct strbuf submodule_git_dir = STRBUF_INIT;\n \t\tstruct strbuf submodule_prefix = STRBUF_INIT;\n-\t\tconst struct cache_entry *ce = active_cache[spf->count];\n+\t\tconst struct cache_entry *ce = the_index.cache[spf->count];\n \t\tconst char *git_dir, *default_argv;\n \t\tconst struct submodule *submodule;\n \ndiff --git a/t/helper/test-dump-cache-tree.c b/t/helper/test-dump-cache-tree.c\nindex ed037a52f4..1ba09f86d6 100644\n--- a/t/helper/test-dump-cache-tree.c\n+++ b/t/helper/test-dump-cache-tree.c\n@@ -64,5 +64,5 @@ int cmd_main(int ac, const char **av)\n \tistate = the_index;\n \tistate.cache_tree = another;\n \tcache_tree_update(&istate, WRITE_TREE_DRY_RUN);\n-\treturn dump_cache_tree(active_cache_tree, another, \"\");\n+\treturn dump_cache_tree(the_index.cache_tree, another, \"\");\n }\ndiff --git a/t/helper/test-scrap-cache-tree.c b/t/helper/test-scrap-cache-tree.c\nindex b02a679166..1c640752cd 100644\n--- a/t/helper/test-scrap-cache-tree.c\n+++ b/t/helper/test-scrap-cache-tree.c\n@@ -11,7 +11,7 @@ int cmd_main(int ac, const char **av)\n \thold_locked_index(&index_lock, LOCK_DIE_ON_ERROR);\n \tif (read_index(&the_index) < 0)\n \t\tdie(\"unable to read index file\");\n-\tactive_cache_tree = NULL;\n+\tthe_index.cache_tree = NULL;\n \tif (write_locked_index(&the_index, &index_lock, COMMIT_LOCK))\n \t\tdie(\"unable to write index file\");\n \treturn 0;\ndiff --git a/t/t2107-update-index-basic.sh b/t/t2107-update-index-basic.sh\nindex 32ac6e09bd..224d509f9f 100755\n--- a/t/t2107-update-index-basic.sh\n+++ b/t/t2107-update-index-basic.sh\n@@ -74,7 +74,7 @@ test_expect_success '.lock files cleaned up' '\n \tcd repo &&\n \tgit config core.worktree ../../worktree &&\n \t# --refresh triggers late setup_work_tree,\n-\t# active_cache_changed is zero, rollback_lock_file fails\n+\t# the_index.cache_changed is zero, rollback_lock_file fails\n \tgit update-index --refresh &&\n \t! test -f .git/index.lock\n \t)\ndiff --git a/tree.c b/tree.c\nindex ce345c5511..82a6ae2a19 100644\n--- a/tree.c\n+++ b/tree.c\n@@ -164,8 +164,8 @@ int read_tree(struct tree *tree, int stage, struct pathspec *match)\n \t * do it the original slow way, otherwise, append and then\n \t * sort at the end.\n \t */\n-\tfor (i = 0; !fn && i < active_nr; i++) {\n-\t\tconst struct cache_entry *ce = active_cache[i];\n+\tfor (i = 0; !fn && i < the_index.cache_nr; i++) {\n+\t\tconst struct cache_entry *ce = the_index.cache[i];\n \t\tif (ce_stage(ce) == stage)\n \t\t\tfn = read_one_entry;\n \t}\n@@ -179,8 +179,8 @@ int read_tree(struct tree *tree, int stage, struct pathspec *match)\n \t/*\n \t * Sort the cache entry -- we need to nuke the cache tree, though.\n \t */\n-\tcache_tree_free(&active_cache_tree);\n-\tQSORT(active_cache, active_nr, cmp_cache_name_compare);\n+\tcache_tree_free(&the_index.cache_tree);\n+\tQSORT(the_index.cache, the_index.cache_nr, cmp_cache_name_compare);\n \treturn 0;\n }\n \ndiff --git a/wt-status.c b/wt-status.c\nindex 0375484962..750ed28b49 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -487,8 +487,8 @@ static int unmerged_mask(const char *path)\n \n \tmask = 0;\n \tpos = -pos-1;\n-\twhile (pos < active_nr) {\n-\t\tce = active_cache[pos++];\n+\twhile (pos < the_index.cache_nr) {\n+\t\tce = the_index.cache[pos++];\n \t\tif (strcmp(ce->name, path) || !ce_stage(ce))\n \t\t\tbreak;\n \t\tmask |= (1 << (ce_stage(ce) - 1));\n@@ -614,10 +614,10 @@ static void wt_status_collect_changes_initial(struct wt_status *s)\n {\n \tint i;\n \n-\tfor (i = 0; i < active_nr; i++) {\n+\tfor (i = 0; i < the_index.cache_nr; i++) {\n \t\tstruct string_list_item *it;\n \t\tstruct wt_status_change_data *d;\n-\t\tconst struct cache_entry *ce = active_cache[i];\n+\t\tconst struct cache_entry *ce = the_index.cache[i];\n \n \t\tif (!ce_path_match(ce, &s->pathspec, NULL))\n \t\t\tcontinue;\n@@ -2099,8 +2099,8 @@ static void wt_porcelain_v2_print_unmerged_entry(\n \tpos = cache_name_pos(it->string, strlen(it->string));\n \tassert(pos < 0);\n \tpos = -pos-1;\n-\twhile (pos < active_nr) {\n-\t\tce = active_cache[pos++];\n+\twhile (pos < the_index.cache_nr) {\n+\t\tce = the_index.cache[pos++];\n \t\tstage = ce_stage(ce);\n \t\tif (strcmp(ce->name, it->string) || !stage)\n \t\t\tbreak;\n-- \n2.13.0.rc1.39.ga6db8bfa24\n\n"},{"id":"318574","messageId":"20170502222322.21055-7-sbeller@google.com","threadId":"45853","inReplyTo":"20170502222322.21055-1-sbeller@google.com","subject":"[PATCH 06/24] unpack-trees.c: rename parameter 'the_index'","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-05-02T22:23:04Z","receivedAt":"2017-05-02T22:23:52Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"As \"the_index\" is already a global variable, we do not want to confuse\nthe local variable with the global variable.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n unpack-trees.c | 8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/unpack-trees.c b/unpack-trees.c\nindex aa15111fef..3dd8f60fc1 100644\n--- a/unpack-trees.c\n+++ b/unpack-trees.c\n@@ -1199,7 +1199,7 @@ static int clear_ce_flags(struct cache_entry **cache, int nr,\n  * Set/Clear CE_NEW_SKIP_WORKTREE according to $GIT_DIR/info/sparse-checkout\n  */\n static void mark_new_skip_worktree(struct exclude_list *el,\n-\t\t\t\t   struct index_state *the_index,\n+\t\t\t\t   struct index_state *index,\n \t\t\t\t   int select_flag, int skip_wt_flag)\n {\n \tint i;\n@@ -1208,8 +1208,8 @@ static void mark_new_skip_worktree(struct exclude_list *el,\n \t * 1. Pretend the narrowest worktree: only unmerged entries\n \t * are checked out\n \t */\n-\tfor (i = 0; i < the_index->cache_nr; i++) {\n-\t\tstruct cache_entry *ce = the_index->cache[i];\n+\tfor (i = 0; i < index->cache_nr; i++) {\n+\t\tstruct cache_entry *ce = index->cache[i];\n \n \t\tif (select_flag && !(ce->ce_flags & select_flag))\n \t\t\tcontinue;\n@@ -1224,7 +1224,7 @@ static void mark_new_skip_worktree(struct exclude_list *el,\n \t * 2. Widen worktree according to sparse-checkout file.\n \t * Matched entries will have skip_wt_flag cleared (i.e. \"in\")\n \t */\n-\tclear_ce_flags(the_index->cache, the_index->cache_nr,\n+\tclear_ce_flags(index->cache, index->cache_nr,\n \t\t       select_flag, skip_wt_flag, el);\n }\n \n-- \n2.13.0.rc1.39.ga6db8bfa24\n\n"},{"id":"318575","messageId":"20170502222322.21055-5-sbeller@google.com","threadId":"45853","inReplyTo":"20170502222322.21055-1-sbeller@google.com","subject":"[PATCH 04/24] cache.h: drop read_cache_preload(pathspec)","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-05-02T22:23:02Z","receivedAt":"2017-05-02T22:23:53Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"coccinelle patch:\n@@ expression E; @@\n-read_cache_preload(E)\n+read_index_preload(&the_index, E)\n\nAdditionally manual editing:\n* drop the define from cache.h.\n* builtin/{commit,describe}.c were not picked up as we have NULL and\n  the address of an expression. Converted them manually.\n* builtin/diff{-files,-index}.c error messages converted as well.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n builtin/checkout.c     | 4 ++--\n builtin/commit.c       | 4 ++--\n builtin/describe.c     | 2 +-\n builtin/diff-files.c   | 4 ++--\n builtin/diff-index.c   | 4 ++--\n builtin/diff.c         | 8 ++++----\n builtin/update-index.c | 2 +-\n cache.h                | 1 -\n 8 files changed, 14 insertions(+), 15 deletions(-)\n\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex 0aac616ad6..2328a475ea 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -295,7 +295,7 @@ static int checkout_paths(const struct checkout_opts *opts,\n \tlock_file = xcalloc(1, sizeof(struct lock_file));\n \n \thold_locked_index(lock_file, LOCK_DIE_ON_ERROR);\n-\tif (read_cache_preload(&opts->pathspec) < 0)\n+\tif (read_index_preload(&the_index, &opts->pathspec) < 0)\n \t\treturn error(_(\"index file corrupt\"));\n \n \tif (opts->source_tree)\n@@ -488,7 +488,7 @@ static int merge_working_tree(const struct checkout_opts *opts,\n \tstruct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));\n \n \thold_locked_index(lock_file, LOCK_DIE_ON_ERROR);\n-\tif (read_cache_preload(NULL) < 0)\n+\tif (read_index_preload(&the_index, NULL) < 0)\n \t\treturn error(_(\"index file corrupt\"));\n \n \tresolve_undo_clear();\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 65a04ac199..687e7c8a3a 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -346,7 +346,7 @@ static const char *prepare_index(int argc, const char **argv, const char *prefix\n \t\t       PATHSPEC_PREFER_FULL,\n \t\t       prefix, argv);\n \n-\tif (read_cache_preload(&pathspec) < 0)\n+\tif (read_index_preload(&the_index, &pathspec) < 0)\n \t\tdie(_(\"index file corrupt\"));\n \n \tif (interactive) {\n@@ -1377,7 +1377,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)\n \t\t       PATHSPEC_PREFER_FULL,\n \t\t       prefix, argv);\n \n-\tread_cache_preload(&s.pathspec);\n+\tread_index_preload(&the_index, &s.pathspec);\n \trefresh_index(&the_index, REFRESH_QUIET|REFRESH_UNMERGED, &s.pathspec, NULL, NULL);\n \n \tfd = hold_locked_index(&index_lock, 0);\ndiff --git a/builtin/describe.c b/builtin/describe.c\nindex a5cd8c513f..0229458ac6 100644\n--- a/builtin/describe.c\n+++ b/builtin/describe.c\n@@ -531,7 +531,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix)\n \t\t\tstatic struct lock_file index_lock;\n \t\t\tint fd;\n \n-\t\t\tread_cache_preload(NULL);\n+\t\t\tread_index_preload(&the_index, NULL);\n \t\t\trefresh_index(&the_index, REFRESH_QUIET|REFRESH_UNMERGED,\n \t\t\t\t      NULL, NULL, NULL);\n \t\t\tfd = hold_locked_index(&index_lock, 0);\ndiff --git a/builtin/diff-files.c b/builtin/diff-files.c\nindex 15c61fd8d1..d400d8c1fc 100644\n--- a/builtin/diff-files.c\n+++ b/builtin/diff-files.c\n@@ -62,8 +62,8 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix)\n \t    (rev.diffopt.output_format & DIFF_FORMAT_PATCH))\n \t\trev.combine_merges = rev.dense_combined_merges = 1;\n \n-\tif (read_cache_preload(&rev.diffopt.pathspec) < 0) {\n-\t\tperror(\"read_cache_preload\");\n+\tif (read_index_preload(&the_index, &rev.diffopt.pathspec) < 0) {\n+\t\tperror(\"read_index_preload\");\n \t\treturn -1;\n \t}\n \tresult = run_diff_files(&rev, options);\ndiff --git a/builtin/diff-index.c b/builtin/diff-index.c\nindex 49fd64d4ce..3fbe33a90a 100644\n--- a/builtin/diff-index.c\n+++ b/builtin/diff-index.c\n@@ -44,8 +44,8 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix)\n \t\tusage(diff_cache_usage);\n \tif (!cached) {\n \t\tsetup_work_tree();\n-\t\tif (read_cache_preload(&rev.diffopt.pathspec) < 0) {\n-\t\t\tperror(\"read_cache_preload\");\n+\t\tif (read_index_preload(&the_index, &rev.diffopt.pathspec) < 0) {\n+\t\t\tperror(\"read_index_preload\");\n \t\t\treturn -1;\n \t\t}\n \t} else if (read_index(&the_index) < 0) {\ndiff --git a/builtin/diff.c b/builtin/diff.c\nindex ed9edb2d0c..0ae33bce2b 100644\n--- a/builtin/diff.c\n+++ b/builtin/diff.c\n@@ -144,8 +144,8 @@ static int builtin_diff_index(struct rev_info *revs,\n \t\tusage(builtin_diff_usage);\n \tif (!cached) {\n \t\tsetup_work_tree();\n-\t\tif (read_cache_preload(&revs->diffopt.pathspec) < 0) {\n-\t\t\tperror(\"read_cache_preload\");\n+\t\tif (read_index_preload(&the_index, &revs->diffopt.pathspec) < 0) {\n+\t\t\tperror(\"read_index_preload\");\n \t\t\treturn -1;\n \t\t}\n \t} else if (read_index(&the_index) < 0) {\n@@ -246,8 +246,8 @@ static int builtin_diff_files(struct rev_info *revs, int argc, const char **argv\n \t\trevs->combine_merges = revs->dense_combined_merges = 1;\n \n \tsetup_work_tree();\n-\tif (read_cache_preload(&revs->diffopt.pathspec) < 0) {\n-\t\tperror(\"read_cache_preload\");\n+\tif (read_index_preload(&the_index, &revs->diffopt.pathspec) < 0) {\n+\t\tperror(\"read_index_preload\");\n \t\treturn -1;\n \t}\n \treturn run_diff_files(revs, options);\ndiff --git a/builtin/update-index.c b/builtin/update-index.c\nindex 9b93e09765..8667c48446 100644\n--- a/builtin/update-index.c\n+++ b/builtin/update-index.c\n@@ -766,7 +766,7 @@ struct refresh_params {\n static int refresh(struct refresh_params *o, unsigned int flag)\n {\n \tsetup_work_tree();\n-\tread_cache_preload(NULL);\n+\tread_index_preload(&the_index, NULL);\n \t*o->has_errors |= refresh_cache(o->flags | flag);\n \treturn 0;\n }\ndiff --git a/cache.h b/cache.h\nindex 6abf48dcc3..a66ae97fb7 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -354,7 +354,6 @@ extern void free_name_hash(struct index_state *istate);\n \n \n #ifndef NO_THE_INDEX_COMPATIBILITY_MACROS\n-#define read_cache_preload(pathspec) read_index_preload(&the_index, (pathspec))\n #define is_cache_unborn() is_index_unborn(&the_index)\n #define read_cache_unmerged() read_index_unmerged(&the_index)\n #define discard_cache() discard_index(&the_index)\n-- \n2.13.0.rc1.39.ga6db8bfa24\n\n"},{"id":"318576","messageId":"20170502222322.21055-8-sbeller@google.com","threadId":"45853","inReplyTo":"20170502222322.21055-1-sbeller@google.com","subject":"[PATCH 07/24] cache.h: drop read_blob_data_from_cache","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-05-02T22:23:05Z","receivedAt":"2017-05-02T22:23:55Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"This was done without cocinelle, as we only have 2 occurrences.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n cache.h   | 1 -\n convert.c | 4 ++--\n 2 files changed, 2 insertions(+), 3 deletions(-)\n\ndiff --git a/cache.h b/cache.h\nindex 9b94339573..d078e88c3f 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -374,7 +374,6 @@ extern void free_name_hash(struct index_state *istate);\n #define resolve_undo_clear() resolve_undo_clear_index(&the_index)\n #define unmerge_cache_entry_at(at) unmerge_index_entry_at(&the_index, at)\n #define unmerge_cache(pathspec) unmerge_index(&the_index, pathspec)\n-#define read_blob_data_from_cache(path, sz) read_blob_data_from_index(&the_index, (path), (sz))\n #endif\n \n enum object_type {\ndiff --git a/convert.c b/convert.c\nindex 8d652bf27c..cf29280ae1 100644\n--- a/convert.c\n+++ b/convert.c\n@@ -137,7 +137,7 @@ const char *get_cached_convert_stats_ascii(const char *path)\n {\n \tconst char *ret;\n \tunsigned long sz;\n-\tvoid *data = read_blob_data_from_cache(path, &sz);\n+\tvoid *data = read_blob_data_from_index(&the_index, path, &sz);\n \tret = gather_convert_stats_ascii(data, sz);\n \tfree(data);\n \treturn ret;\n@@ -222,7 +222,7 @@ static int has_cr_in_index(const char *path)\n \tvoid *data;\n \tint has_cr;\n \n-\tdata = read_blob_data_from_cache(path, &sz);\n+\tdata = read_blob_data_from_index(&the_index, path, &sz);\n \tif (!data)\n \t\treturn 0;\n \thas_cr = memchr(data, '\\r', sz) != NULL;\n-- \n2.13.0.rc1.39.ga6db8bfa24\n\n"},{"id":"318577","messageId":"20170502222322.21055-6-sbeller@google.com","threadId":"45853","inReplyTo":"20170502222322.21055-1-sbeller@google.com","subject":"[PATCH 05/24] cache.h: drop read_cache_unmerged()","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-05-02T22:23:03Z","receivedAt":"2017-05-02T22:23:56Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"@@ @@\n-read_cache_unmerged()\n+read_index_unmerged(&the_index)\n\nAdditionally drop the define from cache.h manually.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n builtin/am.c        | 2 +-\n builtin/merge.c     | 2 +-\n builtin/pull.c      | 2 +-\n builtin/read-tree.c | 2 +-\n builtin/reset.c     | 2 +-\n cache.h             | 1 -\n sequencer.c         | 2 +-\n 7 files changed, 6 insertions(+), 7 deletions(-)\n\ndiff --git a/builtin/am.c b/builtin/am.c\nindex cb3e4dff63..bb0927fbcc 100644\n--- a/builtin/am.c\n+++ b/builtin/am.c\n@@ -2053,7 +2053,7 @@ static int clean_index(const struct object_id *head, const struct object_id *rem\n \tif (!remote_tree)\n \t\treturn error(_(\"Could not parse object '%s'.\"), oid_to_hex(remote));\n \n-\tread_cache_unmerged();\n+\tread_index_unmerged(&the_index);\n \n \tif (fast_forward_to(head_tree, head_tree, 1))\n \t\treturn -1;\ndiff --git a/builtin/merge.c b/builtin/merge.c\nindex 4d4c56050c..c27c806ac1 100644\n--- a/builtin/merge.c\n+++ b/builtin/merge.c\n@@ -1170,7 +1170,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)\n \t\tgoto done;\n \t}\n \n-\tif (read_cache_unmerged())\n+\tif (read_index_unmerged(&the_index))\n \t\tdie_resolve_conflict(\"merge\");\n \n \tif (file_exists(git_path_merge_head())) {\ndiff --git a/builtin/pull.c b/builtin/pull.c\nindex dd1a4a94e4..42578cee05 100644\n--- a/builtin/pull.c\n+++ b/builtin/pull.c\n@@ -788,7 +788,7 @@ int cmd_pull(int argc, const char **argv, const char *prefix)\n \n \tgit_config(git_pull_config, NULL);\n \n-\tif (read_cache_unmerged())\n+\tif (read_index_unmerged(&the_index))\n \t\tdie_resolve_conflict(\"pull\");\n \n \tif (file_exists(git_path_merge_head()))\ndiff --git a/builtin/read-tree.c b/builtin/read-tree.c\nindex f997814933..0bcf021ead 100644\n--- a/builtin/read-tree.c\n+++ b/builtin/read-tree.c\n@@ -195,7 +195,7 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)\n \t */\n \n \tif (opts.reset || opts.merge || opts.prefix) {\n-\t\tif (read_cache_unmerged() && (opts.prefix || opts.merge))\n+\t\tif (read_index_unmerged(&the_index) && (opts.prefix || opts.merge))\n \t\t\tdie(\"You need to resolve your current index first\");\n \t\tstage = opts.merge = 1;\n \t}\ndiff --git a/builtin/reset.c b/builtin/reset.c\nindex 03c5498d6e..4a4eb723dd 100644\n--- a/builtin/reset.c\n+++ b/builtin/reset.c\n@@ -66,7 +66,7 @@ static int reset_index(const struct object_id *oid, int reset_type, int quiet)\n \t\topts.reset = 1;\n \t}\n \n-\tread_cache_unmerged();\n+\tread_index_unmerged(&the_index);\n \n \tif (reset_type == KEEP) {\n \t\tstruct object_id head_oid;\ndiff --git a/cache.h b/cache.h\nindex a66ae97fb7..9b94339573 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -355,7 +355,6 @@ extern void free_name_hash(struct index_state *istate);\n \n #ifndef NO_THE_INDEX_COMPATIBILITY_MACROS\n #define is_cache_unborn() is_index_unborn(&the_index)\n-#define read_cache_unmerged() read_index_unmerged(&the_index)\n #define discard_cache() discard_index(&the_index)\n #define unmerged_cache() unmerged_index(&the_index)\n #define cache_name_pos(name, namelen) index_name_pos(&the_index,(name),(namelen))\ndiff --git a/sequencer.c b/sequencer.c\nindex 9409b65aaa..f20e05fe60 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -349,7 +349,7 @@ static struct tree *empty_tree(void)\n \n static int error_dirty_index(struct replay_opts *opts)\n {\n-\tif (read_cache_unmerged())\n+\tif (read_index_unmerged(&the_index))\n \t\treturn error_resolve_conflict(_(action_name(opts)));\n \n \terror(_(\"your local changes would be overwritten by %s.\"),\n-- \n2.13.0.rc1.39.ga6db8bfa24\n\n"},{"id":"318578","messageId":"20170502222322.21055-11-sbeller@google.com","threadId":"45853","inReplyTo":"20170502222322.21055-1-sbeller@google.com","subject":"[PATCH 10/24] cache.h: drop cache_name_is_other","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-05-02T22:23:08Z","receivedAt":"2017-05-02T22:23:58Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Signed-off-by: Stefan Beller <sbeller@google.com>\n---\n builtin/clean.c    | 2 +-\n builtin/ls-files.c | 2 +-\n cache.h            | 1 -\n dir.c              | 2 +-\n wt-status.c        | 4 ++--\n 5 files changed, 5 insertions(+), 6 deletions(-)\n\ndiff --git a/builtin/clean.c b/builtin/clean.c\nindex 9bdefca6dc..c6aacbb0f0 100644\n--- a/builtin/clean.c\n+++ b/builtin/clean.c\n@@ -938,7 +938,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix)\n \t\tstruct stat st;\n \t\tconst char *rel;\n \n-\t\tif (!cache_name_is_other(ent->name, ent->len))\n+\t\tif (!index_name_is_other(&the_index, ent->name, ent->len))\n \t\t\tcontinue;\n \n \t\tif (pathspec.nr)\ndiff --git a/builtin/ls-files.c b/builtin/ls-files.c\nindex edcad6e8e1..6f7ecec1b0 100644\n--- a/builtin/ls-files.c\n+++ b/builtin/ls-files.c\n@@ -114,7 +114,7 @@ static void show_other_files(struct dir_struct *dir)\n \n \tfor (i = 0; i < dir->nr; i++) {\n \t\tstruct dir_entry *ent = dir->entries[i];\n-\t\tif (!cache_name_is_other(ent->name, ent->len))\n+\t\tif (!index_name_is_other(&the_index, ent->name, ent->len))\n \t\t\tcontinue;\n \t\tshow_dir_entry(tag_other, ent);\n \t}\ndiff --git a/cache.h b/cache.h\nindex abf1474034..5de8ab4e69 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -370,7 +370,6 @@ extern void free_name_hash(struct index_state *istate);\n #define ce_modified(ce, st, options) ie_modified(&the_index, (ce), (st), (options))\n #define cache_dir_exists(name, namelen) index_dir_exists(&the_index, (name), (namelen))\n #define cache_file_exists(name, namelen, igncase) index_file_exists(&the_index, (name), (namelen), (igncase))\n-#define cache_name_is_other(name, namelen) index_name_is_other(&the_index, (name), (namelen))\n #endif\n \n enum object_type {\ndiff --git a/dir.c b/dir.c\nindex 8abad1b969..d5e1c462bb 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -1244,7 +1244,7 @@ static struct dir_entry *dir_add_name(struct dir_struct *dir, const char *pathna\n \n struct dir_entry *dir_add_ignored(struct dir_struct *dir, const char *pathname, int len)\n {\n-\tif (!cache_name_is_other(pathname, len))\n+\tif (!index_name_is_other(&the_index, pathname, len))\n \t\treturn NULL;\n \n \tALLOC_GROW(dir->ignored, dir->ignored_nr+1, dir->ignored_alloc);\ndiff --git a/wt-status.c b/wt-status.c\nindex 750ed28b49..ff0e70a25a 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -669,7 +669,7 @@ static void wt_status_collect_untracked(struct wt_status *s)\n \n \tfor (i = 0; i < dir.nr; i++) {\n \t\tstruct dir_entry *ent = dir.entries[i];\n-\t\tif (cache_name_is_other(ent->name, ent->len) &&\n+\t\tif (index_name_is_other(&the_index, ent->name, ent->len) &&\n \t\t    dir_path_match(ent, &s->pathspec, 0, NULL))\n \t\t\tstring_list_insert(&s->untracked, ent->name);\n \t\tfree(ent);\n@@ -677,7 +677,7 @@ static void wt_status_collect_untracked(struct wt_status *s)\n \n \tfor (i = 0; i < dir.ignored_nr; i++) {\n \t\tstruct dir_entry *ent = dir.ignored[i];\n-\t\tif (cache_name_is_other(ent->name, ent->len) &&\n+\t\tif (index_name_is_other(&the_index, ent->name, ent->len) &&\n \t\t    dir_path_match(ent, &s->pathspec, 0, NULL))\n \t\t\tstring_list_insert(&s->ignored, ent->name);\n \t\tfree(ent);\n-- \n2.13.0.rc1.39.ga6db8bfa24\n\n"},{"id":"318579","messageId":"20170502222322.21055-13-sbeller@google.com","threadId":"45853","inReplyTo":"20170502222322.21055-1-sbeller@google.com","subject":"[PATCH 12/24] cache.h: drop cache_dir_exists","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-05-02T22:23:10Z","receivedAt":"2017-05-02T22:24:03Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Signed-off-by: Stefan Beller <sbeller@google.com>\n---\n cache.h | 1 -\n dir.c   | 2 +-\n 2 files changed, 1 insertion(+), 2 deletions(-)\n\ndiff --git a/cache.h b/cache.h\nindex 85a85f8b96..4b8e8c31fe 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -368,7 +368,6 @@ extern void free_name_hash(struct index_state *istate);\n #define refresh_cache(flags) refresh_index(&the_index, (flags), NULL, NULL, NULL)\n #define ce_match_stat(ce, st, options) ie_match_stat(&the_index, (ce), (st), (options))\n #define ce_modified(ce, st, options) ie_modified(&the_index, (ce), (st), (options))\n-#define cache_dir_exists(name, namelen) index_dir_exists(&the_index, (name), (namelen))\n #endif\n \n enum object_type {\ndiff --git a/dir.c b/dir.c\nindex 0327832e53..63edaec2ef 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -1266,7 +1266,7 @@ static enum exist_status directory_exists_in_index_icase(const char *dirname, in\n {\n \tstruct cache_entry *ce;\n \n-\tif (cache_dir_exists(dirname, len))\n+\tif (index_dir_exists(&the_index, dirname, len))\n \t\treturn index_directory;\n \n \tce = index_file_exists(&the_index, dirname, len, ignore_case);\n-- \n2.13.0.rc1.39.ga6db8bfa24\n\n"},{"id":"318580","messageId":"20170502222322.21055-12-sbeller@google.com","threadId":"45853","inReplyTo":"20170502222322.21055-1-sbeller@google.com","subject":"[PATCH 11/24] cache.h: drop cache_file_exists","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-05-02T22:23:09Z","receivedAt":"2017-05-02T22:24:05Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Signed-off-by: Stefan Beller <sbeller@google.com>\n---\n apply.c           | 2 +-\n cache.h           | 1 -\n dir.c             | 9 +++++----\n merge-recursive.c | 3 ++-\n 4 files changed, 8 insertions(+), 7 deletions(-)\n\ndiff --git a/apply.c b/apply.c\nindex 159e039a18..eb8eaeabec 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -3810,7 +3810,7 @@ static int path_is_beyond_symlink_1(struct apply_state *state, struct strbuf *na\n \t\tif (state->check_index) {\n \t\t\tstruct cache_entry *ce;\n \n-\t\t\tce = cache_file_exists(name->buf, name->len, ignore_case);\n+\t\t\tce = index_file_exists(&the_index, name->buf, name->len, ignore_case);\n \t\t\tif (ce && S_ISLNK(ce->ce_mode))\n \t\t\t\treturn 1;\n \t\t} else {\ndiff --git a/cache.h b/cache.h\nindex 5de8ab4e69..85a85f8b96 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -369,7 +369,6 @@ extern void free_name_hash(struct index_state *istate);\n #define ce_match_stat(ce, st, options) ie_match_stat(&the_index, (ce), (st), (options))\n #define ce_modified(ce, st, options) ie_modified(&the_index, (ce), (st), (options))\n #define cache_dir_exists(name, namelen) index_dir_exists(&the_index, (name), (namelen))\n-#define cache_file_exists(name, namelen, igncase) index_file_exists(&the_index, (name), (namelen), (igncase))\n #endif\n \n enum object_type {\ndiff --git a/dir.c b/dir.c\nindex d5e1c462bb..0327832e53 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -1235,7 +1235,7 @@ static struct dir_entry *dir_entry_new(const char *pathname, int len)\n \n static struct dir_entry *dir_add_name(struct dir_struct *dir, const char *pathname, int len)\n {\n-\tif (cache_file_exists(pathname, len, ignore_case))\n+\tif (index_file_exists(&the_index, pathname, len, ignore_case))\n \t\treturn NULL;\n \n \tALLOC_GROW(dir->entries, dir->nr+1, dir->alloc);\n@@ -1269,7 +1269,7 @@ static enum exist_status directory_exists_in_index_icase(const char *dirname, in\n \tif (cache_dir_exists(dirname, len))\n \t\treturn index_directory;\n \n-\tce = cache_file_exists(dirname, len, ignore_case);\n+\tce = index_file_exists(&the_index, dirname, len, ignore_case);\n \tif (ce && S_ISGITLINK(ce->ce_mode))\n \t\treturn index_gitdir;\n \n@@ -1460,7 +1460,7 @@ static int get_index_dtype(const char *path, int len)\n \tint pos;\n \tconst struct cache_entry *ce;\n \n-\tce = cache_file_exists(path, len, 0);\n+\tce = index_file_exists(&the_index, path, len, 0);\n \tif (ce) {\n \t\tif (!ce_uptodate(ce))\n \t\t\treturn DT_UNKNOWN;\n@@ -1522,7 +1522,8 @@ static enum path_treatment treat_one_path(struct dir_struct *dir,\n \t\t\t\t\t  int dtype, struct dirent *de)\n {\n \tint exclude;\n-\tint has_path_in_index = !!cache_file_exists(path->buf, path->len, ignore_case);\n+\tint has_path_in_index = !!index_file_exists(&the_index, path->buf,\n+\t\t\t\t\t\t    path->len, ignore_case);\n \n \tif (dtype == DT_UNKNOWN)\n \t\tdtype = get_dtype(de, path->buf, path->len);\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 57ca250c88..b8b3a153f1 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -623,7 +623,8 @@ static int remove_file(struct merge_options *o, int clean,\n \tif (update_working_directory) {\n \t\tif (ignore_case) {\n \t\t\tstruct cache_entry *ce;\n-\t\t\tce = cache_file_exists(path, strlen(path), ignore_case);\n+\t\t\tce = index_file_exists(&the_index, path,\n+\t\t\t\t\t       strlen(path), ignore_case);\n \t\t\tif (ce && ce_stage(ce) == 0)\n \t\t\t\treturn 0;\n \t\t}\n-- \n2.13.0.rc1.39.ga6db8bfa24\n\n"},{"id":"318581","messageId":"20170502222322.21055-14-sbeller@google.com","threadId":"45853","inReplyTo":"20170502222322.21055-1-sbeller@google.com","subject":"[PATCH 13/24] cache.h: drop is_cache_unborn(), discard_cache(), unmerged_cache()","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-05-02T22:23:11Z","receivedAt":"2017-05-02T22:24:08Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"cocci semantic patch:\n@@ @@\n-is_cache_unborn()\n+is_index_unborn(&the_index)\n@@ @@\n-discard_cache()\n+discard_index(&the_index)\n@@ @@\n-unmerged_cache()\n+unmerged_index(&the_index)\n\nAdditionally the defines in cache.h were removed manually.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n builtin/am.c                        |  8 ++++----\n builtin/blame.c                     |  2 +-\n builtin/checkout.c                  |  4 ++--\n builtin/commit.c                    | 10 +++++-----\n builtin/diff.c                      |  2 +-\n builtin/pull.c                      |  2 +-\n builtin/read-tree.c                 |  2 +-\n builtin/reset.c                     |  2 +-\n cache.h                             |  3 ---\n merge-recursive.c                   |  8 ++++----\n merge.c                             |  2 +-\n sequencer.c                         |  4 ++--\n t/helper/test-lazy-init-name-hash.c | 10 +++++-----\n t/helper/test-read-cache.c          |  2 +-\n wt-status.c                         |  2 +-\n 15 files changed, 30 insertions(+), 33 deletions(-)\n\ndiff --git a/builtin/am.c b/builtin/am.c\nindex bb0927fbcc..38fc4566f7 100644\n--- a/builtin/am.c\n+++ b/builtin/am.c\n@@ -1556,7 +1556,7 @@ static int run_apply(const struct am_state *state, const char *index_file)\n \n \tif (index_file) {\n \t\t/* Reload index as apply_all_patches() will have modified it. */\n-\t\tdiscard_cache();\n+\t\tdiscard_index(&the_index);\n \t\tread_index_from(&the_index, index_file);\n \t}\n \n@@ -1599,7 +1599,7 @@ static int fall_back_threeway(const struct am_state *state, const char *index_pa\n \tif (build_fake_ancestor(state, index_path))\n \t\treturn error(\"could not build fake ancestor\");\n \n-\tdiscard_cache();\n+\tdiscard_index(&the_index);\n \tread_index_from(&the_index, index_path);\n \n \tif (write_index_as_tree(orig_tree.hash, &the_index, index_path, 0, NULL))\n@@ -1632,7 +1632,7 @@ static int fall_back_threeway(const struct am_state *state, const char *index_pa\n \n \tsay(state, stdout, _(\"Falling back to patching base and 3-way merge...\"));\n \n-\tdiscard_cache();\n+\tdiscard_index(&the_index);\n \tread_index(&the_index);\n \n \t/*\n@@ -1938,7 +1938,7 @@ static void am_resolve(struct am_state *state)\n \t\tdie_user_resolve(state);\n \t}\n \n-\tif (unmerged_cache()) {\n+\tif (unmerged_index(&the_index)) {\n \t\tprintf_ln(_(\"You still have unmerged paths in your index.\\n\"\n \t\t\t\"Did you forget to use 'git add'?\"));\n \t\tdie_user_resolve(state);\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex cbb7c1fd9d..b47aae25d4 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -2394,7 +2394,7 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,\n \t * bits; we are not going to write this index out -- we just\n \t * want to run \"diff-index --cached\".\n \t */\n-\tdiscard_cache();\n+\tdiscard_index(&the_index);\n \tread_index(&the_index);\n \n \tlen = strlen(path);\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex abcc45a74f..a6cd8c0f37 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -510,13 +510,13 @@ static int merge_working_tree(const struct checkout_opts *opts,\n \n \t\trefresh_cache(REFRESH_QUIET);\n \n-\t\tif (unmerged_cache()) {\n+\t\tif (unmerged_index(&the_index)) {\n \t\t\terror(_(\"you need to resolve your current index first\"));\n \t\t\treturn 1;\n \t\t}\n \n \t\t/* 2-way merge to the new branch */\n-\t\ttopts.initial_checkout = is_cache_unborn();\n+\t\ttopts.initial_checkout = is_index_unborn(&the_index);\n \t\ttopts.update = 1;\n \t\ttopts.merge = 1;\n \t\ttopts.gently = opts->merge && old->commit;\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 687e7c8a3a..ef12ea3991 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -301,7 +301,7 @@ static void create_base_index(const struct commit *current_head)\n \tstruct tree_desc t;\n \n \tif (!current_head) {\n-\t\tdiscard_cache();\n+\t\tdiscard_index(&the_index);\n \t\treturn;\n \t}\n \n@@ -369,7 +369,7 @@ static const char *prepare_index(int argc, const char **argv, const char *prefix\n \t\telse\n \t\t\tunsetenv(INDEX_ENVIRONMENT);\n \n-\t\tdiscard_cache();\n+\t\tdiscard_index(&the_index);\n \t\tread_index_from(&the_index, get_lock_file_path(&index_lock));\n \t\tif (update_main_cache_tree(WRITE_TREE_SILENT) == 0) {\n \t\t\tif (reopen_lock_file(&index_lock) < 0)\n@@ -464,7 +464,7 @@ static const char *prepare_index(int argc, const char **argv, const char *prefix\n \tif (list_paths(&partial, !current_head ? NULL : \"HEAD\", prefix, &pathspec))\n \t\texit(1);\n \n-\tdiscard_cache();\n+\tdiscard_index(&the_index);\n \tif (read_index(&the_index) < 0)\n \t\tdie(_(\"cannot read the index\"));\n \n@@ -487,7 +487,7 @@ static const char *prepare_index(int argc, const char **argv, const char *prefix\n \tif (write_locked_index(&the_index, &false_lock, CLOSE_LOCK))\n \t\tdie(_(\"unable to write temporary index file\"));\n \n-\tdiscard_cache();\n+\tdiscard_index(&the_index);\n \tret = get_lock_file_path(&false_lock);\n \tread_index_from(&the_index, ret);\n \treturn ret;\n@@ -948,7 +948,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,\n \t * and write it out as a tree.  We must do this before we invoke\n \t * the editor and after we invoke run_status above.\n \t */\n-\tdiscard_cache();\n+\tdiscard_index(&the_index);\n \tread_index_from(&the_index, index_file);\n \tif (update_main_cache_tree(0)) {\n \t\terror(_(\"Error building trees\"));\ndiff --git a/builtin/diff.c b/builtin/diff.c\nindex 0ae33bce2b..1efd0d6b61 100644\n--- a/builtin/diff.c\n+++ b/builtin/diff.c\n@@ -209,7 +209,7 @@ static void refresh_index_quietly(void)\n \tfd = hold_locked_index(lock_file, 0);\n \tif (fd < 0)\n \t\treturn;\n-\tdiscard_cache();\n+\tdiscard_index(&the_index);\n \tread_index(&the_index);\n \trefresh_cache(REFRESH_QUIET|REFRESH_UNMERGED);\n \tupdate_index_if_able(&the_index, lock_file);\ndiff --git a/builtin/pull.c b/builtin/pull.c\nindex 42578cee05..57f9833367 100644\n--- a/builtin/pull.c\n+++ b/builtin/pull.c\n@@ -805,7 +805,7 @@ int cmd_pull(int argc, const char **argv, const char *prefix)\n \t\tif (opt_autostash != -1)\n \t\t\tautostash = opt_autostash;\n \n-\t\tif (is_null_oid(&orig_head) && !is_cache_unborn())\n+\t\tif (is_null_oid(&orig_head) && !is_index_unborn(&the_index))\n \t\t\tdie(_(\"Updating an unborn branch with changes added to the index.\"));\n \n \t\tif (!autostash)\ndiff --git a/builtin/read-tree.c b/builtin/read-tree.c\nindex 61f5f6f028..2b8f0a0b3a 100644\n--- a/builtin/read-tree.c\n+++ b/builtin/read-tree.c\n@@ -234,7 +234,7 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)\n \t\t\tbreak;\n \t\tcase 2:\n \t\t\topts.fn = twoway_merge;\n-\t\t\topts.initial_checkout = is_cache_unborn();\n+\t\t\topts.initial_checkout = is_index_unborn(&the_index);\n \t\t\tbreak;\n \t\tcase 3:\n \t\tdefault:\ndiff --git a/builtin/reset.c b/builtin/reset.c\nindex 4a4eb723dd..f8073b1caa 100644\n--- a/builtin/reset.c\n+++ b/builtin/reset.c\n@@ -179,7 +179,7 @@ static void set_reflog_message(struct strbuf *sb, const char *action,\n \n static void die_if_unmerged_cache(int reset_type)\n {\n-\tif (is_merge() || unmerged_cache())\n+\tif (is_merge() || unmerged_index(&the_index))\n \t\tdie(_(\"Cannot do a %s reset in the middle of a merge.\"),\n \t\t    _(reset_type_names[reset_type]));\n \ndiff --git a/cache.h b/cache.h\nindex 4b8e8c31fe..a021d6e988 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -354,9 +354,6 @@ extern void free_name_hash(struct index_state *istate);\n \n \n #ifndef NO_THE_INDEX_COMPATIBILITY_MACROS\n-#define is_cache_unborn() is_index_unborn(&the_index)\n-#define discard_cache() discard_index(&the_index)\n-#define unmerged_cache() unmerged_index(&the_index)\n #define cache_name_pos(name, namelen) index_name_pos(&the_index,(name),(namelen))\n #define add_cache_entry(ce, option) add_index_entry(&the_index, (ce), (option))\n #define rename_cache_entry_at(pos, new_name) rename_index_entry_at(&the_index, (pos), (new_name))\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex b8b3a153f1..eb0f0c6960 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -283,7 +283,7 @@ struct tree *write_tree_from_memory(struct merge_options *o)\n {\n \tstruct tree *result = NULL;\n \n-\tif (unmerged_cache()) {\n+\tif (unmerged_index(&the_index)) {\n \t\tint i;\n \t\tfprintf(stderr, \"BUG: There are unmerged index entries:\\n\");\n \t\tfor (i = 0; i < the_index.cache_nr; i++) {\n@@ -1942,7 +1942,7 @@ int merge_trees(struct merge_options *o,\n \t\treturn -1;\n \t}\n \n-\tif (unmerged_cache()) {\n+\tif (unmerged_index(&the_index)) {\n \t\tstruct string_list *entries, *re_head, *re_merge;\n \t\tint i;\n \t\tstring_list_clear(&o->current_file_set, 1);\n@@ -2058,7 +2058,7 @@ int merge_recursive(struct merge_options *o,\n \t\t * overwritten it: the committed \"conflicts\" were\n \t\t * already resolved.\n \t\t */\n-\t\tdiscard_cache();\n+\t\tdiscard_index(&the_index);\n \t\tsaved_b1 = o->branch1;\n \t\tsaved_b2 = o->branch2;\n \t\to->branch1 = \"Temporary merge branch 1\";\n@@ -2074,7 +2074,7 @@ int merge_recursive(struct merge_options *o,\n \t\t\treturn err(o, _(\"merge returned no commit\"));\n \t}\n \n-\tdiscard_cache();\n+\tdiscard_index(&the_index);\n \tif (!o->call_depth)\n \t\tread_index(&the_index);\n \ndiff --git a/merge.c b/merge.c\nindex 06509a6df2..e1f93e9714 100644\n--- a/merge.c\n+++ b/merge.c\n@@ -36,7 +36,7 @@ int try_merge_command(const char *strategy, size_t xopts_nr,\n \tret = run_command_v_opt(args.argv, RUN_GIT_CMD);\n \targv_array_clear(&args);\n \n-\tdiscard_cache();\n+\tdiscard_index(&the_index);\n \tif (read_index(&the_index) < 0)\n \t\tdie(_(\"failed to read the cache\"));\n \tresolve_undo_clear_index(&the_index);\ndiff --git a/sequencer.c b/sequencer.c\nindex f20e05fe60..274eda243a 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -958,7 +958,7 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,\n \t\tif (index_differs_from(unborn ? EMPTY_TREE_SHA1_HEX : \"HEAD\", 0, 0))\n \t\t\treturn error_dirty_index(opts);\n \t}\n-\tdiscard_cache();\n+\tdiscard_index(&the_index);\n \n \tif (!commit->parents)\n \t\tparent = NULL;\n@@ -1845,7 +1845,7 @@ static int do_exec(const char *command_line)\n \tstatus = run_command_v_opt(child_argv, RUN_USING_SHELL);\n \n \t/* force re-reading of the cache */\n-\tif (discard_cache() < 0 || read_index(&the_index) < 0)\n+\tif (discard_index(&the_index) < 0 || read_index(&the_index) < 0)\n \t\treturn error(_(\"could not read index\"));\n \n \tdirty = require_clean_work_tree(\"rebase\", NULL, 1, 1);\ndiff --git a/t/helper/test-lazy-init-name-hash.c b/t/helper/test-lazy-init-name-hash.c\nindex bd747dcbcd..5512c97647 100644\n--- a/t/helper/test-lazy-init-name-hash.c\n+++ b/t/helper/test-lazy-init-name-hash.c\n@@ -52,7 +52,7 @@ static void dump_run(void)\n \t\tce = hashmap_iter_next(&iter_cache);\n \t}\n \n-\tdiscard_cache();\n+\tdiscard_index(&the_index);\n }\n \n /*\n@@ -92,7 +92,7 @@ static uint64_t time_runs(int try_threaded)\n \t\t\t\t   the_index.cache_nr);\n \t\tfflush(stdout);\n \n-\t\tdiscard_cache();\n+\t\tdiscard_index(&the_index);\n \t}\n \n \tavg = sum / count;\n@@ -118,7 +118,7 @@ static void analyze_run(void)\n \n \tread_index(&the_index);\n \tcache_nr_limit = the_index.cache_nr;\n-\tdiscard_cache();\n+\tdiscard_index(&the_index);\n \n \tnr = analyze;\n \twhile (1) {\n@@ -138,7 +138,7 @@ static void analyze_run(void)\n \t\t\tt2s = getnanotime();\n \t\t\tsum_single += (t2s - t1s);\n \t\t\tthe_index.cache_nr = cache_nr_limit;\n-\t\t\tdiscard_cache();\n+\t\t\tdiscard_index(&the_index);\n \n \t\t\tread_index(&the_index);\n \t\t\tthe_index.cache_nr = nr; /* cheap truncate of index */\n@@ -147,7 +147,7 @@ static void analyze_run(void)\n \t\t\tt2m = getnanotime();\n \t\t\tsum_multi += (t2m - t1m);\n \t\t\tthe_index.cache_nr = cache_nr_limit;\n-\t\t\tdiscard_cache();\n+\t\t\tdiscard_index(&the_index);\n \n \t\t\tif (!nr_threads_used)\n \t\t\t\tprintf(\"    [size %8d] [single %f]   non-threaded code path used\\n\",\ndiff --git a/t/helper/test-read-cache.c b/t/helper/test-read-cache.c\nindex b4aa339ddb..084778c52f 100644\n--- a/t/helper/test-read-cache.c\n+++ b/t/helper/test-read-cache.c\n@@ -8,7 +8,7 @@ int cmd_main(int argc, const char **argv)\n \tsetup_git_directory();\n \tfor (i = 0; i < cnt; i++) {\n \t\tread_index(&the_index);\n-\t\tdiscard_cache();\n+\t\tdiscard_index(&the_index);\n \t}\n \treturn 0;\n }\ndiff --git a/wt-status.c b/wt-status.c\nindex ff0e70a25a..d17d4cb6ca 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -2247,7 +2247,7 @@ int has_uncommitted_changes(int ignore_submodules)\n \tstruct rev_info rev_info;\n \tint result;\n \n-\tif (is_cache_unborn())\n+\tif (is_index_unborn(&the_index))\n \t\treturn 0;\n \n \tinit_revisions(&rev_info, NULL);\n-- \n2.13.0.rc1.39.ga6db8bfa24\n\n"},{"id":"318582","messageId":"20170502222322.21055-10-sbeller@google.com","threadId":"45853","inReplyTo":"20170502222322.21055-1-sbeller@google.com","subject":"[PATCH 09/24] cache.h: drop resolve_undo_clear","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-05-02T22:23:07Z","receivedAt":"2017-05-02T22:24:12Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Signed-off-by: Stefan Beller <sbeller@google.com>\n---\n builtin/checkout.c     | 2 +-\n builtin/merge.c        | 2 +-\n builtin/read-tree.c    | 2 +-\n builtin/update-index.c | 2 +-\n cache.h                | 1 -\n merge.c                | 2 +-\n 6 files changed, 5 insertions(+), 6 deletions(-)\n\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex 2328a475ea..abcc45a74f 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -491,7 +491,7 @@ static int merge_working_tree(const struct checkout_opts *opts,\n \tif (read_index_preload(&the_index, NULL) < 0)\n \t\treturn error(_(\"index file corrupt\"));\n \n-\tresolve_undo_clear();\n+\tresolve_undo_clear_index(&the_index);\n \tif (opts->force) {\n \t\tret = reset_tree(new->commit->tree, opts, 1, writeout_error);\n \t\tif (ret)\ndiff --git a/builtin/merge.c b/builtin/merge.c\nindex c27c806ac1..b023107d26 100644\n--- a/builtin/merge.c\n+++ b/builtin/merge.c\n@@ -1191,7 +1191,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)\n \t\telse\n \t\t\tdie(_(\"You have not concluded your cherry-pick (CHERRY_PICK_HEAD exists).\"));\n \t}\n-\tresolve_undo_clear();\n+\tresolve_undo_clear_index(&the_index);\n \n \tif (verbosity < 0)\n \t\tshow_diffstat = 0;\ndiff --git a/builtin/read-tree.c b/builtin/read-tree.c\nindex 0bcf021ead..61f5f6f028 100644\n--- a/builtin/read-tree.c\n+++ b/builtin/read-tree.c\n@@ -199,7 +199,7 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)\n \t\t\tdie(\"You need to resolve your current index first\");\n \t\tstage = opts.merge = 1;\n \t}\n-\tresolve_undo_clear();\n+\tresolve_undo_clear_index(&the_index);\n \n \tfor (i = 0; i < argc; i++) {\n \t\tconst char *arg = argv[i];\ndiff --git a/builtin/update-index.c b/builtin/update-index.c\nindex b8458016f0..c9f06169c0 100644\n--- a/builtin/update-index.c\n+++ b/builtin/update-index.c\n@@ -796,7 +796,7 @@ static int chmod_callback(const struct option *opt,\n static int resolve_undo_clear_callback(const struct option *opt,\n \t\t\t\tconst char *arg, int unset)\n {\n-\tresolve_undo_clear();\n+\tresolve_undo_clear_index(&the_index);\n \treturn 0;\n }\n \ndiff --git a/cache.h b/cache.h\nindex 8a2dc393dc..abf1474034 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -371,7 +371,6 @@ extern void free_name_hash(struct index_state *istate);\n #define cache_dir_exists(name, namelen) index_dir_exists(&the_index, (name), (namelen))\n #define cache_file_exists(name, namelen, igncase) index_file_exists(&the_index, (name), (namelen), (igncase))\n #define cache_name_is_other(name, namelen) index_name_is_other(&the_index, (name), (namelen))\n-#define resolve_undo_clear() resolve_undo_clear_index(&the_index)\n #endif\n \n enum object_type {\ndiff --git a/merge.c b/merge.c\nindex 748305031e..06509a6df2 100644\n--- a/merge.c\n+++ b/merge.c\n@@ -39,7 +39,7 @@ int try_merge_command(const char *strategy, size_t xopts_nr,\n \tdiscard_cache();\n \tif (read_index(&the_index) < 0)\n \t\tdie(_(\"failed to read the cache\"));\n-\tresolve_undo_clear();\n+\tresolve_undo_clear_index(&the_index);\n \n \treturn ret;\n }\n-- \n2.13.0.rc1.39.ga6db8bfa24\n\n"},{"id":"318583","messageId":"20170502222322.21055-9-sbeller@google.com","threadId":"45853","inReplyTo":"20170502222322.21055-1-sbeller@google.com","subject":"[PATCH 08/24] cache.h: drop unmerge_cache[_entry_at]","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-05-02T22:23:06Z","receivedAt":"2017-05-02T22:24:13Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Signed-off-by: Stefan Beller <sbeller@google.com>\n---\n builtin/update-index.c | 2 +-\n cache.h                | 2 --\n rerere.c               | 2 +-\n 3 files changed, 2 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin/update-index.c b/builtin/update-index.c\nindex 8667c48446..b8458016f0 100644\n--- a/builtin/update-index.c\n+++ b/builtin/update-index.c\n@@ -613,7 +613,7 @@ static int unresolve_one(const char *path)\n \tpos = cache_name_pos(path, namelen);\n \tif (0 <= pos) {\n \t\t/* already merged */\n-\t\tpos = unmerge_cache_entry_at(pos);\n+\t\tpos = unmerge_index_entry_at(&the_index, pos);\n \t\tif (pos < the_index.cache_nr) {\n \t\t\tconst struct cache_entry *ce = the_index.cache[pos];\n \t\t\tif (ce_stage(ce) &&\ndiff --git a/cache.h b/cache.h\nindex d078e88c3f..8a2dc393dc 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -372,8 +372,6 @@ extern void free_name_hash(struct index_state *istate);\n #define cache_file_exists(name, namelen, igncase) index_file_exists(&the_index, (name), (namelen), (igncase))\n #define cache_name_is_other(name, namelen) index_name_is_other(&the_index, (name), (namelen))\n #define resolve_undo_clear() resolve_undo_clear_index(&the_index)\n-#define unmerge_cache_entry_at(at) unmerge_index_entry_at(&the_index, at)\n-#define unmerge_cache(pathspec) unmerge_index(&the_index, pathspec)\n #endif\n \n enum object_type {\ndiff --git a/rerere.c b/rerere.c\nindex b9b39a959e..03218166ab 100644\n--- a/rerere.c\n+++ b/rerere.c\n@@ -1116,7 +1116,7 @@ int rerere_forget(struct pathspec *pathspec)\n \t * recover the original conflicted state and then\n \t * find the conflicted paths.\n \t */\n-\tunmerge_cache(pathspec);\n+\tunmerge_index(&the_index, pathspec);\n \tfind_conflict(&conflict);\n \tfor (i = 0; i < conflict.nr; i++) {\n \t\tstruct string_list_item *it = &conflict.items[i];\n-- \n2.13.0.rc1.39.ga6db8bfa24\n\n"},{"id":"318584","messageId":"20170502222322.21055-15-sbeller@google.com","threadId":"45853","inReplyTo":"20170502222322.21055-1-sbeller@google.com","subject":"[PATCH 14/24] cache.h: drop cache_name_pos","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-05-02T22:23:12Z","receivedAt":"2017-05-02T22:24:15Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"coccinelle patch:\n@@ expression name, namelen; @@\n-cache_name_pos(name, namelen)\n+index_name_pos(&the_index, name, namelen)\n\nAdditionally manual editing:\n * drop the define from cache.h.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n apply.c                  |  9 +++++----\n builtin/blame.c          |  4 ++--\n builtin/checkout-index.c |  2 +-\n builtin/checkout.c       |  2 +-\n builtin/ls-files.c       |  7 ++++---\n builtin/merge-index.c    |  2 +-\n builtin/mv.c             |  8 ++++----\n builtin/rm.c             |  4 ++--\n builtin/update-index.c   | 10 +++++-----\n cache.h                  |  1 -\n diff.c                   |  2 +-\n dir.c                    |  8 ++++----\n merge-recursive.c        |  4 ++--\n pathspec.c               |  2 +-\n rerere.c                 |  2 +-\n sha1_name.c              |  6 +++---\n submodule.c              |  2 +-\n wt-status.c              |  4 ++--\n 18 files changed, 40 insertions(+), 39 deletions(-)\n\ndiff --git a/apply.c b/apply.c\nindex eb8eaeabec..bb1cd77c66 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -3496,7 +3496,7 @@ static int load_current(struct apply_state *state,\n \tif (!patch->is_new)\n \t\tdie(\"BUG: patch to %s is not a creation\", patch->old_name);\n \n-\tpos = cache_name_pos(name, strlen(name));\n+\tpos = index_name_pos(&the_index, name, strlen(name));\n \tif (pos < 0)\n \t\treturn error(_(\"%s: does not exist in index\"), name);\n \tce = the_index.cache[pos];\n@@ -3665,7 +3665,8 @@ static int check_preimage(struct apply_state *state,\n \t}\n \n \tif (state->check_index && !previous) {\n-\t\tint pos = cache_name_pos(old_name, strlen(old_name));\n+\t\tint pos = index_name_pos(&the_index, old_name,\n+\t\t\t\t\t strlen(old_name));\n \t\tif (pos < 0) {\n \t\t\tif (patch->is_new < 0)\n \t\t\t\tgoto is_new;\n@@ -3721,7 +3722,7 @@ static int check_to_create(struct apply_state *state,\n \tstruct stat nst;\n \n \tif (state->check_index &&\n-\t    cache_name_pos(new_name, strlen(new_name)) >= 0 &&\n+\t    index_name_pos(&the_index, new_name, strlen(new_name)) >= 0 &&\n \t    !ok_if_exists)\n \t\treturn EXISTS_IN_INDEX;\n \tif (state->cached)\n@@ -3998,7 +3999,7 @@ static int get_current_oid(struct apply_state *state, const char *path,\n \n \tif (read_apply_cache(state) < 0)\n \t\treturn -1;\n-\tpos = cache_name_pos(path, strlen(path));\n+\tpos = index_name_pos(&the_index, path, strlen(path));\n \tif (pos < 0)\n \t\treturn -1;\n \toidcpy(oid, &the_index.cache[pos]->oid);\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex b47aae25d4..c71d9a3340 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -2239,7 +2239,7 @@ static void verify_working_tree_path(struct commit *work_tree, const char *path)\n \t\t\treturn;\n \t}\n \n-\tpos = cache_name_pos(path, strlen(path));\n+\tpos = index_name_pos(&the_index, path, strlen(path));\n \tif (pos >= 0)\n \t\t; /* path is in the index */\n \telse if (-1 - pos < the_index.cache_nr &&\n@@ -2399,7 +2399,7 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,\n \n \tlen = strlen(path);\n \tif (!mode) {\n-\t\tint pos = cache_name_pos(path, len);\n+\t\tint pos = index_name_pos(&the_index, path, len);\n \t\tif (0 <= pos)\n \t\t\tmode = the_index.cache[pos]->ce_mode;\n \t\telse\ndiff --git a/builtin/checkout-index.c b/builtin/checkout-index.c\nindex 1c3dcc1a8b..e8fc24b2ce 100644\n--- a/builtin/checkout-index.c\n+++ b/builtin/checkout-index.c\n@@ -46,7 +46,7 @@ static void write_tempfile_record(const char *name, const char *prefix)\n static int checkout_file(const char *name, const char *prefix)\n {\n \tint namelen = strlen(name);\n-\tint pos = cache_name_pos(name, namelen);\n+\tint pos = index_name_pos(&the_index, name, namelen);\n \tint has_same_name = 0;\n \tint did_checkout = 0;\n \tint errs = 0;\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex a6cd8c0f37..039d3d296b 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -107,7 +107,7 @@ static int update_some(const unsigned char *sha1, struct strbuf *base,\n \t * entry in place. Whether it is UPTODATE or not, checkout_entry will\n \t * do the right thing.\n \t */\n-\tpos = cache_name_pos(ce->name, ce->ce_namelen);\n+\tpos = index_name_pos(&the_index, ce->name, ce->ce_namelen);\n \tif (pos >= 0) {\n \t\tstruct cache_entry *old = the_index.cache[pos];\n \t\tif (ce->ce_mode == old->ce_mode &&\ndiff --git a/builtin/ls-files.c b/builtin/ls-files.c\nindex 6f7ecec1b0..3507490d3e 100644\n--- a/builtin/ls-files.c\n+++ b/builtin/ls-files.c\n@@ -134,7 +134,8 @@ static void show_killed_files(struct dir_struct *dir)\n \t\t\t\t/* If ent->name is prefix of an entry in the\n \t\t\t\t * cache, it will be killed.\n \t\t\t\t */\n-\t\t\t\tpos = cache_name_pos(ent->name, ent->len);\n+\t\t\t\tpos = index_name_pos(&the_index, ent->name,\n+\t\t\t\t\t\t     ent->len);\n \t\t\t\tif (0 <= pos)\n \t\t\t\t\tdie(\"BUG: killed-file %.*s not found\",\n \t\t\t\t\t\tent->len, ent->name);\n@@ -156,7 +157,7 @@ static void show_killed_files(struct dir_struct *dir)\n \t\t\t\t\tkilled = 1;\n \t\t\t\tbreak;\n \t\t\t}\n-\t\t\tif (0 <= cache_name_pos(ent->name, sp - ent->name)) {\n+\t\t\tif (0 <= index_name_pos(&the_index, ent->name, sp - ent->name)) {\n \t\t\t\t/* If any of the leading directories in\n \t\t\t\t * ent->name is registered in the cache,\n \t\t\t\t * ent->name will be killed.\n@@ -384,7 +385,7 @@ static void prune_cache(const char *prefix, size_t prefixlen)\n \n \tif (!prefix)\n \t\treturn;\n-\tpos = cache_name_pos(prefix, prefixlen);\n+\tpos = index_name_pos(&the_index, prefix, prefixlen);\n \tif (pos < 0)\n \t\tpos = -pos-1;\n \tfirst = pos;\ndiff --git a/builtin/merge-index.c b/builtin/merge-index.c\nindex d867ee73f0..ec7104614c 100644\n--- a/builtin/merge-index.c\n+++ b/builtin/merge-index.c\n@@ -44,7 +44,7 @@ static int merge_entry(int pos, const char *path)\n \n static void merge_one_path(const char *path)\n {\n-\tint pos = cache_name_pos(path, strlen(path));\n+\tint pos = index_name_pos(&the_index, path, strlen(path));\n \n \t/*\n \t * If it already exists in the cache as stage0, it's\ndiff --git a/builtin/mv.c b/builtin/mv.c\nindex 3b887a9490..40e40bb098 100644\n--- a/builtin/mv.c\n+++ b/builtin/mv.c\n@@ -97,7 +97,7 @@ static int index_range_of_same_dir(const char *src, int length,\n \tconst char *src_w_slash = add_slash(src);\n \tint first, last, len_w_slash = length + 1;\n \n-\tfirst = cache_name_pos(src_w_slash, len_w_slash);\n+\tfirst = index_name_pos(&the_index, src_w_slash, len_w_slash);\n \tif (first >= 0)\n \t\tdie(_(\"%.*s is in index\"), len_w_slash, src_w_slash);\n \n@@ -187,7 +187,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)\n \t\t\t\t&& lstat(dst, &st) == 0)\n \t\t\tbad = _(\"cannot move directory over file\");\n \t\telse if (src_is_dir) {\n-\t\t\tint first = cache_name_pos(src, length), last;\n+\t\t\tint first = index_name_pos(&the_index, src, length), last;\n \n \t\t\tif (first >= 0)\n \t\t\t\tprepare_move_submodule(src, first,\n@@ -218,7 +218,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)\n \t\t\t\t}\n \t\t\t\targc += last - first;\n \t\t\t}\n-\t\t} else if (cache_name_pos(src, length) < 0)\n+\t\t} else if (index_name_pos(&the_index, src, length) < 0)\n \t\t\tbad = _(\"not under version control\");\n \t\telse if (lstat(dst, &st) == 0 &&\n \t\t\t (!ignore_case || strcasecmp(src, dst))) {\n@@ -284,7 +284,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)\n \t\tif (mode == WORKING_DIRECTORY)\n \t\t\tcontinue;\n \n-\t\tpos = cache_name_pos(src, strlen(src));\n+\t\tpos = index_name_pos(&the_index, src, strlen(src));\n \t\tassert(pos >= 0);\n \t\tif (!show_only)\n \t\t\trename_cache_entry_at(pos, dst);\ndiff --git a/builtin/rm.c b/builtin/rm.c\nindex 0813d0a853..c77c941ef0 100644\n--- a/builtin/rm.c\n+++ b/builtin/rm.c\n@@ -67,7 +67,7 @@ static void submodules_absorb_gitdir_if_needed(const char *prefix)\n \t\tint pos;\n \t\tconst struct cache_entry *ce;\n \n-\t\tpos = cache_name_pos(name, strlen(name));\n+\t\tpos = index_name_pos(&the_index, name, strlen(name));\n \t\tif (pos < 0) {\n \t\t\tpos = get_ours_cache_pos(name, pos);\n \t\t\tif (pos < 0)\n@@ -112,7 +112,7 @@ static int check_local_mod(struct object_id *head, int index_only)\n \t\tint local_changes = 0;\n \t\tint staged_changes = 0;\n \n-\t\tpos = cache_name_pos(name, strlen(name));\n+\t\tpos = index_name_pos(&the_index, name, strlen(name));\n \t\tif (pos < 0) {\n \t\t\t/*\n \t\t\t * Skip unmerged entries except for populated submodules\ndiff --git a/builtin/update-index.c b/builtin/update-index.c\nindex c9f06169c0..d7a117c674 100644\n--- a/builtin/update-index.c\n+++ b/builtin/update-index.c\n@@ -225,7 +225,7 @@ static int test_if_untracked_cache_is_supported(void)\n static int mark_ce_flags(const char *path, int flag, int mark)\n {\n \tint namelen = strlen(path);\n-\tint pos = cache_name_pos(path, namelen);\n+\tint pos = index_name_pos(&the_index, path, namelen);\n \tif (0 <= pos) {\n \t\tif (mark)\n \t\t\tthe_index.cache[pos]->ce_flags |= flag;\n@@ -317,7 +317,7 @@ static int add_one_path(const struct cache_entry *old, const char *path, int len\n static int process_directory(const char *path, int len, struct stat *st)\n {\n \tstruct object_id oid;\n-\tint pos = cache_name_pos(path, len);\n+\tint pos = index_name_pos(&the_index, path, len);\n \n \t/* Exact match: file or existing gitlink */\n \tif (pos >= 0) {\n@@ -368,7 +368,7 @@ static int process_path(const char *path)\n \tif (has_symlink_leading_path(path, len))\n \t\treturn error(\"'%s' is beyond a symbolic link\", path);\n \n-\tpos = cache_name_pos(path, len);\n+\tpos = index_name_pos(&the_index, path, len);\n \tce = pos < 0 ? NULL : the_index.cache[pos];\n \tif (ce && ce_skip_worktree(ce)) {\n \t\t/*\n@@ -428,7 +428,7 @@ static void chmod_path(char flip, const char *path)\n \tint pos;\n \tstruct cache_entry *ce;\n \n-\tpos = cache_name_pos(path, strlen(path));\n+\tpos = index_name_pos(&the_index, path, strlen(path));\n \tif (pos < 0)\n \t\tgoto fail;\n \tce = the_index.cache[pos];\n@@ -610,7 +610,7 @@ static int unresolve_one(const char *path)\n \tstruct cache_entry *ce_2 = NULL, *ce_3 = NULL;\n \n \t/* See if there is such entry in the index. */\n-\tpos = cache_name_pos(path, namelen);\n+\tpos = index_name_pos(&the_index, path, namelen);\n \tif (0 <= pos) {\n \t\t/* already merged */\n \t\tpos = unmerge_index_entry_at(&the_index, pos);\ndiff --git a/cache.h b/cache.h\nindex a021d6e988..a18ebf263a 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -354,7 +354,6 @@ extern void free_name_hash(struct index_state *istate);\n \n \n #ifndef NO_THE_INDEX_COMPATIBILITY_MACROS\n-#define cache_name_pos(name, namelen) index_name_pos(&the_index,(name),(namelen))\n #define add_cache_entry(ce, option) add_index_entry(&the_index, (ce), (option))\n #define rename_cache_entry_at(pos, new_name) rename_index_entry_at(&the_index, (pos), (new_name))\n #define remove_cache_entry_at(pos) remove_index_entry_at(&the_index, (pos))\ndiff --git a/diff.c b/diff.c\nindex 37083914c5..f2ee40fe21 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -2759,7 +2759,7 @@ static int reuse_worktree_file(const char *name, const unsigned char *sha1, int\n \t\treturn 0;\n \n \tlen = strlen(name);\n-\tpos = cache_name_pos(name, len);\n+\tpos = index_name_pos(&the_index, name, len);\n \tif (pos < 0)\n \t\treturn 0;\n \tce = the_index.cache[pos];\ndiff --git a/dir.c b/dir.c\nindex 63edaec2ef..47890b3d3b 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -596,7 +596,7 @@ static void *read_skip_worktree_file_from_index(const char *path, size_t *size,\n \tvoid *data;\n \n \tlen = strlen(path);\n-\tpos = cache_name_pos(path, len);\n+\tpos = index_name_pos(&the_index, path, len);\n \tif (pos < 0)\n \t\treturn NULL;\n \tif (!ce_skip_worktree(the_index.cache[pos]))\n@@ -785,7 +785,7 @@ static int add_excludes(const char *fname, const char *base, int baselen,\n \t\t\t    !match_stat_data_racy(&the_index, &sha1_stat->stat, &st))\n \t\t\t\t; /* no content change, ss->sha1 still good */\n \t\t\telse if (check_index &&\n-\t\t\t\t (pos = cache_name_pos(fname, strlen(fname))) >= 0 &&\n+\t\t\t\t (pos = index_name_pos(&the_index, fname, strlen(fname))) >= 0 &&\n \t\t\t\t !ce_stage(the_index.cache[pos]) &&\n \t\t\t\t ce_uptodate(the_index.cache[pos]) &&\n \t\t\t\t !would_convert_to_git(fname))\n@@ -1290,7 +1290,7 @@ static enum exist_status directory_exists_in_index(const char *dirname, int len)\n \tif (ignore_case)\n \t\treturn directory_exists_in_index_icase(dirname, len);\n \n-\tpos = cache_name_pos(dirname, len);\n+\tpos = index_name_pos(&the_index, dirname, len);\n \tif (pos < 0)\n \t\tpos = -pos-1;\n \twhile (pos < the_index.cache_nr) {\n@@ -1474,7 +1474,7 @@ static int get_index_dtype(const char *path, int len)\n \t}\n \n \t/* Try to look it up as a directory */\n-\tpos = cache_name_pos(path, len);\n+\tpos = index_name_pos(&the_index, path, len);\n \tif (pos >= 0)\n \t\treturn DT_UNKNOWN;\n \tpos = -pos-1;\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex eb0f0c6960..163d37866e 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -680,7 +680,7 @@ static int dir_in_way(const char *path, int check_working_copy, int empty_ok)\n \tstrbuf_addstr(&dirpath, path);\n \tstrbuf_addch(&dirpath, '/');\n \n-\tpos = cache_name_pos(dirpath.buf, dirpath.len);\n+\tpos = index_name_pos(&the_index, dirpath.buf, dirpath.len);\n \n \tif (pos < 0)\n \t\tpos = -1 - pos;\n@@ -697,7 +697,7 @@ static int dir_in_way(const char *path, int check_working_copy, int empty_ok)\n \n static int was_tracked(const char *path)\n {\n-\tint pos = cache_name_pos(path, strlen(path));\n+\tint pos = index_name_pos(&the_index, path, strlen(path));\n \n \tif (0 <= pos)\n \t\t/* we have been tracking this path */\ndiff --git a/pathspec.c b/pathspec.c\nindex 25c2afef30..28b5f8b606 100644\n--- a/pathspec.c\n+++ b/pathspec.c\n@@ -389,7 +389,7 @@ static const char *parse_element_magic(unsigned *magic, int *prefix_len,\n static void strip_submodule_slash_cheap(struct pathspec_item *item)\n {\n \tif (item->len >= 1 && item->match[item->len - 1] == '/') {\n-\t\tint i = cache_name_pos(item->match, item->len - 1);\n+\t\tint i = index_name_pos(&the_index, item->match, item->len - 1);\n \n \t\tif (i >= 0 && S_ISGITLINK(the_index.cache[i]->ce_mode)) {\n \t\t\titem->len--;\ndiff --git a/rerere.c b/rerere.c\nindex 03218166ab..b6d84b8461 100644\n--- a/rerere.c\n+++ b/rerere.c\n@@ -966,7 +966,7 @@ static int handle_cache(const char *path, unsigned char *sha1, const char *outpu\n \t * Reproduce the conflicted merge in-core\n \t */\n \tlen = strlen(path);\n-\tpos = cache_name_pos(path, len);\n+\tpos = index_name_pos(&the_index, path, len);\n \tif (0 <= pos)\n \t\treturn -1;\n \tpos = -pos - 1;\ndiff --git a/sha1_name.c b/sha1_name.c\nindex b73e261498..41ab9d9f1a 100644\n--- a/sha1_name.c\n+++ b/sha1_name.c\n@@ -1441,7 +1441,7 @@ static void diagnose_invalid_index_path(int stage,\n \t\tprefix = \"\";\n \n \t/* Wrong stage number? */\n-\tpos = cache_name_pos(filename, namelen);\n+\tpos = index_name_pos(&the_index, filename, namelen);\n \tif (pos < 0)\n \t\tpos = -pos - 1;\n \tif (pos < the_index.cache_nr) {\n@@ -1457,7 +1457,7 @@ static void diagnose_invalid_index_path(int stage,\n \t/* Confusion between relative and absolute filenames? */\n \tstrbuf_addstr(&fullname, prefix);\n \tstrbuf_addstr(&fullname, filename);\n-\tpos = cache_name_pos(fullname.buf, fullname.len);\n+\tpos = index_name_pos(&the_index, fullname.buf, fullname.len);\n \tif (pos < 0)\n \t\tpos = -pos - 1;\n \tif (pos < the_index.cache_nr) {\n@@ -1553,7 +1553,7 @@ static int get_sha1_with_context_1(const char *name,\n \n \t\tif (!the_index.cache)\n \t\t\tread_index(&the_index);\n-\t\tpos = cache_name_pos(cp, namelen);\n+\t\tpos = index_name_pos(&the_index, cp, namelen);\n \t\tif (pos < 0)\n \t\t\tpos = -pos - 1;\n \t\twhile (pos < the_index.cache_nr) {\ndiff --git a/submodule.c b/submodule.c\nindex b225ff6d1f..148194831d 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -179,7 +179,7 @@ void gitmodules_config(void)\n \t\tstrbuf_addstr(&gitmodules_path, \"/.gitmodules\");\n \t\tif (read_index(&the_index) < 0)\n \t\t\tdie(\"index file corrupt\");\n-\t\tpos = cache_name_pos(\".gitmodules\", 11);\n+\t\tpos = index_name_pos(&the_index, \".gitmodules\", 11);\n \t\tif (pos < 0) { /* .gitmodules not found or isn't merged */\n \t\t\tpos = -1 - pos;\n \t\t\tif (the_index.cache_nr > pos) {  /* there is a .gitmodules */\ndiff --git a/wt-status.c b/wt-status.c\nindex d17d4cb6ca..59cdf09a07 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -481,7 +481,7 @@ static int unmerged_mask(const char *path)\n \tint pos, mask;\n \tconst struct cache_entry *ce;\n \n-\tpos = cache_name_pos(path, strlen(path));\n+\tpos = index_name_pos(&the_index, path, strlen(path));\n \tif (0 <= pos)\n \t\treturn 0;\n \n@@ -2096,7 +2096,7 @@ static void wt_porcelain_v2_print_unmerged_entry(\n \t */\n \tmemset(stages, 0, sizeof(stages));\n \tsum = 0;\n-\tpos = cache_name_pos(it->string, strlen(it->string));\n+\tpos = index_name_pos(&the_index, it->string, strlen(it->string));\n \tassert(pos < 0);\n \tpos = -pos-1;\n \twhile (pos < the_index.cache_nr) {\n-- \n2.13.0.rc1.39.ga6db8bfa24\n\n"},{"id":"318585","messageId":"20170502222322.21055-23-sbeller@google.com","threadId":"45853","inReplyTo":"20170502222322.21055-1-sbeller@google.com","subject":"[PATCH 22/24] cache.h: drop ce_modified","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-05-02T22:23:20Z","receivedAt":"2017-05-02T22:24:21Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Signed-off-by: Stefan Beller <sbeller@google.com>\n---\n builtin/ls-files.c | 2 +-\n cache.h            | 1 -\n 2 files changed, 1 insertion(+), 2 deletions(-)\n\ndiff --git a/builtin/ls-files.c b/builtin/ls-files.c\nindex 3507490d3e..89fac7ddf5 100644\n--- a/builtin/ls-files.c\n+++ b/builtin/ls-files.c\n@@ -369,7 +369,7 @@ static void show_files(struct dir_struct *dir)\n \t\t\terr = lstat(ce->name, &st);\n \t\t\tif (show_deleted && err)\n \t\t\t\tshow_ce_entry(tag_removed, ce);\n-\t\t\tif (show_modified && ce_modified(ce, &st, 0))\n+\t\t\tif (show_modified && ie_modified(&the_index, ce, &st, 0))\n \t\t\t\tshow_ce_entry(tag_modified, ce);\n \t\t}\n \t}\ndiff --git a/cache.h b/cache.h\nindex 23c9c1697c..c34fc4fd40 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -355,7 +355,6 @@ extern void free_name_hash(struct index_state *istate);\n \n #ifndef NO_THE_INDEX_COMPATIBILITY_MACROS\n #define ce_match_stat(ce, st, options) ie_match_stat(&the_index, (ce), (st), (options))\n-#define ce_modified(ce, st, options) ie_modified(&the_index, (ce), (st), (options))\n #endif\n \n enum object_type {\n-- \n2.13.0.rc1.39.ga6db8bfa24\n\n"},{"id":"318586","messageId":"20170502222322.21055-21-sbeller@google.com","threadId":"45853","inReplyTo":"20170502222322.21055-1-sbeller@google.com","subject":"[PATCH 20/24] cache.h: drop chmod_cache_entry","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-05-02T22:23:18Z","receivedAt":"2017-05-02T22:24:23Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Signed-off-by: Stefan Beller <sbeller@google.com>\n---\n builtin/add.c          | 2 +-\n builtin/update-index.c | 2 +-\n cache.h                | 1 -\n 3 files changed, 2 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/add.c b/builtin/add.c\nindex f6d71b10d0..288b1f5bb3 100644\n--- a/builtin/add.c\n+++ b/builtin/add.c\n@@ -40,7 +40,7 @@ static void chmod_pathspec(struct pathspec *pathspec, int force_mode)\n \t\tif (pathspec && !ce_path_match(ce, pathspec, NULL))\n \t\t\tcontinue;\n \n-\t\tif (chmod_cache_entry(ce, force_mode) < 0)\n+\t\tif (chmod_index_entry(&the_index, ce, force_mode) < 0)\n \t\t\tfprintf(stderr, \"cannot chmod '%s'\", ce->name);\n \t}\n }\ndiff --git a/builtin/update-index.c b/builtin/update-index.c\nindex 8c4911e920..f1c52a5531 100644\n--- a/builtin/update-index.c\n+++ b/builtin/update-index.c\n@@ -432,7 +432,7 @@ static void chmod_path(char flip, const char *path)\n \tif (pos < 0)\n \t\tgoto fail;\n \tce = the_index.cache[pos];\n-\tif (chmod_cache_entry(ce, flip) < 0)\n+\tif (chmod_index_entry(&the_index, ce, flip) < 0)\n \t\tgoto fail;\n \n \treport(\"chmod %cx '%s'\", flip, path);\ndiff --git a/cache.h b/cache.h\nindex a9b059913e..07ad23d912 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -354,7 +354,6 @@ extern void free_name_hash(struct index_state *istate);\n \n \n #ifndef NO_THE_INDEX_COMPATIBILITY_MACROS\n-#define chmod_cache_entry(ce, flip) chmod_index_entry(&the_index, (ce), (flip))\n #define refresh_cache(flags) refresh_index(&the_index, (flags), NULL, NULL, NULL)\n #define ce_match_stat(ce, st, options) ie_match_stat(&the_index, (ce), (st), (options))\n #define ce_modified(ce, st, options) ie_modified(&the_index, (ce), (st), (options))\n-- \n2.13.0.rc1.39.ga6db8bfa24\n\n"},{"id":"318587","messageId":"20170502222322.21055-24-sbeller@google.com","threadId":"45853","inReplyTo":"20170502222322.21055-1-sbeller@google.com","subject":"[PATCH 23/24] cache.h: drop ce_match_stat","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-05-02T22:23:21Z","receivedAt":"2017-05-02T22:24:31Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"coccinelle patch:\n@@ expression ce, st, options; @@\n-ce_match_stat(ce, st, options)\n+ie_match_stat(&the_index, ce, st, options)\n\nAdditionally drop the define from cache.h manually.\n\nNote that there is an empty define section in cache.h now.\nThe cleanup of that is done in a later patch.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n apply.c                | 3 ++-\n builtin/rm.c           | 2 +-\n builtin/update-index.c | 2 +-\n cache.h                | 1 -\n check-racy.c           | 4 ++--\n diff-lib.c             | 2 +-\n diff.c                 | 2 +-\n entry.c                | 3 ++-\n submodule.c            | 2 +-\n 9 files changed, 11 insertions(+), 10 deletions(-)\n\ndiff --git a/apply.c b/apply.c\nindex 8a61f19d03..46bc5a20b9 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -3364,7 +3364,8 @@ static int verify_index_match(const struct cache_entry *ce, struct stat *st)\n \t\t\treturn -1;\n \t\treturn 0;\n \t}\n-\treturn ce_match_stat(ce, st, CE_MATCH_IGNORE_VALID|CE_MATCH_IGNORE_SKIP_WORKTREE);\n+\treturn ie_match_stat(&the_index, ce, st,\n+\t\t\t     CE_MATCH_IGNORE_VALID | CE_MATCH_IGNORE_SKIP_WORKTREE);\n }\n \n #define SUBMODULE_PATCH_WITHOUT_INDEX 1\ndiff --git a/builtin/rm.c b/builtin/rm.c\nindex f479100298..51b64f2bae 100644\n--- a/builtin/rm.c\n+++ b/builtin/rm.c\n@@ -163,7 +163,7 @@ static int check_local_mod(struct object_id *head, int index_only)\n \t\t * Is the index different from the file in the work tree?\n \t\t * If it's a submodule, is its work tree modified?\n \t\t */\n-\t\tif (ce_match_stat(ce, &st, 0) ||\n+\t\tif (ie_match_stat(&the_index, ce, &st, 0) ||\n \t\t    (S_ISGITLINK(ce->ce_mode) &&\n \t\t     bad_to_remove_submodule(ce->name,\n \t\t\t\tSUBMODULE_REMOVAL_DIE_ON_ERROR |\ndiff --git a/builtin/update-index.c b/builtin/update-index.c\nindex 9cbd346f95..042f4c94cf 100644\n--- a/builtin/update-index.c\n+++ b/builtin/update-index.c\n@@ -268,7 +268,7 @@ static int add_one_path(const struct cache_entry *old, const char *path, int len\n \tstruct cache_entry *ce;\n \n \t/* Was the old index entry already up-to-date? */\n-\tif (old && !ce_stage(old) && !ce_match_stat(old, st, 0))\n+\tif (old && !ce_stage(old) && !ie_match_stat(&the_index, old, st, 0))\n \t\treturn 0;\n \n \tsize = cache_entry_size(len);\ndiff --git a/cache.h b/cache.h\nindex c34fc4fd40..f2a45eda9a 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -354,7 +354,6 @@ extern void free_name_hash(struct index_state *istate);\n \n \n #ifndef NO_THE_INDEX_COMPATIBILITY_MACROS\n-#define ce_match_stat(ce, st, options) ie_match_stat(&the_index, (ce), (st), (options))\n #endif\n \n enum object_type {\ndiff --git a/check-racy.c b/check-racy.c\nindex 6599ae84cf..485d7ab8f8 100644\n--- a/check-racy.c\n+++ b/check-racy.c\n@@ -16,9 +16,9 @@ int main(int ac, char **av)\n \t\t\tcontinue;\n \t\t}\n \n-\t\tif (ce_match_stat(ce, &st, 0))\n+\t\tif (ie_match_stat(&the_index, ce, &st, 0))\n \t\t\tdirty++;\n-\t\telse if (ce_match_stat(ce, &st, CE_MATCH_RACY_IS_DIRTY))\n+\t\telse if (ie_match_stat(&the_index, ce, &st, CE_MATCH_RACY_IS_DIRTY))\n \t\t\tracy++;\n \t\telse\n \t\t\tclean++;\ndiff --git a/diff-lib.c b/diff-lib.c\nindex de59ec0459..4ca3ce9c90 100644\n--- a/diff-lib.c\n+++ b/diff-lib.c\n@@ -69,7 +69,7 @@ static int match_stat_with_submodule(struct diff_options *diffopt,\n \t\t\t\t     struct stat *st, unsigned ce_option,\n \t\t\t\t     unsigned *dirty_submodule)\n {\n-\tint changed = ce_match_stat(ce, st, ce_option);\n+\tint changed = ie_match_stat(&the_index, ce, st, ce_option);\n \tif (S_ISGITLINK(ce->ce_mode)) {\n \t\tunsigned orig_flags = diffopt->flags;\n \t\tif (!DIFF_OPT_TST(diffopt, OVERRIDE_SUBMODULE_CONFIG))\ndiff --git a/diff.c b/diff.c\nindex f2ee40fe21..bd1478f6c9 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -2782,7 +2782,7 @@ static int reuse_worktree_file(const char *name, const unsigned char *sha1, int\n \t * If ce matches the file in the work tree, we can reuse it.\n \t */\n \tif (ce_uptodate(ce) ||\n-\t    (!lstat(name, &st) && !ce_match_stat(ce, &st, 0)))\n+\t    (!lstat(name, &st) && !ie_match_stat(&the_index, ce, &st, 0)))\n \t\treturn 1;\n \n \treturn 0;\ndiff --git a/entry.c b/entry.c\nindex d2b512da90..d3a34c9cc4 100644\n--- a/entry.c\n+++ b/entry.c\n@@ -266,7 +266,8 @@ int checkout_entry(struct cache_entry *ce,\n \n \tif (!check_path(path.buf, path.len, &st, state->base_dir_len)) {\n \t\tconst struct submodule *sub;\n-\t\tunsigned changed = ce_match_stat(ce, &st, CE_MATCH_IGNORE_VALID|CE_MATCH_IGNORE_SKIP_WORKTREE);\n+\t\tunsigned changed = ie_match_stat(&the_index, ce, &st,\n+\t\t\t\t\t\t CE_MATCH_IGNORE_VALID | CE_MATCH_IGNORE_SKIP_WORKTREE);\n \t\t/*\n \t\t * Needs to be checked before !changed returns early,\n \t\t * as the possibly empty directory was not changed\ndiff --git a/submodule.c b/submodule.c\nindex 6587bc0d84..43997f237e 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -191,7 +191,7 @@ void gitmodules_config(void)\n \t\t} else if (pos < the_index.cache_nr) {\n \t\t\tstruct stat st;\n \t\t\tif (lstat(\".gitmodules\", &st) == 0 &&\n-\t\t\t    ce_match_stat(the_index.cache[pos], &st, 0) & DATA_CHANGED)\n+\t\t\t    ie_match_stat(&the_index, the_index.cache[pos], &st, 0) & DATA_CHANGED)\n \t\t\t\tgitmodules_is_modified = 1;\n \t\t}\n \n-- \n2.13.0.rc1.39.ga6db8bfa24\n\n"},{"id":"318588","messageId":"20170502222322.21055-25-sbeller@google.com","threadId":"45853","inReplyTo":"20170502222322.21055-1-sbeller@google.com","subject":"[PATCH 24/24] cache.h: retire NO_THE_INDEX_COMPATIBILITY_MACROS","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-05-02T22:23:22Z","receivedAt":"2017-05-02T22:24:32Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"The NO_THE_INDEX_COMPATIBILITY_MACROS pre processor setting was introduced\nin 4aab5b46f4 (Make read-cache.c \"the_index\" free., 2007-04-01), stating:\n\n    This makes all low-level functions defined in read-cache.c to\n    take an explicit index_state structure as their first parameter,\n    to specify which index to work on.\n\nThe reasoning is very vague, maybe indicating that having the index\nspecified to work on is easier to for the new reader to understand what\nis going on.\n\nAll preceding patches worked on retiring functions that do not take an\nexplicit index as to where to perform its work. Spelling out the reasons\nwhy we want to specify the index at each call:\n\n1)  Ease of understanding:\n   The recent patches dropped a lot of macros that may confuse new people\n   diving into the code base.\n2a) Spelling out global state explicitly:\n   Anything you do in submodule land today needs to spawn new processes in\n   the submodule. This is cumbersome and not performant. So we may want to\n   have an abstraction of a repo, i.e. all repository state in one struct.\n   That way we can open a submodule in-process and perform the required\n   actions without spawning a process. The road to this future is a long\n   road, and we have to start somewhere. Exposing the global state seems\n   like a good starter point.\n2b) Spelling out global state explicitly (II): (Jeff Hostetler wrote)\n   In addition to (eventually) allowing multiple repos be open at the same\n   time for submodules, it would also help with various multi-threading\n   efforts.  For example, we have loops that do a\n   \"for (k = 0, k < active_nr; k++) {...}\"  There is no visual clue in that\n   code that it references \"the_index\" and therefore should be subject to\n   the same locking.  Granted, this is a trivial example, but goes to the\n   argument that the code has lots of subtle global variables and macros\n   that make it difficult to reason about the code.\n\n   This step would help un-hide this.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n attr.c         | 1 -\n cache.h        | 4 ----\n name-hash.c    | 1 -\n read-cache.c   | 1 -\n unpack-trees.c | 1 -\n 5 files changed, 8 deletions(-)\n\ndiff --git a/attr.c b/attr.c\nindex 7e2134471c..3decf432b8 100644\n--- a/attr.c\n+++ b/attr.c\n@@ -7,7 +7,6 @@\n  * an insanely large number of attributes.\n  */\n \n-#define NO_THE_INDEX_COMPATIBILITY_MACROS\n #include \"cache.h\"\n #include \"exec_cmd.h\"\n #include \"attr.h\"\ndiff --git a/cache.h b/cache.h\nindex f2a45eda9a..f4b7b8621c 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -352,10 +352,6 @@ extern void add_name_hash(struct index_state *istate, struct cache_entry *ce);\n extern void remove_name_hash(struct index_state *istate, struct cache_entry *ce);\n extern void free_name_hash(struct index_state *istate);\n \n-\n-#ifndef NO_THE_INDEX_COMPATIBILITY_MACROS\n-#endif\n-\n enum object_type {\n \tOBJ_BAD = -1,\n \tOBJ_NONE = 0,\ndiff --git a/name-hash.c b/name-hash.c\nindex 39309efb7f..02870c1d19 100644\n--- a/name-hash.c\n+++ b/name-hash.c\n@@ -5,7 +5,6 @@\n  *\n  * Copyright (C) 2008 Linus Torvalds\n  */\n-#define NO_THE_INDEX_COMPATIBILITY_MACROS\n #include \"cache.h\"\n \n struct dir_entry {\ndiff --git a/read-cache.c b/read-cache.c\nindex 6681376f5b..e0c6f3ca11 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -3,7 +3,6 @@\n  *\n  * Copyright (C) Linus Torvalds, 2005\n  */\n-#define NO_THE_INDEX_COMPATIBILITY_MACROS\n #include \"cache.h\"\n #include \"tempfile.h\"\n #include \"lockfile.h\"\ndiff --git a/unpack-trees.c b/unpack-trees.c\nindex 3dd8f60fc1..41956c4b37 100644\n--- a/unpack-trees.c\n+++ b/unpack-trees.c\n@@ -1,4 +1,3 @@\n-#define NO_THE_INDEX_COMPATIBILITY_MACROS\n #include \"cache.h\"\n #include \"dir.h\"\n #include \"tree.h\"\n-- \n2.13.0.rc1.39.ga6db8bfa24\n\n"},{"id":"318589","messageId":"20170502222322.21055-22-sbeller@google.com","threadId":"45853","inReplyTo":"20170502222322.21055-1-sbeller@google.com","subject":"[PATCH 21/24] cache.h: drop refresh_cache","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-05-02T22:23:19Z","receivedAt":"2017-05-02T22:24:34Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"coccinelle patch:\n@@ expression flags; @@\n-refresh_cache(flags)\n+refresh_index(&the_index, flags, NULL, NULL, NULL)\n\nAdditionally drop the define from cache.h manually.\n\nThis is a commit where I think the macro expansion is maybe silly, but\nfor reasons outlined in the first patch of the series, we still follow\nthrough.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n builtin/am.c           | 4 ++--\n builtin/checkout.c     | 2 +-\n builtin/commit.c       | 6 +++---\n builtin/diff.c         | 3 ++-\n builtin/merge.c        | 8 ++++----\n builtin/update-index.c | 3 ++-\n cache.h                | 1 -\n merge.c                | 2 +-\n wt-status.c            | 2 +-\n 9 files changed, 16 insertions(+), 15 deletions(-)\n\ndiff --git a/builtin/am.c b/builtin/am.c\nindex 38fc4566f7..a7388ec4e0 100644\n--- a/builtin/am.c\n+++ b/builtin/am.c\n@@ -1122,7 +1122,7 @@ static void refresh_and_write_cache(void)\n \tstruct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));\n \n \thold_locked_index(lock_file, LOCK_DIE_ON_ERROR);\n-\trefresh_cache(REFRESH_QUIET);\n+\trefresh_index(&the_index, REFRESH_QUIET, NULL, NULL, NULL);\n \tif (write_locked_index(&the_index, lock_file, COMMIT_LOCK))\n \t\tdie(_(\"unable to write index file\"));\n }\n@@ -1977,7 +1977,7 @@ static int fast_forward_to(struct tree *head, struct tree *remote, int reset)\n \tlock_file = xcalloc(1, sizeof(struct lock_file));\n \thold_locked_index(lock_file, LOCK_DIE_ON_ERROR);\n \n-\trefresh_cache(REFRESH_QUIET);\n+\trefresh_index(&the_index, REFRESH_QUIET, NULL, NULL, NULL);\n \n \tmemset(&opts, 0, sizeof(opts));\n \topts.head_idx = 1;\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex 34ec9f7e32..49a8b3a7ff 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -509,7 +509,7 @@ static int merge_working_tree(const struct checkout_opts *opts,\n \n \t\tsetup_unpack_trees_porcelain(&topts, \"checkout\");\n \n-\t\trefresh_cache(REFRESH_QUIET);\n+\t\trefresh_index(&the_index, REFRESH_QUIET, NULL, NULL, NULL);\n \n \t\tif (unmerged_index(&the_index)) {\n \t\t\terror(_(\"you need to resolve your current index first\"));\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex ac4fe97d36..4b95ff181b 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -328,7 +328,7 @@ static void refresh_cache_or_die(int refresh_flags)\n \t * refresh_flags contains REFRESH_QUIET, so the only errors\n \t * are for unmerged entries.\n \t */\n-\tif (refresh_cache(refresh_flags | REFRESH_IN_PORCELAIN))\n+\tif (refresh_index(&the_index, refresh_flags | REFRESH_IN_PORCELAIN, NULL, NULL, NULL))\n \t\tdie_resolve_conflict(\"commit\");\n }\n \n@@ -470,7 +470,7 @@ static const char *prepare_index(int argc, const char **argv, const char *prefix\n \n \thold_locked_index(&index_lock, LOCK_DIE_ON_ERROR);\n \tadd_remove_files(&partial);\n-\trefresh_cache(REFRESH_QUIET);\n+\trefresh_index(&the_index, REFRESH_QUIET, NULL, NULL, NULL);\n \tupdate_main_cache_tree(WRITE_TREE_SILENT);\n \tif (write_locked_index(&the_index, &index_lock, CLOSE_LOCK))\n \t\tdie(_(\"unable to write new_index file\"));\n@@ -482,7 +482,7 @@ static const char *prepare_index(int argc, const char **argv, const char *prefix\n \n \tcreate_base_index(current_head);\n \tadd_remove_files(&partial);\n-\trefresh_cache(REFRESH_QUIET);\n+\trefresh_index(&the_index, REFRESH_QUIET, NULL, NULL, NULL);\n \n \tif (write_locked_index(&the_index, &false_lock, CLOSE_LOCK))\n \t\tdie(_(\"unable to write temporary index file\"));\ndiff --git a/builtin/diff.c b/builtin/diff.c\nindex 1efd0d6b61..b11b94b214 100644\n--- a/builtin/diff.c\n+++ b/builtin/diff.c\n@@ -211,7 +211,8 @@ static void refresh_index_quietly(void)\n \t\treturn;\n \tdiscard_index(&the_index);\n \tread_index(&the_index);\n-\trefresh_cache(REFRESH_QUIET|REFRESH_UNMERGED);\n+\trefresh_index(&the_index, REFRESH_QUIET | REFRESH_UNMERGED, NULL,\n+\t\t      NULL, NULL);\n \tupdate_index_if_able(&the_index, lock_file);\n }\n \ndiff --git a/builtin/merge.c b/builtin/merge.c\nindex b023107d26..4e219cb9e8 100644\n--- a/builtin/merge.c\n+++ b/builtin/merge.c\n@@ -324,7 +324,7 @@ static void restore_state(const struct object_id *head,\n \trun_command_v_opt(args, RUN_GIT_CMD);\n \n \tstrbuf_release(&sb);\n-\trefresh_cache(REFRESH_QUIET);\n+\trefresh_index(&the_index, REFRESH_QUIET, NULL, NULL, NULL);\n }\n \n /* This is called when no merge was necessary. */\n@@ -639,7 +639,7 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,\n \tconst char *head_arg = \"HEAD\";\n \n \thold_locked_index(&lock, LOCK_DIE_ON_ERROR);\n-\trefresh_cache(REFRESH_QUIET);\n+\trefresh_index(&the_index, REFRESH_QUIET, NULL, NULL, NULL);\n \tif (the_index.cache_changed &&\n \t    write_locked_index(&the_index, &lock, COMMIT_LOCK))\n \t\treturn error(_(\"Unable to write index.\"));\n@@ -786,7 +786,7 @@ static int merge_trivial(struct commit *head, struct commit_list *remoteheads)\n \tstatic struct lock_file lock;\n \n \thold_locked_index(&lock, LOCK_DIE_ON_ERROR);\n-\trefresh_cache(REFRESH_QUIET);\n+\trefresh_index(&the_index, REFRESH_QUIET, NULL, NULL, NULL);\n \tif (the_index.cache_changed &&\n \t    write_locked_index(&the_index, &lock, COMMIT_LOCK))\n \t\treturn error(_(\"Unable to write index.\"));\n@@ -1393,7 +1393,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)\n \t\t * We are not doing octopus, not fast-forward, and have\n \t\t * only one common.\n \t\t */\n-\t\trefresh_cache(REFRESH_QUIET);\n+\t\trefresh_index(&the_index, REFRESH_QUIET, NULL, NULL, NULL);\n \t\tif (allow_trivial && fast_forward != FF_ONLY) {\n \t\t\t/* See if it is really trivial. */\n \t\t\tgit_committer_info(IDENT_STRICT);\ndiff --git a/builtin/update-index.c b/builtin/update-index.c\nindex f1c52a5531..9cbd346f95 100644\n--- a/builtin/update-index.c\n+++ b/builtin/update-index.c\n@@ -767,7 +767,8 @@ static int refresh(struct refresh_params *o, unsigned int flag)\n {\n \tsetup_work_tree();\n \tread_index_preload(&the_index, NULL);\n-\t*o->has_errors |= refresh_cache(o->flags | flag);\n+\t*o->has_errors |= refresh_index(&the_index, o->flags | flag, NULL,\n+\t\t\t\t\tNULL, NULL);\n \treturn 0;\n }\n \ndiff --git a/cache.h b/cache.h\nindex 07ad23d912..23c9c1697c 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -354,7 +354,6 @@ extern void free_name_hash(struct index_state *istate);\n \n \n #ifndef NO_THE_INDEX_COMPATIBILITY_MACROS\n-#define refresh_cache(flags) refresh_index(&the_index, (flags), NULL, NULL, NULL)\n #define ce_match_stat(ce, st, options) ie_match_stat(&the_index, (ce), (st), (options))\n #define ce_modified(ce, st, options) ie_modified(&the_index, (ce), (st), (options))\n #endif\ndiff --git a/merge.c b/merge.c\nindex e1f93e9714..2e468b507d 100644\n--- a/merge.c\n+++ b/merge.c\n@@ -55,7 +55,7 @@ int checkout_fast_forward(const unsigned char *head,\n \tstruct dir_struct dir;\n \tstruct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));\n \n-\trefresh_cache(REFRESH_QUIET);\n+\trefresh_index(&the_index, REFRESH_QUIET, NULL, NULL, NULL);\n \n \tif (hold_locked_index(lock_file, LOCK_REPORT_ON_ERROR) < 0)\n \t\treturn -1;\ndiff --git a/wt-status.c b/wt-status.c\nindex 59cdf09a07..1c5dcd172e 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -2270,7 +2270,7 @@ int require_clean_work_tree(const char *action, const char *hint, int ignore_sub\n \tint err = 0, fd;\n \n \tfd = hold_locked_index(lock_file, 0);\n-\trefresh_cache(REFRESH_QUIET);\n+\trefresh_index(&the_index, REFRESH_QUIET, NULL, NULL, NULL);\n \tif (0 <= fd)\n \t\tupdate_index_if_able(&the_index, lock_file);\n \trollback_lock_file(lock_file);\n-- \n2.13.0.rc1.39.ga6db8bfa24\n\n"},{"id":"318590","messageId":"20170502222322.21055-20-sbeller@google.com","threadId":"45853","inReplyTo":"20170502222322.21055-1-sbeller@google.com","subject":"[PATCH 19/24] cache.h: drop add_file_to_cache","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-05-02T22:23:17Z","receivedAt":"2017-05-02T22:24:35Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Signed-off-by: Stefan Beller <sbeller@google.com>\n---\n cache.h     | 1 -\n rerere.c    | 2 +-\n submodule.c | 2 +-\n 3 files changed, 2 insertions(+), 3 deletions(-)\n\ndiff --git a/cache.h b/cache.h\nindex bc49defc27..a9b059913e 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -354,7 +354,6 @@ extern void free_name_hash(struct index_state *istate);\n \n \n #ifndef NO_THE_INDEX_COMPATIBILITY_MACROS\n-#define add_file_to_cache(path, flags) add_file_to_index(&the_index, (path), (flags))\n #define chmod_cache_entry(ce, flip) chmod_index_entry(&the_index, (ce), (flip))\n #define refresh_cache(flags) refresh_index(&the_index, (flags), NULL, NULL, NULL)\n #define ce_match_stat(ce, st, options) ie_match_stat(&the_index, (ce), (st), (options))\ndiff --git a/rerere.c b/rerere.c\nindex b6d84b8461..0ada0ef247 100644\n--- a/rerere.c\n+++ b/rerere.c\n@@ -712,7 +712,7 @@ static void update_paths(struct string_list *update)\n \n \tfor (i = 0; i < update->nr; i++) {\n \t\tstruct string_list_item *item = &update->items[i];\n-\t\tif (add_file_to_cache(item->string, 0))\n+\t\tif (add_file_to_index(&the_index, item->string, 0))\n \t\t\texit(128);\n \t\tfprintf(stderr, \"Staged '%s' using previous resolution.\\n\",\n \t\t\titem->string);\ndiff --git a/submodule.c b/submodule.c\nindex 148194831d..6587bc0d84 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -119,7 +119,7 @@ int remove_path_from_gitmodules(const char *path)\n \n void stage_updated_gitmodules(void)\n {\n-\tif (add_file_to_cache(\".gitmodules\", 0))\n+\tif (add_file_to_index(&the_index, \".gitmodules\", 0))\n \t\tdie(_(\"staging updated .gitmodules failed\"));\n }\n \n-- \n2.13.0.rc1.39.ga6db8bfa24\n\n"},{"id":"318591","messageId":"20170502222322.21055-19-sbeller@google.com","threadId":"45853","inReplyTo":"20170502222322.21055-1-sbeller@google.com","subject":"[PATCH 18/24] cache.h: drop add_to_cache","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-05-02T22:23:16Z","receivedAt":"2017-05-02T22:24:38Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Signed-off-by: Stefan Beller <sbeller@google.com>\n---\n builtin/commit.c | 2 +-\n cache.h          | 1 -\n 2 files changed, 1 insertion(+), 2 deletions(-)\n\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex fa962c4f86..ac4fe97d36 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -287,7 +287,7 @@ static void add_remove_files(struct string_list *list)\n \t\t\tcontinue;\n \n \t\tif (!lstat(p->string, &st)) {\n-\t\t\tif (add_to_cache(p->string, &st, 0))\n+\t\t\tif (add_to_index(&the_index, p->string, &st, 0))\n \t\t\t\tdie(_(\"updating files failed\"));\n \t\t} else\n \t\t\tremove_file_from_index(&the_index, p->string);\ndiff --git a/cache.h b/cache.h\nindex 88c6f8a7df..bc49defc27 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -354,7 +354,6 @@ extern void free_name_hash(struct index_state *istate);\n \n \n #ifndef NO_THE_INDEX_COMPATIBILITY_MACROS\n-#define add_to_cache(path, st, flags) add_to_index(&the_index, (path), (st), (flags))\n #define add_file_to_cache(path, flags) add_file_to_index(&the_index, (path), (flags))\n #define chmod_cache_entry(ce, flip) chmod_index_entry(&the_index, (ce), (flip))\n #define refresh_cache(flags) refresh_index(&the_index, (flags), NULL, NULL, NULL)\n-- \n2.13.0.rc1.39.ga6db8bfa24\n\n"},{"id":"318592","messageId":"20170502222322.21055-18-sbeller@google.com","threadId":"45853","inReplyTo":"20170502222322.21055-1-sbeller@google.com","subject":"[PATCH 17/24] cache.h: drop remove_file_from_cache","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-05-02T22:23:15Z","receivedAt":"2017-05-02T22:24:40Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"coccinelle patch:\n@@ expression path; @@\n-remove_file_from_cache(path)\n+remove_file_from_index(&the_index, path)\n\nAdditionally drop the define from cache.h manually.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n apply.c                |  4 ++--\n builtin/commit.c       |  2 +-\n builtin/reset.c        |  2 +-\n builtin/rm.c           |  2 +-\n builtin/update-index.c | 10 +++++-----\n cache.h                |  1 -\n merge-recursive.c      | 16 ++++++++--------\n 7 files changed, 18 insertions(+), 19 deletions(-)\n\ndiff --git a/apply.c b/apply.c\nindex 66d4969e72..8a61f19d03 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -4230,7 +4230,7 @@ static int build_fake_ancestor(struct apply_state *state, struct patch *list)\n  static int remove_file(struct apply_state *state, struct patch *patch, int rmdir_empty)\n  {\n \t if (state->update_index) {\n-\t\t if (remove_file_from_cache(patch->old_name) < 0)\n+\t\t if (remove_file_from_index(&the_index, patch->old_name) < 0)\n \t\t\t return error(_(\"unable to remove %s from index\"), patch->old_name);\n \t }\n \t if (!state->cached) {\n@@ -4418,7 +4418,7 @@ static int add_conflicted_stages_file(struct apply_state *state,\n \tce_size = cache_entry_size(namelen);\n \tmode = patch->new_mode ? patch->new_mode : (S_IFREG | 0644);\n \n-\tremove_file_from_cache(patch->new_name);\n+\tremove_file_from_index(&the_index, patch->new_name);\n \tfor (stage = 1; stage < 4; stage++) {\n \t\tif (is_null_oid(&patch->threeway_stage[stage - 1]))\n \t\t\tcontinue;\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex ef12ea3991..fa962c4f86 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -290,7 +290,7 @@ static void add_remove_files(struct string_list *list)\n \t\t\tif (add_to_cache(p->string, &st, 0))\n \t\t\t\tdie(_(\"updating files failed\"));\n \t\t} else\n-\t\t\tremove_file_from_cache(p->string);\n+\t\t\tremove_file_from_index(&the_index, p->string);\n \t}\n }\n \ndiff --git a/builtin/reset.c b/builtin/reset.c\nindex 0e19d6e8d5..90c56b46f2 100644\n--- a/builtin/reset.c\n+++ b/builtin/reset.c\n@@ -125,7 +125,7 @@ static void update_index_from_diff(struct diff_queue_struct *q,\n \t\tstruct cache_entry *ce;\n \n \t\tif (is_missing && !intent_to_add) {\n-\t\t\tremove_file_from_cache(one->path);\n+\t\t\tremove_file_from_index(&the_index, one->path);\n \t\t\tcontinue;\n \t\t}\n \ndiff --git a/builtin/rm.c b/builtin/rm.c\nindex c77c941ef0..f479100298 100644\n--- a/builtin/rm.c\n+++ b/builtin/rm.c\n@@ -343,7 +343,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)\n \t\tif (!quiet)\n \t\t\tprintf(\"rm '%s'\\n\", path);\n \n-\t\tif (remove_file_from_cache(path))\n+\t\tif (remove_file_from_index(&the_index, path))\n \t\t\tdie(_(\"git rm: unable to remove %s\"), path);\n \t}\n \ndiff --git a/builtin/update-index.c b/builtin/update-index.c\nindex e0738f74bf..8c4911e920 100644\n--- a/builtin/update-index.c\n+++ b/builtin/update-index.c\n@@ -243,7 +243,7 @@ static int remove_one_path(const char *path)\n {\n \tif (!allow_remove)\n \t\treturn error(\"%s: does not exist and --remove not passed\", path);\n-\tif (remove_file_from_cache(path))\n+\tif (remove_file_from_index(&the_index, path))\n \t\treturn error(\"%s: cannot remove from the index\", path);\n \treturn 0;\n }\n@@ -376,7 +376,7 @@ static int process_path(const char *path)\n \t\t * so updating it does not make sense.\n \t\t * On the other hand, removing it from index should work\n \t\t */\n-\t\tif (allow_remove && remove_file_from_cache(path))\n+\t\tif (allow_remove && remove_file_from_index(&the_index, path))\n \t\t\treturn error(\"%s: cannot remove from the index\", path);\n \t\treturn 0;\n \t}\n@@ -459,7 +459,7 @@ static void update_one(const char *path)\n \t}\n \n \tif (force_remove) {\n-\t\tif (remove_file_from_cache(path))\n+\t\tif (remove_file_from_index(&the_index, path))\n \t\t\tdie(\"git update-index: unable to remove %s\", path);\n \t\treport(\"remove '%s'\", path);\n \t\treturn;\n@@ -541,7 +541,7 @@ static void read_index_info(int nul_term_line)\n \n \t\tif (!mode) {\n \t\t\t/* mode == 0 means there is no such path -- remove */\n-\t\t\tif (remove_file_from_cache(path_name))\n+\t\t\tif (remove_file_from_index(&the_index, path_name))\n \t\t\t\tdie(\"git update-index: unable to remove %s\",\n \t\t\t\t    ptr);\n \t\t}\n@@ -658,7 +658,7 @@ static int unresolve_one(const char *path)\n \t\tgoto free_return;\n \t}\n \n-\tremove_file_from_cache(path);\n+\tremove_file_from_index(&the_index, path);\n \tif (add_index_entry(&the_index, ce_2, ADD_CACHE_OK_TO_ADD)) {\n \t\terror(\"%s: cannot add our version to the index.\", path);\n \t\tret = -1;\ndiff --git a/cache.h b/cache.h\nindex 4c12ff265e..88c6f8a7df 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -354,7 +354,6 @@ extern void free_name_hash(struct index_state *istate);\n \n \n #ifndef NO_THE_INDEX_COMPATIBILITY_MACROS\n-#define remove_file_from_cache(path) remove_file_from_index(&the_index, (path))\n #define add_to_cache(path, st, flags) add_to_index(&the_index, (path), (st), (flags))\n #define add_file_to_cache(path, flags) add_file_to_index(&the_index, (path), (flags))\n #define chmod_cache_entry(ce, flip) chmod_index_entry(&the_index, (ce), (flip))\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 6420dc1951..c5bf1fb6a2 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -582,7 +582,7 @@ static int update_stages(struct merge_options *opt, const char *path,\n \tint clear = 1;\n \tint options = ADD_CACHE_OK_TO_ADD | ADD_CACHE_SKIP_DFCHECK;\n \tif (clear)\n-\t\tif (remove_file_from_cache(path))\n+\t\tif (remove_file_from_index(&the_index, path))\n \t\t\treturn -1;\n \tif (o)\n \t\tif (add_cacheinfo(opt, o->mode, &o->oid, path, 1, 0, options))\n@@ -617,7 +617,7 @@ static int remove_file(struct merge_options *o, int clean,\n \tint update_working_directory = !o->call_depth && !no_wd;\n \n \tif (update_cache) {\n-\t\tif (remove_file_from_cache(path))\n+\t\tif (remove_file_from_index(&the_index, path))\n \t\t\treturn -1;\n \t}\n \tif (update_working_directory) {\n@@ -1084,7 +1084,7 @@ static int handle_change_delete(struct merge_options *o,\n \t\t * correct; since there is no true \"middle point\" between\n \t\t * them, simply reuse the base version for virtual merge base.\n \t\t */\n-\t\tret = remove_file_from_cache(path);\n+\t\tret = remove_file_from_index(&the_index, path);\n \t\tif (!ret)\n \t\t\tret = update_file(o, 0, o_oid, o_mode, update_path);\n \t} else {\n@@ -1145,7 +1145,7 @@ static int conflict_rename_delete(struct merge_options *o,\n \t\treturn -1;\n \n \tif (o->call_depth)\n-\t\treturn remove_file_from_cache(dest->path);\n+\t\treturn remove_file_from_index(&the_index, dest->path);\n \telse\n \t\treturn update_stages(o, dest->path, NULL,\n \t\t\t\t     rename_branch == o->branch1 ? dest : NULL,\n@@ -1263,14 +1263,14 @@ static int conflict_rename_rename_1to2(struct merge_options *o,\n \t\t\t\treturn -1;\n \t\t}\n \t\telse\n-\t\t\tremove_file_from_cache(a->path);\n+\t\t\tremove_file_from_index(&the_index, a->path);\n \t\tadd = filespec_from_entry(&other, ci->dst_entry2, 3 ^ 1);\n \t\tif (add) {\n \t\t\tif (update_file(o, 0, &add->oid, add->mode, b->path))\n \t\t\t\treturn -1;\n \t\t}\n \t\telse\n-\t\t\tremove_file_from_cache(b->path);\n+\t\t\tremove_file_from_index(&the_index, b->path);\n \t} else if (handle_file(o, a, 2, ci) || handle_file(o, b, 3, ci))\n \t\treturn -1;\n \n@@ -1759,7 +1759,7 @@ static int merge_content(struct merge_options *o,\n \tif (df_conflict_remains) {\n \t\tchar *new_path;\n \t\tif (o->call_depth) {\n-\t\t\tremove_file_from_cache(path);\n+\t\t\tremove_file_from_index(&the_index, path);\n \t\t} else {\n \t\t\tif (!mfi.clean) {\n \t\t\t\tif (update_stages(o, path, &one, &a, &b))\n@@ -1887,7 +1887,7 @@ static int process_entry(struct merge_options *o,\n \t\t\tif (update_file(o, 0, oid, mode, new_path))\n \t\t\t\tclean_merge = -1;\n \t\t\telse if (o->call_depth)\n-\t\t\t\tremove_file_from_cache(path);\n+\t\t\t\tremove_file_from_index(&the_index, path);\n \t\t\tfree(new_path);\n \t\t} else {\n \t\t\toutput(o, 2, _(\"Adding %s\"), path);\n-- \n2.13.0.rc1.39.ga6db8bfa24\n\n"},{"id":"318593","messageId":"20170502222322.21055-17-sbeller@google.com","threadId":"45853","inReplyTo":"20170502222322.21055-1-sbeller@google.com","subject":"[PATCH 16/24] cache.h: drop rename_cache_entry_at","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-05-02T22:23:14Z","receivedAt":"2017-05-02T22:24:42Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"One define was unused, the other occurs just once. Easy patch.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n builtin/mv.c | 2 +-\n cache.h      | 2 --\n 2 files changed, 1 insertion(+), 3 deletions(-)\n\ndiff --git a/builtin/mv.c b/builtin/mv.c\nindex 40e40bb098..1a3c61994c 100644\n--- a/builtin/mv.c\n+++ b/builtin/mv.c\n@@ -287,7 +287,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)\n \t\tpos = index_name_pos(&the_index, src, strlen(src));\n \t\tassert(pos >= 0);\n \t\tif (!show_only)\n-\t\t\trename_cache_entry_at(pos, dst);\n+\t\t\trename_index_entry_at(&the_index, pos, dst);\n \t}\n \n \tif (gitmodules_modified)\ndiff --git a/cache.h b/cache.h\nindex 54c1bbf0d1..4c12ff265e 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -354,8 +354,6 @@ extern void free_name_hash(struct index_state *istate);\n \n \n #ifndef NO_THE_INDEX_COMPATIBILITY_MACROS\n-#define rename_cache_entry_at(pos, new_name) rename_index_entry_at(&the_index, (pos), (new_name))\n-#define remove_cache_entry_at(pos) remove_index_entry_at(&the_index, (pos))\n #define remove_file_from_cache(path) remove_file_from_index(&the_index, (path))\n #define add_to_cache(path, st, flags) add_to_index(&the_index, (path), (st), (flags))\n #define add_file_to_cache(path, flags) add_file_to_index(&the_index, (path), (flags))\n-- \n2.13.0.rc1.39.ga6db8bfa24\n\n"},{"id":"318594","messageId":"20170502222322.21055-16-sbeller@google.com","threadId":"45853","inReplyTo":"20170502222322.21055-1-sbeller@google.com","subject":"[PATCH 15/24] cache.h: drop add_cache_entry","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-05-02T22:23:13Z","receivedAt":"2017-05-02T22:24:45Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"coccinelle patch\n-add_cache_entry(ce, option)\n+add_index_entry(&the_index, ce, option)\n\nAdditionally drop the define from cache.h manually.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n apply.c                | 4 ++--\n builtin/blame.c        | 3 ++-\n builtin/checkout.c     | 3 ++-\n builtin/reset.c        | 3 ++-\n builtin/update-index.c | 8 ++++----\n cache.h                | 1 -\n merge-recursive.c      | 4 ++--\n tree.c                 | 2 +-\n 8 files changed, 15 insertions(+), 13 deletions(-)\n\ndiff --git a/apply.c b/apply.c\nindex bb1cd77c66..66d4969e72 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -4284,7 +4284,7 @@ static int build_fake_ancestor(struct apply_state *state, struct patch *list)\n \t\t\t\t       \"for newly created file %s\"), path);\n \t\t}\n \t}\n-\tif (add_cache_entry(ce, ADD_CACHE_OK_TO_ADD) < 0) {\n+\tif (add_index_entry(&the_index, ce, ADD_CACHE_OK_TO_ADD) < 0) {\n \t\tfree(ce);\n \t\treturn error(_(\"unable to add cache entry for %s\"), path);\n \t}\n@@ -4428,7 +4428,7 @@ static int add_conflicted_stages_file(struct apply_state *state,\n \t\tce->ce_flags = create_ce_flags(stage);\n \t\tce->ce_namelen = namelen;\n \t\toidcpy(&ce->oid, &patch->threeway_stage[stage - 1]);\n-\t\tif (add_cache_entry(ce, ADD_CACHE_OK_TO_ADD) < 0) {\n+\t\tif (add_index_entry(&the_index, ce, ADD_CACHE_OK_TO_ADD) < 0) {\n \t\t\tfree(ce);\n \t\t\treturn error(_(\"unable to add cache entry for %s\"),\n \t\t\t\t     patch->new_name);\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex c71d9a3340..5140015cc0 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -2413,7 +2413,8 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,\n \tce->ce_flags = create_ce_flags(0);\n \tce->ce_namelen = len;\n \tce->ce_mode = create_ce_mode(mode);\n-\tadd_cache_entry(ce, ADD_CACHE_OK_TO_ADD|ADD_CACHE_OK_TO_REPLACE);\n+\tadd_index_entry(&the_index, ce,\n+\t\t\tADD_CACHE_OK_TO_ADD | ADD_CACHE_OK_TO_REPLACE);\n \n \tcache_tree_invalidate_path(&the_index, path);\n \ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex 039d3d296b..34ec9f7e32 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -118,7 +118,8 @@ static int update_some(const unsigned char *sha1, struct strbuf *base,\n \t\t}\n \t}\n \n-\tadd_cache_entry(ce, ADD_CACHE_OK_TO_ADD | ADD_CACHE_OK_TO_REPLACE);\n+\tadd_index_entry(&the_index, ce,\n+\t\t\tADD_CACHE_OK_TO_ADD | ADD_CACHE_OK_TO_REPLACE);\n \treturn 0;\n }\n \ndiff --git a/builtin/reset.c b/builtin/reset.c\nindex f8073b1caa..0e19d6e8d5 100644\n--- a/builtin/reset.c\n+++ b/builtin/reset.c\n@@ -138,7 +138,8 @@ static void update_index_from_diff(struct diff_queue_struct *q,\n \t\t\tce->ce_flags |= CE_INTENT_TO_ADD;\n \t\t\tset_object_name_for_intent_to_add_entry(ce);\n \t\t}\n-\t\tadd_cache_entry(ce, ADD_CACHE_OK_TO_ADD | ADD_CACHE_OK_TO_REPLACE);\n+\t\tadd_index_entry(&the_index, ce,\n+\t\t\t\tADD_CACHE_OK_TO_ADD | ADD_CACHE_OK_TO_REPLACE);\n \t}\n }\n \ndiff --git a/builtin/update-index.c b/builtin/update-index.c\nindex d7a117c674..e0738f74bf 100644\n--- a/builtin/update-index.c\n+++ b/builtin/update-index.c\n@@ -286,7 +286,7 @@ static int add_one_path(const struct cache_entry *old, const char *path, int len\n \t}\n \toption = allow_add ? ADD_CACHE_OK_TO_ADD : 0;\n \toption |= allow_replace ? ADD_CACHE_OK_TO_REPLACE : 0;\n-\tif (add_cache_entry(ce, option))\n+\tif (add_index_entry(&the_index, ce, option))\n \t\treturn error(\"%s: cannot add to the index - missing --add option?\", path);\n \treturn 0;\n }\n@@ -416,7 +416,7 @@ static int add_cacheinfo(unsigned int mode, const struct object_id *oid,\n \t\tce->ce_flags |= CE_VALID;\n \toption = allow_add ? ADD_CACHE_OK_TO_ADD : 0;\n \toption |= allow_replace ? ADD_CACHE_OK_TO_REPLACE : 0;\n-\tif (add_cache_entry(ce, option))\n+\tif (add_index_entry(&the_index, ce, option))\n \t\treturn error(\"%s: cannot add to the index - missing --add option?\",\n \t\t\t     path);\n \treport(\"add '%s'\", path);\n@@ -659,12 +659,12 @@ static int unresolve_one(const char *path)\n \t}\n \n \tremove_file_from_cache(path);\n-\tif (add_cache_entry(ce_2, ADD_CACHE_OK_TO_ADD)) {\n+\tif (add_index_entry(&the_index, ce_2, ADD_CACHE_OK_TO_ADD)) {\n \t\terror(\"%s: cannot add our version to the index.\", path);\n \t\tret = -1;\n \t\tgoto free_return;\n \t}\n-\tif (!add_cache_entry(ce_3, ADD_CACHE_OK_TO_ADD))\n+\tif (!add_index_entry(&the_index, ce_3, ADD_CACHE_OK_TO_ADD))\n \t\treturn 0;\n \terror(\"%s: cannot add their version to the index.\", path);\n \tret = -1;\ndiff --git a/cache.h b/cache.h\nindex a18ebf263a..54c1bbf0d1 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -354,7 +354,6 @@ extern void free_name_hash(struct index_state *istate);\n \n \n #ifndef NO_THE_INDEX_COMPATIBILITY_MACROS\n-#define add_cache_entry(ce, option) add_index_entry(&the_index, (ce), (option))\n #define rename_cache_entry_at(pos, new_name) rename_index_entry_at(&the_index, (pos), (new_name))\n #define remove_cache_entry_at(pos) remove_index_entry_at(&the_index, (pos))\n #define remove_file_from_cache(path) remove_file_from_index(&the_index, (path))\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 163d37866e..6420dc1951 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -230,7 +230,7 @@ static int add_cacheinfo(struct merge_options *o,\n \tif (!ce)\n \t\treturn err(o, _(\"addinfo_cache failed for path '%s'\"), path);\n \n-\tret = add_cache_entry(ce, options);\n+\tret = add_index_entry(&the_index, ce, options);\n \tif (refresh) {\n \t\tstruct cache_entry *nce;\n \n@@ -238,7 +238,7 @@ static int add_cacheinfo(struct merge_options *o,\n \t\tif (!nce)\n \t\t\treturn err(o, _(\"addinfo_cache failed for path '%s'\"), path);\n \t\tif (nce != ce)\n-\t\t\tret = add_cache_entry(nce, options);\n+\t\t\tret = add_index_entry(&the_index, nce, options);\n \t}\n \treturn ret;\n }\ndiff --git a/tree.c b/tree.c\nindex 82a6ae2a19..5f9a322ddd 100644\n--- a/tree.c\n+++ b/tree.c\n@@ -27,7 +27,7 @@ static int read_one_entry_opt(const unsigned char *sha1, const char *base, int b\n \tmemcpy(ce->name, base, baselen);\n \tmemcpy(ce->name + baselen, pathname, len+1);\n \thashcpy(ce->oid.hash, sha1);\n-\treturn add_cache_entry(ce, opt);\n+\treturn add_index_entry(&the_index, ce, opt);\n }\n \n static int read_one_entry(const unsigned char *sha1, struct strbuf *base,\n-- \n2.13.0.rc1.39.ga6db8bfa24\n\n"}]}