{"thread":{"id":"45843","subject":"[PATCH 0/5] Start of a journey: drop NO_THE_INDEX_COMPATIBILITY_MACROS","startedAt":"2017-05-01T19:08:03Z","lastAt":"2017-05-05T17:30:04Z","messageCount":25,"participants":["Stefan Beller","Junio C Hamano","Jeff Hostetler","Duy Nguyen","Samuel Lijin","Brandon Williams","Jonathan Nieder","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":5},"messages":[{"id":"318394","messageId":"20170501190719.10669-1-sbeller@google.com","threadId":"45843","inReplyTo":null,"subject":"[PATCH 0/5] Start of a journey: drop NO_THE_INDEX_COMPATIBILITY_MACROS","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-05-01T19:07:14Z","receivedAt":"2017-05-01T19:08:03Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"This applies to origin/master.\n\nFor better readability and understandability for newcomers it is a good idea\nto not offer 2 APIs doing the same thing with on being the #define of the other.\n\nIn the long run we may want to drop the macros guarded by\nNO_THE_INDEX_COMPATIBILITY_MACROS. This converts a couple of them.\n\nMy main reason for this patch is to try out coccinelle as well as a\ndiscussion I had off list about maintainability of software.\n\nI just made these patches and wonder if now is a good time to pull through and\nconvert the rest as well?\n\nThanks,\nStefan\n\nStefan Beller (5):\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\n apply.c                              | 10 +++----\n builtin/add.c                        | 10 +++----\n builtin/am.c                         | 14 +++++-----\n builtin/blame.c                      | 10 +++----\n builtin/check-attr.c                 |  2 +-\n builtin/check-ignore.c               |  4 +--\n builtin/checkout-index.c             | 10 +++----\n builtin/checkout.c                   | 53 ++++++++++++++++++------------------\n builtin/clean.c                      |  2 +-\n builtin/commit.c                     | 32 +++++++++++-----------\n builtin/describe.c                   |  2 +-\n builtin/diff-files.c                 |  4 +--\n builtin/diff-index.c                 |  6 ++--\n builtin/diff.c                       | 14 +++++-----\n builtin/fsck.c                       | 14 +++++-----\n builtin/grep.c                       | 10 +++----\n builtin/ls-files.c                   | 38 +++++++++++++-------------\n builtin/merge-index.c                | 12 ++++----\n builtin/merge.c                      | 14 +++++-----\n builtin/mv.c                         | 12 ++++----\n builtin/pull.c                       |  2 +-\n builtin/read-tree.c                  |  4 +--\n builtin/reset.c                      |  4 +--\n builtin/rev-parse.c                  |  2 +-\n builtin/rm.c                         | 18 ++++++------\n builtin/submodule--helper.c          | 10 +++----\n builtin/update-index.c               | 52 ++++++++++++++++++-----------------\n cache.h                              | 10 -------\n check-racy.c                         |  6 ++--\n diff-lib.c                           |  6 ++--\n diff.c                               | 10 +++----\n dir.c                                | 20 +++++++-------\n merge-recursive.c                    | 30 ++++++++++----------\n merge.c                              |  2 +-\n pathspec.c                           | 14 +++++-----\n read-cache.c                         |  4 +--\n rerere.c                             | 32 +++++++++++-----------\n revision.c                           | 22 +++++++--------\n sequencer.c                          | 27 +++++++++---------\n sha1_name.c                          | 16 +++++------\n submodule.c                          | 16 +++++------\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  | 10 +++----\n t/helper/test-read-cache.c           |  2 +-\n t/helper/test-scrap-cache-tree.c     |  4 +--\n t/t2107-update-index-basic.sh        |  2 +-\n tree.c                               |  8 +++---\n wt-status.c                          | 12 ++++----\n 49 files changed, 309 insertions(+), 315 deletions(-)\n\n-- \n2.13.0.rc1.1.gbc33f0f778\n\n"},{"id":"318395","messageId":"20170501190719.10669-2-sbeller@google.com","threadId":"45843","inReplyTo":"20170501190719.10669-1-sbeller@google.com","subject":"[PATCH 1/5] cache.h: drop read_cache()","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-05-01T19:07:15Z","receivedAt":"2017-05-01T19:08:15Z","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.1.gbc33f0f778\n\n"},{"id":"318396","messageId":"20170501190719.10669-3-sbeller@google.com","threadId":"45843","inReplyTo":"20170501190719.10669-1-sbeller@google.com","subject":"[PATCH 2/5] cache.h: drop active_* macros","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-05-01T19:07:16Z","receivedAt":"2017-05-01T19:08:26Z","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.1.gbc33f0f778\n\n"},{"id":"318397","messageId":"20170501190719.10669-4-sbeller@google.com","threadId":"45843","inReplyTo":"20170501190719.10669-1-sbeller@google.com","subject":"[PATCH 3/5] cache.h: drop read_cache_from","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-05-01T19:07:17Z","receivedAt":"2017-05-01T19:08:33Z","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.1.gbc33f0f778\n\n"},{"id":"318398","messageId":"20170501190719.10669-5-sbeller@google.com","threadId":"45843","inReplyTo":"20170501190719.10669-1-sbeller@google.com","subject":"[PATCH 4/5] cache.h: drop read_cache_preload(pathspec)","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-05-01T19:07:18Z","receivedAt":"2017-05-01T19:08:40Z","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.1.gbc33f0f778\n\n"},{"id":"318399","messageId":"20170501190719.10669-6-sbeller@google.com","threadId":"45843","inReplyTo":"20170501190719.10669-1-sbeller@google.com","subject":"[PATCH 5/5] cache.h: drop read_cache_unmerged()","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-05-01T19:07:19Z","receivedAt":"2017-05-01T19:08:45Z","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.1.gbc33f0f778\n\n"},{"id":"318448","messageId":"xmqq7f20f3a8.fsf@gitster.mtv.corp.google.com","threadId":"45843","inReplyTo":"20170501190719.10669-1-sbeller@google.com","subject":"Re: [PATCH 0/5] Start of a journey: drop NO_THE_INDEX_COMPATIBILITY_MACROS","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-05-02T01:36:31Z","receivedAt":"2017-05-02T01:36:37Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stefan Beller <sbeller@google.com> writes:\n\n> This applies to origin/master.\n>\n> For better readability and understandability for newcomers it is a good idea\n> to not offer 2 APIs doing the same thing with on being the #define of the other.\n>\n> In the long run we may want to drop the macros guarded by\n> NO_THE_INDEX_COMPATIBILITY_MACROS. This converts a couple of them.\n\nWhy?  Why should we keep typing &the_index, when most of the time we\nare given _the_ index and working on it?\n"},{"id":"318470","messageId":"CAGZ79kZkssTEdNyzYh1YYv89szvig=rn2j3DJcHxsbzdADRw-w@mail.gmail.com","threadId":"45843","inReplyTo":"xmqq7f20f3a8.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH 0/5] Start of a journey: drop NO_THE_INDEX_COMPATIBILITY_MACROS","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-05-02T04:17:44Z","receivedAt":"2017-05-02T04:17:51Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Mon, May 1, 2017 at 6:36 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Stefan Beller <sbeller@google.com> writes:\n>\n>> This applies to origin/master.\n>>\n>> For better readability and understandability for newcomers it is a good idea\n>> to not offer 2 APIs doing the same thing with on being the #define of the other.\n>>\n>> In the long run we may want to drop the macros guarded by\n>> NO_THE_INDEX_COMPATIBILITY_MACROS. This converts a couple of them.\n>\n> Why?  Why should we keep typing &the_index, when most of the time we\n> are given _the_ index and working on it?\n\nAs someone knowledgeable with the code base you know that the cache_*\nand index_* functions only differ by an index argument. A newcomer may not\nknow this, so they wonder why we have (A) so many functions [and which is the\nright function to use]; it is an issue of ease of use of the code base.\n\nAnything you do In submodule land today needs to spawn new processes in\nthe submodule. This is cumbersome and not performant. So in the far future\nwe may want to have an abstraction of a repo (B), i.e. all repository state in\none struct/class. That way we can open a submodule in-process and perform\nthe required actions without spawning a process.\n\nThe road to (B) is a long road, but we have to art somewhere. And this seemed\nlike a good place by introducing a dedicated argument for the\nrepository. In a follow\nup in the future we may want to replace &the_index by \"the_main_repo.its_index\"\nand then could also run the commands on other (submodule) indexes. But more\nimportantly, all these commands would operate on a repository object.\n\nIn such a far future we would have functions like the cmd_* functions\nthat would take a repository object instead of doing its setup discovery\non their own.\n\nAnother reason may be its current velocity (or absence of it) w.r.t. to these\nfunctions, such that fewer merge conflicts may arise.\n\n---\nThis discussion is similar to the \"free memory at the end of cmd_*\" discussion,\nas it aims to make code reusable, and accepting a minor drawback for it.\nTyping \"the_index\" re-enforces the object thinking model and may have people\nstart on thinking if they would like to declare yet another global variable.\n\nThanks,\nStefan\n"},{"id":"318501","messageId":"b2d1d2fe-1b9b-4afa-192f-267bbb5df487@jeffhostetler.com","threadId":"45843","inReplyTo":"CAGZ79kZkssTEdNyzYh1YYv89szvig=rn2j3DJcHxsbzdADRw-w@mail.gmail.com","subject":"Re: [PATCH 0/5] Start of a journey: drop NO_THE_INDEX_COMPATIBILITY_MACROS","fromName":"Jeff Hostetler","fromEmail":"git@jeffhostetler.com","sentAt":"2017-05-02T14:05:00Z","receivedAt":"2017-05-02T14:05:11Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"\n\nOn 5/2/2017 12:17 AM, Stefan Beller wrote:\n> On Mon, May 1, 2017 at 6:36 PM, Junio C Hamano <gitster@pobox.com> wrote:\n>> Stefan Beller <sbeller@google.com> writes:\n>>\n>>> This applies to origin/master.\n>>>\n>>> For better readability and understandability for newcomers it is a good idea\n>>> to not offer 2 APIs doing the same thing with on being the #define of the other.\n>>>\n>>> In the long run we may want to drop the macros guarded by\n>>> NO_THE_INDEX_COMPATIBILITY_MACROS. This converts a couple of them.\n\nThank you for bringing this up and making this proposal.\nI started a similar effort internally last fall, but\nstopped because of the footprint size.\n\n>>\n>> Why?  Why should we keep typing &the_index, when most of the time we\n>> are given _the_ index and working on it?\n>\n> As someone knowledgeable with the code base you know that the cache_*\n> and index_* functions only differ by an index argument. A newcomer may not\n> know this, so they wonder why we have (A) so many functions [and which is the\n> right function to use]; it is an issue of ease of use of the code base.\n>\n> Anything you do In submodule land today needs to spawn new processes in\n> the submodule. This is cumbersome and not performant. So in the far future\n> we may want to have an abstraction of a repo (B), i.e. all repository state in\n> one struct/class. That way we can open a submodule in-process and perform\n> the required actions without spawning a process.\n>\n> The road to (B) is a long road, but we have to art somewhere. And this seemed\n> like a good place by introducing a dedicated argument for the\n> repository. In a follow\n> up in the future we may want to replace &the_index by \"the_main_repo.its_index\"\n> and then could also run the commands on other (submodule) indexes. But more\n> importantly, all these commands would operate on a repository object.\n>\n> In such a far future we would have functions like the cmd_* functions\n> that would take a repository object instead of doing its setup discovery\n> on their own.\n>\n> Another reason may be its current velocity (or absence of it) w.r.t. to these\n> functions, such that fewer merge conflicts may arise.\n\nIn addition to (eventually) allowing multiple repos be open at\nthe same time for submodules, it would also help with various\nmulti-threading efforts.  For example, we have loops that do a\n\"for (k = 0, k < active_nr; k++) {...}\"  There is no visual clue\nin that code that it references \"the_index\" and therefore should\nbe subject to the same locking.  Granted, this is a trivial example,\nbut goes to the argument that the code has lots of subtle global\nvariables and macros that make it difficult to reason about the\ncode.\n\nThis step would help un-hide this.\n\nIn a much longer future, we could also consider building an\nimproved API around the in-memory index data.  For example,\ncurrently we have a simple array of cache_entry pointers and\nthe entire code base uses \"for\" loops like the above to iterate.\nIf we could hide that fact, then we could consider alternative\nrepresentations for various reasons.\n() bulk alloc the cache_entries from a pool, rather than individually.\n() cluster cache_entries linearly by parent directory, rather\n    than linearly over the whole tree.\n() efficient alternative iterator methods on the index, such as\n    non-recursive breadth-first\n\nThings like this would be difficult with the current set of\nglobals and macros.\n\nThanks,\nJeff\n\n\n>\n> ---\n> This discussion is similar to the \"free memory at the end of cmd_*\" discussion,\n> as it aims to make code reusable, and accepting a minor drawback for it.\n> Typing \"the_index\" re-enforces the object thinking model and may have people\n> start on thinking if they would like to declare yet another global variable.\n>\n> Thanks,\n> Stefan\n>\n"},{"id":"318506","messageId":"253450f8-4ece-e31b-c139-5d8a3863fb9a@jeffhostetler.com","threadId":"45843","inReplyTo":"20170501190719.10669-1-sbeller@google.com","subject":"Re: [PATCH 0/5] Start of a journey: drop NO_THE_INDEX_COMPATIBILITY_MACROS","fromName":"Jeff Hostetler","fromEmail":"git@jeffhostetler.com","sentAt":"2017-05-02T15:35:32Z","receivedAt":"2017-05-02T15:35:40Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"\n\nOn 5/1/2017 3:07 PM, Stefan Beller wrote:\n> This applies to origin/master.\n>\n> For better readability and understandability for newcomers it is a good idea\n> to not offer 2 APIs doing the same thing with on being the #define of the other.\n>\n> In the long run we may want to drop the macros guarded by\n> NO_THE_INDEX_COMPATIBILITY_MACROS. This converts a couple of them.\n>\n> My main reason for this patch is to try out coccinelle as well as a\n> discussion I had off list about maintainability of software.\n>\n> I just made these patches and wonder if now is a good time to pull through and\n> convert the rest as well?\n>\n\nYou may also want to look at unpack-trees.c : mark_new_skip_worktree().\nIt has a local variable named \"the_index\" in the argument list.\nYou may want to rename this to avoid confusion.\n\nJeff\n\n"},{"id":"318542","messageId":"CAGZ79kYzDTgtwx6JT4HULTm4sXGLicc_-sMATuL9ayOHxR-4+A@mail.gmail.com","threadId":"45843","inReplyTo":"253450f8-4ece-e31b-c139-5d8a3863fb9a@jeffhostetler.com","subject":"Re: [PATCH 0/5] Start of a journey: drop NO_THE_INDEX_COMPATIBILITY_MACROS","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-05-02T17:06:59Z","receivedAt":"2017-05-02T17:07:07Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Tue, May 2, 2017 at 8:35 AM, Jeff Hostetler <git@jeffhostetler.com> wrote:\n> You may also want to look at unpack-trees.c : mark_new_skip_worktree().\n> It has a local variable named \"the_index\" in the argument list.\n> You may want to rename this to avoid confusion.\n\nThanks for bringing this up. I just made a local commit,\nto be sent out with v2.\n\n>\n> Thank you for bringing this up and making this proposal.\n> I started a similar effort internally last fall, but\n> stopped because of the footprint size.\n>\n\nYeah, I also have a bad feeling about the foot print, which\nis why I asked if now is a good time to go with such a series.\n\n\n> In addition to (eventually) allowing multiple repos be open at\n> the same time for submodules, it would also help with various\n> multi-threading efforts.  For example, we have loops that do a\n> \"for (k = 0, k < active_nr; k++) {...}\"  There is no visual clue\n> in that code that it references \"the_index\" and therefore should\n> be subject to the same locking.  Granted, this is a trivial example,\n> but goes to the argument that the code has lots of subtle global\n> variables and macros that make it difficult to reason about the\n> code.\n>\n> This step would help un-hide this.\n\nThanks for pointing out the actual underlying reason, that I was trying\nto formulate. I'll borrow these lines for future cover letters.\n\nThanks,\nStefan\n"},{"id":"318641","messageId":"CACsJy8AZevgFda4ZJAmH_Nyrtuk72FUjdk6B8_SJB=n6quPnbw@mail.gmail.com","threadId":"45843","inReplyTo":"xmqq7f20f3a8.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH 0/5] Start of a journey: drop NO_THE_INDEX_COMPATIBILITY_MACROS","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2017-05-03T10:27:27Z","receivedAt":"2017-05-03T10:28:03Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Tue, May 2, 2017 at 8:36 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> Stefan Beller <sbeller@google.com> writes:\n>\n>> This applies to origin/master.\n>>\n>> For better readability and understandability for newcomers it is a good idea\n>> to not offer 2 APIs doing the same thing with on being the #define of the other.\n>>\n>> In the long run we may want to drop the macros guarded by\n>> NO_THE_INDEX_COMPATIBILITY_MACROS. This converts a couple of them.\n>\n> Why?\n\nWell.. why did you add NO_THE_INDEX_COMP... in the first place? ;-) j/k\n\n> Why should we keep typing &the_index, when most of the time we are given _the_ index and working on it?\n\nI attempted the same thing once or twice in the past, had the same\nimpression and dropped it. But I think it's good to get rid of cache_*\nmacros, at least outside builtin/ directory. It makes it clearer about\nthe index dependency. Maybe one day we could libify sha1_file.c and\nfinally introduce \"struct repository\", where the_index, object db and\nref-store belong (hmm.. the index may belong to \"struct worktree\", not\nthe repo one...).\n\nSo yeah it may look a bit more verbose (and probably causes a lot more\nconflicts on 'pu') but in my opinion it's a good direction. I wish\nStefan good luck. Brave soul :D\n-- \nDuy\n"},{"id":"318645","messageId":"CAJZjrdWF4NLPty81wmPsgUoVz1FddYhTGdjrNuB1LcME5qrwDQ@mail.gmail.com","threadId":"45843","inReplyTo":"b2d1d2fe-1b9b-4afa-192f-267bbb5df487@jeffhostetler.com","subject":"Re: [PATCH 0/5] Start of a journey: drop NO_THE_INDEX_COMPATIBILITY_MACROS","fromName":"Samuel Lijin","fromEmail":"sxlijin@gmail.com","sentAt":"2017-05-03T11:31:48Z","receivedAt":"2017-05-03T11:32:34Z","isPatch":true,"sender":{"key":"sxlijin@gmail.com","avatar":"https://gravatar.com/avatar/01777bf1eae64e2b4dca97dcac182a6abbcf6fd8cb4d5b8fa33edf9f8cc21746?d=mp&s=160"},"body":"On Tue, May 2, 2017 at 9:05 AM, Jeff Hostetler <git@jeffhostetler.com> wrote:\n>\n>\n> On 5/2/2017 12:17 AM, Stefan Beller wrote:\n>>\n>> On Mon, May 1, 2017 at 6:36 PM, Junio C Hamano <gitster@pobox.com> wrote:\n>>>\n>>> Stefan Beller <sbeller@google.com> writes:\n>>>\n>>>> This applies to origin/master.\n>>>>\n>>>> For better readability and understandability for newcomers it is a good\n>>>> idea\n>>>> to not offer 2 APIs doing the same thing with on being the #define of\n>>>> the other.\n>>>>\n>>>> In the long run we may want to drop the macros guarded by\n>>>> NO_THE_INDEX_COMPATIBILITY_MACROS. This converts a couple of them.\n>\n>\n> Thank you for bringing this up and making this proposal.\n> I started a similar effort internally last fall, but\n> stopped because of the footprint size.\n>\n>>>\n>>> Why?  Why should we keep typing &the_index, when most of the time we\n>>> are given _the_ index and working on it?\n>>\n>>\n>> As someone knowledgeable with the code base you know that the cache_*\n>> and index_* functions only differ by an index argument. A newcomer may not\n>> know this, so they wonder why we have (A) so many functions [and which is\n>> the\n>> right function to use]; it is an issue of ease of use of the code base.\n>>\n>> Anything you do In submodule land today needs to spawn new processes in\n>> the submodule. This is cumbersome and not performant. So in the far future\n>> we may want to have an abstraction of a repo (B), i.e. all repository\n>> state in\n>> one struct/class. That way we can open a submodule in-process and perform\n>> the required actions without spawning a process.\n>>\n>> The road to (B) is a long road, but we have to art somewhere. And this\n>> seemed\n>> like a good place by introducing a dedicated argument for the\n>> repository. In a follow\n>> up in the future we may want to replace &the_index by\n>> \"the_main_repo.its_index\"\n>> and then could also run the commands on other (submodule) indexes. But\n>> more\n>> importantly, all these commands would operate on a repository object.\n>>\n>> In such a far future we would have functions like the cmd_* functions\n>> that would take a repository object instead of doing its setup discovery\n>> on their own.\n>>\n>> Another reason may be its current velocity (or absence of it) w.r.t. to\n>> these\n>> functions, such that fewer merge conflicts may arise.\n>\n>\n> In addition to (eventually) allowing multiple repos be open at\n> the same time for submodules, it would also help with various\n> multi-threading efforts.  For example, we have loops that do a\n> \"for (k = 0, k < active_nr; k++) {...}\"  There is no visual clue\n> in that code that it references \"the_index\" and therefore should\n> be subject to the same locking.  Granted, this is a trivial example,\n> but goes to the argument that the code has lots of subtle global\n> variables and macros that make it difficult to reason about the\n> code.\n\nJust to throw out an example, I'm relatively new to the codebase (I've\nbeen lurking on the mailing list for a few months now) and for a\nrecent project (I'm an undergrad wrapping up my senior year, and one\nof my classes' final projects was to do something that involved\nconcurrency) I took a shot at parallelizing the estimate_similarity()\ncalls in diffcore_rename(). The only way I was able to get it to work\nwas by dropping global mutexes in one or two files (the code for those\nmutexes still makes me cringe), because of concurrent writes to global\ndata structures.\n"},{"id":"318675","messageId":"CAGZ79kZk_p0-oVrNbqPSyWq7ZGdpQNYNjpCpqxtvU_-=n5EqOw@mail.gmail.com","threadId":"45843","inReplyTo":"CACsJy8AZevgFda4ZJAmH_Nyrtuk72FUjdk6B8_SJB=n6quPnbw@mail.gmail.com","subject":"Re: [PATCH 0/5] Start of a journey: drop NO_THE_INDEX_COMPATIBILITY_MACROS","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-05-03T17:02:36Z","receivedAt":"2017-05-03T17:02:48Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Wed, May 3, 2017 at 3:27 AM, Duy Nguyen <pclouds@gmail.com> wrote:\n> On Tue, May 2, 2017 at 8:36 AM, Junio C Hamano <gitster@pobox.com> wrote:\n>> Stefan Beller <sbeller@google.com> writes:\n>>\n>>> This applies to origin/master.\n>>>\n>>> For better readability and understandability for newcomers it is a good idea\n>>> to not offer 2 APIs doing the same thing with on being the #define of the other.\n>>>\n>>> In the long run we may want to drop the macros guarded by\n>>> NO_THE_INDEX_COMPATIBILITY_MACROS. This converts a couple of them.\n>>\n>> Why?\n>\n> Well.. why did you add NO_THE_INDEX_COMP... in the first place? ;-) j/k\n>\n>> Why should we keep typing &the_index, when most of the time we are given _the_ index and working on it?\n>\n> I attempted the same thing once or twice in the past, had the same\n> impression and dropped it. But I think it's good to get rid of cache_*\n> macros, at least outside builtin/ directory. It makes it clearer about\n> the index dependency. Maybe one day we could libify sha1_file.c and\n> finally introduce \"struct repository\", where the_index, object db and\n> ref-store belong (hmm.. the index may belong to \"struct worktree\", not\n> the repo one...).\n\n+cc Brandon, who attempts to come up with a struct repository as we speak.\n\n> So yeah it may look a bit more verbose (and probably causes a lot more\n> conflicts on 'pu') but in my opinion it's a good direction. I wish\n> Stefan good luck. Brave soul :D\n\nThanks for the encouragement! As you seem to be interested in this topic,\nyou may want to help out by reviewing, starting at:\nhttps://public-inbox.org/git/20170502222322.21055-1-sbeller@google.com/\n\nThanks,\nStefan\n"},{"id":"318678","messageId":"CAGZ79kZs8q2cn7wJr-2ZFGZEwSsy8K2RZ_xBXfUuZBiGM0Gjog@mail.gmail.com","threadId":"45843","inReplyTo":"CAJZjrdWF4NLPty81wmPsgUoVz1FddYhTGdjrNuB1LcME5qrwDQ@mail.gmail.com","subject":"Re: [PATCH 0/5] Start of a journey: drop NO_THE_INDEX_COMPATIBILITY_MACROS","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-05-03T17:14:55Z","receivedAt":"2017-05-03T17:15:01Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Wed, May 3, 2017 at 4:31 AM, Samuel Lijin <sxlijin@gmail.com> wrote:\n> On Tue, May 2, 2017 at 9:05 AM, Jeff Hostetler <git@jeffhostetler.com> wrote:\n>>\n>>\n>> On 5/2/2017 12:17 AM, Stefan Beller wrote:\n>>>\n>>> On Mon, May 1, 2017 at 6:36 PM, Junio C Hamano <gitster@pobox.com> wrote:\n>>>>\n>>>> Stefan Beller <sbeller@google.com> writes:\n>>>>\n>>>>> This applies to origin/master.\n>>>>>\n>>>>> For better readability and understandability for newcomers it is a good\n>>>>> idea\n>>>>> to not offer 2 APIs doing the same thing with on being the #define of\n>>>>> the other.\n>>>>>\n>>>>> In the long run we may want to drop the macros guarded by\n>>>>> NO_THE_INDEX_COMPATIBILITY_MACROS. This converts a couple of them.\n>>\n>>\n>> Thank you for bringing this up and making this proposal.\n>> I started a similar effort internally last fall, but\n>> stopped because of the footprint size.\n>>\n>>>>\n>>>> Why?  Why should we keep typing &the_index, when most of the time we\n>>>> are given _the_ index and working on it?\n>>>\n>>>\n>>> As someone knowledgeable with the code base you know that the cache_*\n>>> and index_* functions only differ by an index argument. A newcomer may not\n>>> know this, so they wonder why we have (A) so many functions [and which is\n>>> the\n>>> right function to use]; it is an issue of ease of use of the code base.\n>>>\n>>> Anything you do In submodule land today needs to spawn new processes in\n>>> the submodule. This is cumbersome and not performant. So in the far future\n>>> we may want to have an abstraction of a repo (B), i.e. all repository\n>>> state in\n>>> one struct/class. That way we can open a submodule in-process and perform\n>>> the required actions without spawning a process.\n>>>\n>>> The road to (B) is a long road, but we have to art somewhere. And this\n>>> seemed\n>>> like a good place by introducing a dedicated argument for the\n>>> repository. In a follow\n>>> up in the future we may want to replace &the_index by\n>>> \"the_main_repo.its_index\"\n>>> and then could also run the commands on other (submodule) indexes. But\n>>> more\n>>> importantly, all these commands would operate on a repository object.\n>>>\n>>> In such a far future we would have functions like the cmd_* functions\n>>> that would take a repository object instead of doing its setup discovery\n>>> on their own.\n>>>\n>>> Another reason may be its current velocity (or absence of it) w.r.t. to\n>>> these\n>>> functions, such that fewer merge conflicts may arise.\n>>\n>>\n>> In addition to (eventually) allowing multiple repos be open at\n>> the same time for submodules, it would also help with various\n>> multi-threading efforts.  For example, we have loops that do a\n>> \"for (k = 0, k < active_nr; k++) {...}\"  There is no visual clue\n>> in that code that it references \"the_index\" and therefore should\n>> be subject to the same locking.  Granted, this is a trivial example,\n>> but goes to the argument that the code has lots of subtle global\n>> variables and macros that make it difficult to reason about the\n>> code.\n>\n> Just to throw out an example, I'm relatively new to the codebase (I've\n> been lurking on the mailing list for a few months now) and for a\n> recent project (I'm an undergrad wrapping up my senior year, and one\n> of my classes' final projects was to do something that involved\n> concurrency) I took a shot at parallelizing the estimate_similarity()\n> calls in diffcore_rename(). The only way I was able to get it to work\n> was by dropping global mutexes in one or two files (the code for those\n> mutexes still makes me cringe), because of concurrent writes to global\n> data structures.\n\nThat sounds like a challenge. As we have many globals, we need to be\nvery careful about threading.\n\nAlso an interesting discussion about threading:\nhttps://public-inbox.org/git/9e4733910708111412t48c1beaahfbaa2c68a02f64f1@mail.gmail.com/\n\nAre the patches available for discussion?\n\nThanks,\nStefan\n"},{"id":"318683","messageId":"CAJZjrdWRjAC4GbJExhHw7OBRbjuUs2bs5bpvaD91W_aj5e3a9g@mail.gmail.com","threadId":"45843","inReplyTo":"CAGZ79kZs8q2cn7wJr-2ZFGZEwSsy8K2RZ_xBXfUuZBiGM0Gjog@mail.gmail.com","subject":"Re: [PATCH 0/5] Start of a journey: drop NO_THE_INDEX_COMPATIBILITY_MACROS","fromName":"Samuel Lijin","fromEmail":"sxlijin@gmail.com","sentAt":"2017-05-03T18:22:51Z","receivedAt":"2017-05-03T18:23:36Z","isPatch":true,"sender":{"key":"sxlijin@gmail.com","avatar":"https://gravatar.com/avatar/01777bf1eae64e2b4dca97dcac182a6abbcf6fd8cb4d5b8fa33edf9f8cc21746?d=mp&s=160"},"body":"On Wed, May 3, 2017 at 12:14 PM, Stefan Beller <sbeller@google.com> wrote:\n> On Wed, May 3, 2017 at 4:31 AM, Samuel Lijin <sxlijin@gmail.com> wrote:\n>>\n>> Just to throw out an example, I'm relatively new to the codebase (I've\n>> been lurking on the mailing list for a few months now) and for a\n>> recent project (I'm an undergrad wrapping up my senior year, and one\n>> of my classes' final projects was to do something that involved\n>> concurrency) I took a shot at parallelizing the estimate_similarity()\n>> calls in diffcore_rename(). The only way I was able to get it to work\n>> was by dropping global mutexes in one or two files (the code for those\n>> mutexes still makes me cringe), because of concurrent writes to global\n>> data structures.\n>\n> That sounds like a challenge. As we have many globals, we need to be\n> very careful about threading.\n>\n> Also an interesting discussion about threading:\n> https://public-inbox.org/git/9e4733910708111412t48c1beaahfbaa2c68a02f64f1@mail.gmail.com/\n\nThanks.\n\n> Are the patches available for discussion?\n\nI was planning on revisiting the patch series before sending it out -\nthe changes in attr.c and sha1_file.c are not pretty (and I'm pretty\nsure one of them is non-portable) - but it is published at\nhttps://github.com/sxlijin/git/commits/parallelize.thread-pool.1 (it's\nbased off v2.12.2).\n\n> Thanks,\n> Stefan\n"},{"id":"318717","messageId":"xmqqa86tbamh.fsf@gitster.mtv.corp.google.com","threadId":"45843","inReplyTo":"CACsJy8AZevgFda4ZJAmH_Nyrtuk72FUjdk6B8_SJB=n6quPnbw@mail.gmail.com","subject":"Re: [PATCH 0/5] Start of a journey: drop NO_THE_INDEX_COMPATIBILITY_MACROS","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-05-04T02:48:22Z","receivedAt":"2017-05-04T02:48:30Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Duy Nguyen <pclouds@gmail.com> writes:\n\n>>> In the long run we may want to drop the macros guarded by\n>>> NO_THE_INDEX_COMPATIBILITY_MACROS. This converts a couple of them.\n>>\n>> Why?\n>\n> Well.. why did you add NO_THE_INDEX_COMP... in the first place? ;-) j/k\n\nThat was to mark the code that implements the underlying machinery\nthat the code in a particular file has already been vetted and\nconverted to be capable of working with an arbitrary index_state\ninstance, not just the_index instance.\n\nYour mentioning \"at least outside builtin/\" shows that you have a\ngood understanding of the issue; they are infrastructure code and\nmany of them may become more useful if they are enhanced to take an\nindex_state instance instead of always working with the_index.  With\nan infrastructure code that insists on working on the_index, an\napplication that has something valuable in the_index already needs\nto somehow save it elsewhere before calling the function and use the\nresult from the_index before restoring its version.\n\nI think unpack-trees.c used to assume that it is OK to use the_index,\nbut after it started taking src/dst_index, it gained NO_THE_INDEX_COMP\nthing.  That's the kind of change in this area we would want to see.\n\n> I attempted the same thing once or twice in the past, had the same\n> impression and dropped it. But I think it's good to get rid of cache_*\n> macros, at least outside builtin/ directory.\n\nOne thing that needs to be kept in mind is that a mechanical\nreplacement of active_cache[] to the_index.cache[] in the\ninfrastructure code does not get us closer to such an improvement.\nIn fact, such a patch only has negative value (keep reading until\nthe end of the paragraph that begins with \"One thing is certain\" to\nunderstand why).\n\nThe entry point to a codechain for an important infrastructure code\nthat can currently only work with the_index needs to be identified.\nThere may be many.  They need to be made to take an index_state\ninstance and to pass it through the callchain.  That kind of change\nwould be an improvement, and will get us closer to mark the\nresulting code with NO_THE_INDEX_COMP thing.\n\nI think somebody else said this, but I agree that in the longer\nterm, we would want to have a \"repository\" abstraction for in-core\ndata structure.\n\nImagine that a program wants to read into an index_state the tip\ncommit of a branch whose name is the same as the current branch in\none submodule and do something with the objects, while keeping\nthe_index for the top-level superproject.  Thanks to Michael's and\nyour recent work, we are almost there to have \"ref-store\" that\nrepresents the set of refs the submodule in question has that a\n\"repository\" object that represents the submodule can point at.  We\ncan learn the object name at the tip of a specific ref using that\ninfrastructure.  Thanks to an ancient change under discussion, we\ncan already read the contents of the index file into an instance of\nan index_state that is different from the_index.  But after doing\nthese operations, we'd need to actually get to the contents of the\nobjects the index_state holds.  How should that work in the\n\"repository object represents an in-core repository\" world?\n\nWhat is missing is a way to represent the object store, so that the\n\"repository\" object can point at an instance of it (which in turn\nmay point at a set of its alternates) [*1*].  With that, perhaps the\nmost general kind of the infrastructure API that works with an\nindex_state instance may additionally take a repository object, or\nperhaps an index_state may have a pointer to the repository where\nthe objects listed in it must be taken from (in which case the\nfunction may take only an index_state).  In the end the enhanced\nfunction has to allow us to read from the object store of the\nsubmodule, not from the superproject's.\n\nDepending on how the design of the repository object goes, the\ninterface to these functions may have to change.\n\nBut one thing is certain. Many users of the API, just like a lot of\nbuiltin/ code works only with the_index today, will not have to work\nwith a non-default repository or a non-default index_state.  Only\nthe more advanced and complex \"multi-repo\" Porcelains would have to\ncare.  Keeping active_cache[], active_nr, etc. abstraction would\nisolate the simpler callers from the inevitable code churn we would\nneed while getting the \"repository\" abstraction right.  This is why\nI see that you understood the issues well when you said \"builtiln/\".\n\nIf we want to have the \"repository\" abstraction, the \"object store\"\nis the next thing we should be working on, and such a work can take\ninspiration from how the old <active_cache[], active_nr,\nactive_alloc, active_cache_changed and *active_cache_tree> tuple was\nturned into an \"index\" object while allowing the majority of code\nthat want to deal with the singleton instance keep using the old\nnames via CPP macros.\n\nAlso, dropping compatibility macros at the end of the series is\nunfriendly to fellow developers with WIPs that depend on the\ntraditional way of doing things.  It is doubly insulting to them to\nsend such a series during the feature freeze period, when it is more\nlikely that they are holding off their WIP in an attempt to allow us\nto concentrate more on what we should be, i.e. finding and fixing\npossible regressions at the tip of 'master' to polish the upcoming\nrelease and help the end users.\n\n\n[Footnote]\n\n*1* Instead we have an ugly hack that lets the singleton object\nstore add objects from the submodule object store, and it does not\nallow us to back out once we did so (unlike the \"ref-store\" thing\nthat we could).  When we need to work with a project with many\nsubmodules, we should be able to say \"OK, we are done with this\nthing for now, call repository_clear() to reclaim the resources we\nused to deal with it\".\n\n"},{"id":"318718","messageId":"20170504032415.GA139188@google.com","threadId":"45843","inReplyTo":"xmqqa86tbamh.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH 0/5] Start of a journey: drop NO_THE_INDEX_COMPATIBILITY_MACROS","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-05-04T03:24:15Z","receivedAt":"2017-05-04T03:24:23Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"On 05/03, Junio C Hamano wrote:\n> Duy Nguyen <pclouds@gmail.com> writes:\n> \n> >>> In the long run we may want to drop the macros guarded by\n> >>> NO_THE_INDEX_COMPATIBILITY_MACROS. This converts a couple of them.\n> >>\n> >> Why?\n> >\n> > Well.. why did you add NO_THE_INDEX_COMP... in the first place? ;-) j/k\n> \n> That was to mark the code that implements the underlying machinery\n> that the code in a particular file has already been vetted and\n> converted to be capable of working with an arbitrary index_state\n> instance, not just the_index instance.\n> \n> Your mentioning \"at least outside builtin/\" shows that you have a\n> good understanding of the issue; they are infrastructure code and\n> many of them may become more useful if they are enhanced to take an\n> index_state instance instead of always working with the_index.  With\n> an infrastructure code that insists on working on the_index, an\n> application that has something valuable in the_index already needs\n> to somehow save it elsewhere before calling the function and use the\n> result from the_index before restoring its version.\n> \n> I think unpack-trees.c used to assume that it is OK to use the_index,\n> but after it started taking src/dst_index, it gained NO_THE_INDEX_COMP\n> thing.  That's the kind of change in this area we would want to see.\n> \n> > I attempted the same thing once or twice in the past, had the same\n> > impression and dropped it. But I think it's good to get rid of cache_*\n> > macros, at least outside builtin/ directory.\n> \n> One thing that needs to be kept in mind is that a mechanical\n> replacement of active_cache[] to the_index.cache[] in the\n> infrastructure code does not get us closer to such an improvement.\n> In fact, such a patch only has negative value (keep reading until\n> the end of the paragraph that begins with \"One thing is certain\" to\n> understand why).\n> \n> The entry point to a codechain for an important infrastructure code\n> that can currently only work with the_index needs to be identified.\n> There may be many.  They need to be made to take an index_state\n> instance and to pass it through the callchain.  That kind of change\n> would be an improvement, and will get us closer to mark the\n> resulting code with NO_THE_INDEX_COMP thing.\n> \n> I think somebody else said this, but I agree that in the longer\n> term, we would want to have a \"repository\" abstraction for in-core\n> data structure.\n> \n> Imagine that a program wants to read into an index_state the tip\n> commit of a branch whose name is the same as the current branch in\n> one submodule and do something with the objects, while keeping\n> the_index for the top-level superproject.  Thanks to Michael's and\n> your recent work, we are almost there to have \"ref-store\" that\n> represents the set of refs the submodule in question has that a\n> \"repository\" object that represents the submodule can point at.  We\n> can learn the object name at the tip of a specific ref using that\n> infrastructure.  Thanks to an ancient change under discussion, we\n> can already read the contents of the index file into an instance of\n> an index_state that is different from the_index.  But after doing\n> these operations, we'd need to actually get to the contents of the\n> objects the index_state holds.  How should that work in the\n> \"repository object represents an in-core repository\" world?\n> \n> What is missing is a way to represent the object store, so that the\n> \"repository\" object can point at an instance of it (which in turn\n> may point at a set of its alternates) [*1*].  With that, perhaps the\n> most general kind of the infrastructure API that works with an\n> index_state instance may additionally take a repository object, or\n> perhaps an index_state may have a pointer to the repository where\n> the objects listed in it must be taken from (in which case the\n> function may take only an index_state).  In the end the enhanced\n> function has to allow us to read from the object store of the\n> submodule, not from the superproject's.\n> \n> Depending on how the design of the repository object goes, the\n> interface to these functions may have to change.\n> \n> But one thing is certain. Many users of the API, just like a lot of\n> builtin/ code works only with the_index today, will not have to work\n> with a non-default repository or a non-default index_state.  Only\n> the more advanced and complex \"multi-repo\" Porcelains would have to\n> care.  Keeping active_cache[], active_nr, etc. abstraction would\n> isolate the simpler callers from the inevitable code churn we would\n> need while getting the \"repository\" abstraction right.  This is why\n> I see that you understood the issues well when you said \"builtiln/\".\n> \n> If we want to have the \"repository\" abstraction, the \"object store\"\n> is the next thing we should be working on, and such a work can take\n> inspiration from how the old <active_cache[], active_nr,\n> active_alloc, active_cache_changed and *active_cache_tree> tuple was\n> turned into an \"index\" object while allowing the majority of code\n> that want to deal with the singleton instance keep using the old\n> names via CPP macros.\n> \n> Also, dropping compatibility macros at the end of the series is\n> unfriendly to fellow developers with WIPs that depend on the\n> traditional way of doing things.  It is doubly insulting to them to\n> send such a series during the feature freeze period, when it is more\n> likely that they are holding off their WIP in an attempt to allow us\n> to concentrate more on what we should be, i.e. finding and fixing\n> possible regressions at the tip of 'master' to polish the upcoming\n> release and help the end users.\n> \n> \n> [Footnote]\n> \n> *1* Instead we have an ugly hack that lets the singleton object\n> store add objects from the submodule object store, and it does not\n> allow us to back out once we did so (unlike the \"ref-store\" thing\n> that we could).  When we need to work with a project with many\n> submodules, we should be able to say \"OK, we are done with this\n> thing for now, call repository_clear() to reclaim the resources we\n> used to deal with it\".\n> \n\nThanks for the detailed explanation on what a possible transition to\nhaving a repository object would look like.  While digging through the\ncode it does seem like the object store is one of the main things\nholding the code base back from having a repository object.\n\nThank being said, I spent today hacking away at 'ls-files' in order to\nsee if it would be feasible to convert it to using a repository object\nfor the recursive submodule case instead of using run-command.  I picked\n'ls-files' mainly because the majority of the code paths don't touch the\nobject store and mainly deal with manipulating the index.  Despite the\nhack-y, cobbled together state that it is in currently it seems very\nfeasible goal.\n\n-- \nBrandon Williams\n"},{"id":"318719","messageId":"20170504032913.GB139188@google.com","threadId":"45843","inReplyTo":"CAJZjrdWRjAC4GbJExhHw7OBRbjuUs2bs5bpvaD91W_aj5e3a9g@mail.gmail.com","subject":"Re: [PATCH 0/5] Start of a journey: drop NO_THE_INDEX_COMPATIBILITY_MACROS","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-05-04T03:29:13Z","receivedAt":"2017-05-04T03:29:29Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"On 05/03, Samuel Lijin wrote:\n> On Wed, May 3, 2017 at 12:14 PM, Stefan Beller <sbeller@google.com> wrote:\n> > On Wed, May 3, 2017 at 4:31 AM, Samuel Lijin <sxlijin@gmail.com> wrote:\n> >>\n> >> Just to throw out an example, I'm relatively new to the codebase (I've\n> >> been lurking on the mailing list for a few months now) and for a\n> >> recent project (I'm an undergrad wrapping up my senior year, and one\n> >> of my classes' final projects was to do something that involved\n> >> concurrency) I took a shot at parallelizing the estimate_similarity()\n> >> calls in diffcore_rename(). The only way I was able to get it to work\n> >> was by dropping global mutexes in one or two files (the code for those\n> >> mutexes still makes me cringe), because of concurrent writes to global\n> >> data structures.\n> >\n> > That sounds like a challenge. As we have many globals, we need to be\n> > very careful about threading.\n> >\n> > Also an interesting discussion about threading:\n> > https://public-inbox.org/git/9e4733910708111412t48c1beaahfbaa2c68a02f64f1@mail.gmail.com/\n> \n> Thanks.\n> \n> > Are the patches available for discussion?\n> \n> I was planning on revisiting the patch series before sending it out -\n> the changes in attr.c and sha1_file.c are not pretty (and I'm pretty\n> sure one of them is non-portable) - but it is published at\n> https://github.com/sxlijin/git/commits/parallelize.thread-pool.1 (it's\n> based off v2.12.2).\n\nI spent a good chunk of time reworking the attribute code a few months\nback in order to make it thread-safe so you may want to rebase on top of\na newer version and see if your changes get a little less messy (if so\nthen I did my job :).\n\n-- \nBrandon Williams\n"},{"id":"318796","messageId":"CAGZ79kZiBOrY6Qno_wFpvFHpbpCY0BtriqYGW5JKG+1hfgJwiQ@mail.gmail.com","threadId":"45843","inReplyTo":"xmqqa86tbamh.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH 0/5] Start of a journey: drop NO_THE_INDEX_COMPATIBILITY_MACROS","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-05-04T18:30:06Z","receivedAt":"2017-05-04T18:35:51Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Wed, May 3, 2017 at 7:48 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Duy Nguyen <pclouds@gmail.com> writes:\n>\n>>>> In the long run we may want to drop the macros guarded by\n>>>> NO_THE_INDEX_COMPATIBILITY_MACROS. This converts a couple of them.\n>>>\n>>> Why?\n>>\n>> Well.. why did you add NO_THE_INDEX_COMP... in the first place? ;-) j/k\n>\n> That was to mark the code that implements the underlying machinery\n> that the code in a particular file has already been vetted and\n> converted to be capable of working with an arbitrary index_state\n> instance, not just the_index instance.\n>\n> Your mentioning \"at least outside builtin/\" shows that you have a\n> good understanding of the issue; they are infrastructure code and\n> many of them may become more useful if they are enhanced to take an\n> index_state instance instead of always working with the_index.  With\n> an infrastructure code that insists on working on the_index, an\n> application that has something valuable in the_index already needs\n> to somehow save it elsewhere before calling the function and use the\n> result from the_index before restoring its version.\n>\n> I think unpack-trees.c used to assume that it is OK to use the_index,\n> but after it started taking src/dst_index, it gained NO_THE_INDEX_COMP\n> thing.  That's the kind of change in this area we would want to see.\n>\n>> I attempted the same thing once or twice in the past, had the same\n>> impression and dropped it. But I think it's good to get rid of cache_*\n>> macros, at least outside builtin/ directory.\n>\n> One thing that needs to be kept in mind is that a mechanical\n> replacement of active_cache[] to the_index.cache[] in the\n> infrastructure code does not get us closer to such an improvement.\n> In fact, such a patch only has negative value (keep reading until\n> the end of the paragraph that begins with \"One thing is certain\" to\n> understand why).\n>\n> The entry point to a codechain for an important infrastructure code\n> that can currently only work with the_index needs to be identified.\n> There may be many.  They need to be made to take an index_state\n> instance and to pass it through the callchain.  That kind of change\n> would be an improvement, and will get us closer to mark the\n> resulting code with NO_THE_INDEX_COMP thing.\n>\n> I think somebody else said this, but I agree that in the longer\n> term, we would want to have a \"repository\" abstraction for in-core\n> data structure.\n>\n> Imagine that a program wants to read into an index_state the tip\n> commit of a branch whose name is the same as the current branch in\n> one submodule and do something with the objects, while keeping\n> the_index for the top-level superproject.  Thanks to Michael's and\n> your recent work, we are almost there to have \"ref-store\" that\n> represents the set of refs the submodule in question has that a\n> \"repository\" object that represents the submodule can point at.  We\n> can learn the object name at the tip of a specific ref using that\n> infrastructure.  Thanks to an ancient change under discussion, we\n> can already read the contents of the index file into an instance of\n> an index_state that is different from the_index.  But after doing\n> these operations, we'd need to actually get to the contents of the\n> objects the index_state holds.  How should that work in the\n> \"repository object represents an in-core repository\" world?\n>\n> What is missing is a way to represent the object store, so that the\n> \"repository\" object can point at an instance of it (which in turn\n> may point at a set of its alternates) [*1*].  With that, perhaps the\n> most general kind of the infrastructure API that works with an\n> index_state instance may additionally take a repository object, or\n> perhaps an index_state may have a pointer to the repository where\n> the objects listed in it must be taken from (in which case the\n> function may take only an index_state).  In the end the enhanced\n> function has to allow us to read from the object store of the\n> submodule, not from the superproject's.\n>\n> Depending on how the design of the repository object goes, the\n> interface to these functions may have to change.\n>\n> But one thing is certain. Many users of the API, just like a lot of\n> builtin/ code works only with the_index today, will not have to work\n> with a non-default repository or a non-default index_state.  Only\n> the more advanced and complex \"multi-repo\" Porcelains would have to\n> care.  Keeping active_cache[], active_nr, etc. abstraction would\n> isolate the simpler callers from the inevitable code churn we would\n> need while getting the \"repository\" abstraction right.  This is why\n> I see that you understood the issues well when you said \"builtiln/\".\n>\n> If we want to have the \"repository\" abstraction, the \"object store\"\n> is the next thing we should be working on, and such a work can take\n> inspiration from how the old <active_cache[], active_nr,\n> active_alloc, active_cache_changed and *active_cache_tree> tuple was\n> turned into an \"index\" object while allowing the majority of code\n> that want to deal with the singleton instance keep using the old\n> names via CPP macros.\n\nThanks for the reply.\n\nSo instead of a mechanical replacement, we'd rather want to\nsee \"the_index\" not appearing at all outside of builtins, which\nimplies two things:\n* If done properly we can move the macros from cache.h to\n  e.g. builtin.h. That way future developers are less tempted\n  to use the cache_* macros in the library code.\n* we'd have to pass through the_index from the builtin function\n  down to the library code, potentially going through multiple\n  function. For this it is unclear if we want to start this now, or wait\n  until Brandon presents his initial repository object struct, which\n  may be suited better for passing-around.\n\nSo if I want to further look into refactoring, I'll have a look into\nthe object store and hold off sending a series that drops the_index.\n\n> Also, dropping compatibility macros at the end of the series is\n> unfriendly to fellow developers with WIPs that depend on the\n> traditional way of doing things.  It is doubly insulting to them to\n> send such a series during the feature freeze period, when it is more\n> likely that they are holding off their WIP in an attempt to allow us\n> to concentrate more on what we should be, i.e. finding and fixing\n> possible regressions at the tip of 'master' to polish the upcoming\n> release and help the end users.\n\nPersonally I have not noticed large variations of patch volume\ncorrelated to pre-release times.\n\nThanks,\nStefan\n"},{"id":"318799","messageId":"20170504191927.GB15203@aiede.svl.corp.google.com","threadId":"45843","inReplyTo":"xmqqa86tbamh.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH 0/5] Start of a journey: drop NO_THE_INDEX_COMPATIBILITY_MACROS","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2017-05-04T19:19:27Z","receivedAt":"2017-05-04T19:19:35Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi,\n\nJunio C Hamano wrote:\n> Duy Nguyen <pclouds@gmail.com> writes:\n\n>> I attempted the same thing once or twice in the past, had the same\n>> impression and dropped it. But I think it's good to get rid of cache_*\n>> macros, at least outside builtin/ directory.\n>\n> One thing that needs to be kept in mind is that a mechanical\n> replacement of active_cache[] to the_index.cache[] in the\n> infrastructure code does not get us closer to such an improvement.\n> In fact, such a patch only has negative value (keep reading until\n> the end of the paragraph that begins with \"One thing is certain\" to\n> understand why).\n>\n> The entry point to a codechain for an important infrastructure code\n> that can currently only work with the_index needs to be identified.\n> There may be many.  They need to be made to take an index_state\n> instance and to pass it through the callchain.  That kind of change\n> would be an improvement, and will get us closer to mark the\n> resulting code with NO_THE_INDEX_COMP thing.\n\nThanks for articulating this.  I agree with this general goal.\n\n[...]\n> But one thing is certain. Many users of the API, just like a lot of\n> builtin/ code works only with the_index today, will not have to work\n> with a non-default repository or a non-default index_state.  Only\n> the more advanced and complex \"multi-repo\" Porcelains would have to\n> care.  Keeping active_cache[], active_nr, etc. abstraction would\n> isolate the simpler callers from the inevitable code churn we would\n> need while getting the \"repository\" abstraction right.  This is why\n> I see that you understood the issues well when you said \"builtiln/\".\n\nOne small change we could make is to reverse the sense of the\nNO_THE_INDEX_COMPATIBILITY_MACROS macro.  That way, new library code\nauthors have to define USE_THE_INDEX_COMPATIBILITY_MACROS at the top\nof the file, providing a hint to reviewers that they are using\nthe_index implicitly instead of relying on explicit repository or\nindex parameters.\n\nMore generally, if we are willing to follow through then I see\nStefan's change as a step in the right direction.  Sure, it replaces\ncalls like read_cache with read_the_index(&the_index, ...) which does\nnot change semantics and may not look like progress.  But:\n\n- uses of 'the_index' are easy to grep for and it is easy to\n  understand that they are using global state.  In builtins, this is\n  not important (which may be an argument for making builtins get\n  USE_THE_INDEX_COMPATIBILITY_MACROS implicitly instead and\n  restricting this change to library code), but in libraries it\n  communicates what is happening to developers looking at the code.\n  It is like a /* NEEDSWORK */ comment, except in code instead of\n  comments.\n\n  See Go's context.TODO <https://golang.org/pkg/context/#TODO> for a\n  similar example in another set of projects.\n\n- it makes code consistently use the term \"index\" instead of mixing\n  \"index\" and \"cache\".  This makes code easier to understand for new\n  contributors.\n\n- a minor thing: it means more of git is using functions instead of\n  macros.  IDEs, grep habits, etc cope better with functions.  That is\n  minor, though: the compatibility macros could easily be replaced\n  with compatibility inline functions to achieve the same effect.\n\n[...]\n> Also, dropping compatibility macros at the end of the series is\n> unfriendly to fellow developers with WIPs that depend on the\n> traditional way of doing things.\n\nAgreed with this as well --- for widely used APIs like these, it is\nmore friendly to decouple adapting callers (in a separate patch) from\nthe patch that removes the API.\n\nThat is, one way to do what this series attempts would be the\nfollowing:\n\n 1. rename variables that shadow the_index.\n\n 2. add coccinelle patches (or one coccinelle patch) to\n    contrib/coccinelle implementing *_cache -> *_index migration.\n    Is there a way to do this without making it fail \"make coccicheck\"?\n\n 3. migrate library code (but not builtins) using that semantic patch\n\n 4. make compatibility macros opt-in instead of opt-out\n    (USE_THE_INDEX_COMPATIBILITY_MACROS). Opt-in all builtins.\n\n 5. optional: change the compatibility macros to compatibility inline\n    functions, perhaps.\n 6. optional: rename *_cache to *_the_index for clarity, perhaps.\n 7. optional: migrate builtins, if there is a way to make the patches\n    for that look sensible.\n\nThoughts?\nJonathan\n"},{"id":"318840","messageId":"alpine.DEB.2.21.1.1705051244310.146734@virtualbox","threadId":"45843","inReplyTo":"CAGZ79kZiBOrY6Qno_wFpvFHpbpCY0BtriqYGW5JKG+1hfgJwiQ@mail.gmail.com","subject":"Re: [PATCH 0/5] Start of a journey: drop NO_THE_INDEX_COMPATIBILITY_MACROS","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2017-05-05T14:31:31Z","receivedAt":"2017-05-05T14:31:59Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Stefan & Junio,\n\nOn Thu, 4 May 2017, Stefan Beller wrote:\n\n> So instead of a mechanical replacement, we'd rather want to\n> see \"the_index\" not appearing at all outside of builtins, which\n> implies two things:\n>\n> * If done properly we can move the macros from cache.h to\n>   e.g. builtin.h. That way future developers are less tempted\n>   to use the cache_* macros in the library code.\n\nYessss!\n\n> * we'd have to pass through the_index from the builtin function\n>   down to the library code, potentially going through multiple\n>   function. For this it is unclear if we want to start this now, or wait\n>   until Brandon presents his initial repository object struct, which\n>   may be suited better for passing-around.\n\nOr the other way round. I guess passing a struct index_state can be a\nfirst step, and we can later convert it to struct repository. I fathom\nthat more places will need a struct repository parameter than a struct\nindex_state parameter. That is, if you first identify all the places where\nthe index_state parameter is required, it should make the struct\nrepository change easier.\n\n> So if I want to further look into refactoring, I'll have a look into\n> the object store and hold off sending a series that drops the_index.\n> \n> > Also, dropping compatibility macros at the end of the series is\n> > unfriendly to fellow developers with WIPs that depend on the\n> > traditional way of doing things.  It is doubly insulting to them to\n> > send such a series during the feature freeze period, when it is more\n> > likely that they are holding off their WIP in an attempt to allow us\n> > to concentrate more on what we should be, i.e. finding and fixing\n> > possible regressions at the tip of 'master' to polish the upcoming\n> > release and help the end users.\n> \n> Personally I have not noticed large variations of patch volume\n> correlated to pre-release times.\n\nSpeaking for myself, I also use this \"slow\" time to prepare patch series\nthat should be submitted directly after a major version bump, patch series\nlike the timestamp_t one (with which I failed miserably: it got to a\nusable state only now, very short *before* a major version bump).\n\nBut yes, part of why I set aside a substantial chunk of time to work on\nthe Coverity report was to prepare for the major version, to make sure\nthat we did not have anything blatant (like the difftool use-after-free,\nwhich was embarrassing) in v2.13.0.\n\nIt may look as if the coverity patches do not focus on critical fixes, but\nthat's only because I did not find anything major in the Coverity report\n(I looked primarily for Git for Windows-specific stuff, though, to be\nhonest).\n\nMaybe it is a similar situation for other patch contributors: they tried\nto focus on critical fixes and ended up not finding anything really\ncritical?\n\nHaving said that, I did see a little shift toward cppcheck & sparse\nrelated patches ;-)\n\nCiao,\nDscho\n"},{"id":"318863","messageId":"20170505172049.GA55152@google.com","threadId":"45843","inReplyTo":"alpine.DEB.2.21.1.1705051244310.146734@virtualbox","subject":"Re: [PATCH 0/5] Start of a journey: drop NO_THE_INDEX_COMPATIBILITY_MACROS","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-05-05T17:20:49Z","receivedAt":"2017-05-05T17:20:57Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"On 05/05, Johannes Schindelin wrote:\n> Hi Stefan & Junio,\n> \n> On Thu, 4 May 2017, Stefan Beller wrote:\n> \n> > So instead of a mechanical replacement, we'd rather want to\n> > see \"the_index\" not appearing at all outside of builtins, which\n> > implies two things:\n> >\n> > * If done properly we can move the macros from cache.h to\n> >   e.g. builtin.h. That way future developers are less tempted\n> >   to use the cache_* macros in the library code.\n> \n> Yessss!\n> \n> > * we'd have to pass through the_index from the builtin function\n> >   down to the library code, potentially going through multiple\n> >   function. For this it is unclear if we want to start this now, or wait\n> >   until Brandon presents his initial repository object struct, which\n> >   may be suited better for passing-around.\n> \n> Or the other way round. I guess passing a struct index_state can be a\n> first step, and we can later convert it to struct repository. I fathom\n> that more places will need a struct repository parameter than a struct\n> index_state parameter. That is, if you first identify all the places where\n> the index_state parameter is required, it should make the struct\n> repository change easier.\n\nExactly this.  I have a local series which converts ls-files to use a\nrepository struct but it turns out, for that to work, dir.c needs to be\nconverted to take in an index_state struct for fill_directory().  So I\nthen started working on doing that conversion and hopefully will have\nsomething clean enough to send out later today for people to comment on.\n\n-- \nBrandon Williams\n"},{"id":"318864","messageId":"xmqq8tmb8bhu.fsf@gitster.mtv.corp.google.com","threadId":"45843","inReplyTo":"20170504191927.GB15203@aiede.svl.corp.google.com","subject":"Re: [PATCH 0/5] Start of a journey: drop NO_THE_INDEX_COMPATIBILITY_MACROS","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-05-05T17:22:21Z","receivedAt":"2017-05-05T17:22:28Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jonathan Nieder <jrnieder@gmail.com> writes:\n\n> That is, one way to do what this series attempts would be the\n> following:\n>\n>  1. rename variables that shadow the_index.\n\nNo question about this one.  It is a good thing to do.\n\n>  2. add coccinelle patches (or one coccinelle patch) to\n>     contrib/coccinelle implementing *_cache -> *_index migration.\n>     Is there a way to do this without making it fail \"make coccicheck\"?\n\nQuite honestly, I do not see much value in this, but take it merely\nas my knee-jerk reaction.  The only scenario I can think of in which\ndropping *_cache() macros is an improvement as the end result is\nwhen our goal is to completely drop the singleton index_state\ninstance, aka \"the_index\".  I actually think that it may be a\nworthwhile goal to eradicate \"the_index\".\n\nI wonder if somebody can take a small example codepath and make it\nnot to rely on the existence of \"the_index\" from start to end?  Have\nan instance of index_state on the stack of cmd_foo(), have it call\nread_index() into it where it currently calls read_cache(), update\nthe support functions it calls so that it can pass the pointer to\nits index_info throughout the callchain, and see how involved the\nnecessary changes of all of the above are.  Start from something\nsimple and small, e.g. \"ls-files\".  The infrastructure code updated\nfor such an experiment may be NO_THE_INDEX_COMPATIBILITY_MACROS\nclean.\n\nPerhaps we can remove the existence of the_index from the system by\ngoing that route; needless to say, when that goal is achieved, by\ndefinition *_cache() macros will be completely useless and must be\nremoved, as there is nobody who relies on the existence of and who\nuses \"the_index\".\n\n>  3. migrate library code (but not builtins) using that semantic patch\n\nI do think this is going backwards.  The only thinng replacing\n*_cache() to *_index(&the_index) buys you is newbies not having to\nknow both, but instead they will be exposed to the pattern of\nrepeated use of *_index(&the_index); i.e. reliance of the existence\nof the singleton \"the_index\" is not reduced, but is stressed which\nis a big downside when we are trying to eventually get rid of it.\n\nAlso quite honestly, I do not think we want newbies to be touching\nthe things that needs *_index() interface while this update is going\non.\n\nThe remainder of your enumeration goes in a direction different from\ngetting rid of the_index, so I do not know---I wrote the above under\nthe assumption that the total removal of \"the_index\" might be a good\nthing to do, and where that assumption would lead us to (e.g. an\nobvious side-effect of no longer having the_index is that *_cache()\nmacros cannot exist), and I am undecided if the assumption is a good\none (yet).\n\n\n"},{"id":"318865","messageId":"20170505172956.GB55152@google.com","threadId":"45843","inReplyTo":"xmqq8tmb8bhu.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH 0/5] Start of a journey: drop NO_THE_INDEX_COMPATIBILITY_MACROS","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-05-05T17:29:56Z","receivedAt":"2017-05-05T17:30:04Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"On 05/05, Junio C Hamano wrote:\n> Jonathan Nieder <jrnieder@gmail.com> writes:\n> \n> > That is, one way to do what this series attempts would be the\n> > following:\n> >\n> >  1. rename variables that shadow the_index.\n> \n> No question about this one.  It is a good thing to do.\n> \n> >  2. add coccinelle patches (or one coccinelle patch) to\n> >     contrib/coccinelle implementing *_cache -> *_index migration.\n> >     Is there a way to do this without making it fail \"make coccicheck\"?\n> \n> Quite honestly, I do not see much value in this, but take it merely\n> as my knee-jerk reaction.  The only scenario I can think of in which\n> dropping *_cache() macros is an improvement as the end result is\n> when our goal is to completely drop the singleton index_state\n> instance, aka \"the_index\".  I actually think that it may be a\n> worthwhile goal to eradicate \"the_index\".\n> \n> I wonder if somebody can take a small example codepath and make it\n> not to rely on the existence of \"the_index\" from start to end?  Have\n> an instance of index_state on the stack of cmd_foo(), have it call\n> read_index() into it where it currently calls read_cache(), update\n> the support functions it calls so that it can pass the pointer to\n> its index_info throughout the callchain, and see how involved the\n> necessary changes of all of the above are.  Start from something\n> simple and small, e.g. \"ls-files\".  The infrastructure code updated\n> for such an experiment may be NO_THE_INDEX_COMPATIBILITY_MACROS\n> clean.\n\nI've mentioned elsewhere but I've been working on this for 'ls-files'.\nThere's quite a few \"gotchas\" but its given me a good idea of which\nsections of code need to be converted to taking in a\n'struct index_state'.  I'll send some of this conversion out later today\nas a RFC and see what people think about it and if its worth while to\ncontinue.\n\n-- \nBrandon Williams\n"}]}