{"thread":{"id":"34390","subject":"[PATCH] Convert \"struct cache_entry *\" to \"const ...\" wherever possible","startedAt":"2013-07-09T15:29:00Z","lastAt":"2013-07-09T16:15:48Z","messageCount":2,"participants":["Nguyễn Thái Ngọc Duy","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"222929","messageId":"1373383740-24440-1-git-send-email-pclouds@gmail.com","threadId":"34390","inReplyTo":null,"subject":"[PATCH] Convert \"struct cache_entry *\" to \"const ...\" wherever possible","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2013-07-09T15:29:00Z","receivedAt":"2013-07-09T15:29:00Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"I attempted to make index_state->cache[] a \"const struct cache_entry **\"\nto find out how existing entries in index are modified and where. The\nquestion I have is what do we do if we really need to keep track of on-disk\nchanges in the index. The result is\n\n - diff-lib.c: setting CE_UPTODATE\n\n - name-hash.c: setting CE_HASHED\n\n - preload-index.c, read-cache.c, unpack-trees.c and\n   builtin/update-index: obvious\n\n - entry.c: write_entry() may refresh the checked out entry via\n   fill_stat_cache_info(). This causes \"non-const struct cache_entry\n   *\" in builtin/apply.c, builtin/checkout-index.c and\n   builtin/checkout.c\n\n - builtin/ls-files.c: --with-tree changes stagemask and may set\n   CE_UPDATE\n\nOf these, write_entry() and its call sites are probably most\ninteresting because it modifies on-disk info. But this is stat info\nand can be retrieved via refresh, at least for porcelain\ncommands. Other just uses ce_flags for local purposes.\n\nSo, keeping track of \"dirty\" entries is just a matter of setting a\nflag in index modification functions exposed by read-cache.c. Except\nunpack-trees, the rest of the code base does not do anything funny\nbehind read-cache's back.\n\nThe actual patch is less valueable than the summary above. But if\nanyone wants to re-identify the above sites. Applying this patch, then\nthis:\n\n    diff --git a/cache.h b/cache.h\n    index 430d021..1692891 100644\n    --- a/cache.h\n    +++ b/cache.h\n    @@ -267,7 +267,7 @@ static inline unsigned int canon_mode(unsigned int mode)\n     #define cache_entry_size(len) (offsetof(struct cache_entry,name) + (len) + 1)\n    \n     struct index_state {\n    -\tstruct cache_entry **cache;\n    +\tconst struct cache_entry **cache;\n     \tunsigned int version;\n     \tunsigned int cache_nr, cache_alloc, cache_changed;\n     \tstruct string_list *resolve_undo;\n\nwill help quickly identify them without bogus warnings.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/apply.c        | 13 +++++++------\n builtin/checkout.c     |  8 ++++----\n builtin/clean.c        |  2 +-\n builtin/commit.c       |  2 +-\n builtin/grep.c         |  2 +-\n builtin/ls-files.c     | 12 ++++++------\n builtin/merge-index.c  |  4 ++--\n builtin/merge.c        |  2 +-\n builtin/rm.c           |  6 +++---\n builtin/update-index.c | 14 +++++++-------\n cache-tree.c           | 19 ++++++++++---------\n cache-tree.h           |  2 +-\n cache.h                |  2 +-\n diff.c                 |  2 +-\n dir.c                  |  6 +++---\n entry.c                | 12 +++++++-----\n merge-recursive.c      |  7 ++++---\n pathspec.c             |  4 ++--\n read-cache.c           |  2 +-\n rerere.c               | 12 ++++++------\n resolve-undo.c         |  6 +++---\n revision.c             |  2 +-\n sequencer.c            |  7 ++++---\n sha1_name.c            |  4 ++--\n submodule.c            |  2 +-\n test-dump-cache-tree.c |  4 +++-\n tree.c                 |  2 +-\n unpack-trees.c         | 14 +++++++-------\n wt-status.c            |  4 ++--\n 29 files changed, 93 insertions(+), 85 deletions(-)\n\ndiff --git a/builtin/apply.c b/builtin/apply.c\nindex 0e9b631..023bb3a 100644\n--- a/builtin/apply.c\n+++ b/builtin/apply.c\n@@ -2999,7 +2999,7 @@ static int read_blob_object(struct strbuf *buf, const unsigned char *sha1, unsig\n \treturn 0;\n }\n \n-static int read_file_or_gitlink(struct cache_entry *ce, struct strbuf *buf)\n+static int read_file_or_gitlink(const struct cache_entry *ce, struct strbuf *buf)\n {\n \tif (!ce)\n \t\treturn 0;\n@@ -3117,7 +3117,7 @@ static struct patch *previous_patch(struct patch *patch, int *gone)\n \treturn previous;\n }\n \n-static int verify_index_match(struct cache_entry *ce, struct stat *st)\n+static int verify_index_match(const struct cache_entry *ce, struct stat *st)\n {\n \tif (S_ISGITLINK(ce->ce_mode)) {\n \t\tif (!S_ISDIR(st->st_mode))\n@@ -3130,7 +3130,7 @@ static int verify_index_match(struct cache_entry *ce, struct stat *st)\n #define SUBMODULE_PATCH_WITHOUT_INDEX 1\n \n static int load_patch_target(struct strbuf *buf,\n-\t\t\t     struct cache_entry *ce,\n+\t\t\t     const struct cache_entry *ce,\n \t\t\t     struct stat *st,\n \t\t\t     const char *name,\n \t\t\t     unsigned expected_mode)\n@@ -3160,7 +3160,8 @@ static int load_patch_target(struct strbuf *buf,\n  * we read from the result of a previous diff.\n  */\n static int load_preimage(struct image *image,\n-\t\t\t struct patch *patch, struct stat *st, struct cache_entry *ce)\n+\t\t\t struct patch *patch, struct stat *st,\n+\t\t\t const struct cache_entry *ce)\n {\n \tstruct strbuf buf = STRBUF_INIT;\n \tsize_t len;\n@@ -3273,7 +3274,7 @@ static int load_current(struct image *image, struct patch *patch)\n }\n \n static int try_threeway(struct image *image, struct patch *patch,\n-\t\t\tstruct stat *st, struct cache_entry *ce)\n+\t\t\tstruct stat *st, const struct cache_entry *ce)\n {\n \tunsigned char pre_sha1[20], post_sha1[20], our_sha1[20];\n \tstruct strbuf buf = STRBUF_INIT;\n@@ -3343,7 +3344,7 @@ static int try_threeway(struct image *image, struct patch *patch,\n \treturn 0;\n }\n \n-static int apply_data(struct patch *patch, struct stat *st, struct cache_entry *ce)\n+static int apply_data(struct patch *patch, struct stat *st, const struct cache_entry *ce)\n {\n \tstruct image image;\n \ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex 3be0018..69f9efa 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -97,7 +97,7 @@ static int read_tree_some(struct tree *tree, const char **pathspec)\n \treturn 0;\n }\n \n-static int skip_same_name(struct cache_entry *ce, int pos)\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@@ -105,7 +105,7 @@ static int skip_same_name(struct cache_entry *ce, int pos)\n \treturn pos;\n }\n \n-static int check_stage(int stage, struct cache_entry *ce, int pos)\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@@ -119,7 +119,7 @@ static int check_stage(int stage, struct cache_entry *ce, int pos)\n \t\treturn error(_(\"path '%s' does not have their version\"), ce->name);\n }\n \n-static int check_stages(unsigned stages, struct cache_entry *ce, int pos)\n+static int check_stages(unsigned stages, const struct cache_entry *ce, int pos)\n {\n \tunsigned seen = 0;\n \tconst char *name = ce->name;\n@@ -321,7 +321,7 @@ static int checkout_paths(const struct checkout_opts *opts,\n \n \t/* Any unmerged paths? */\n \tfor (pos = 0; pos < active_nr; pos++) {\n-\t\tstruct cache_entry *ce = active_cache[pos];\n+\t\tconst struct cache_entry *ce = active_cache[pos];\n \t\tif (ce->ce_flags & CE_MATCHED) {\n \t\t\tif (!ce_stage(ce))\n \t\t\t\tcontinue;\ndiff --git a/builtin/clean.c b/builtin/clean.c\nindex 04e396b..e344137 100644\n--- a/builtin/clean.c\n+++ b/builtin/clean.c\n@@ -221,7 +221,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix)\n \t\tstruct dir_entry *ent = dir.entries[i];\n \t\tint len, pos;\n \t\tint matches = 0;\n-\t\tstruct cache_entry *ce;\n+\t\tconst struct cache_entry *ce;\n \t\tstruct stat st;\n \n \t\t/*\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 6b693c1..c9cbb81 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -205,7 +205,7 @@ static int list_paths(struct string_list *list, const char *with_tree,\n \t}\n \n \tfor (i = 0; i < active_nr; i++) {\n-\t\tstruct cache_entry *ce = active_cache[i];\n+\t\tconst struct cache_entry *ce = active_cache[i];\n \t\tstruct string_list_item *item;\n \n \t\tif (ce->ce_flags & CE_UPDATE)\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 159e65d..0223d70 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -376,7 +376,7 @@ static int grep_cache(struct grep_opt *opt, const struct pathspec *pathspec, int\n \tread_cache();\n \n \tfor (nr = 0; nr < active_nr; nr++) {\n-\t\tstruct cache_entry *ce = active_cache[nr];\n+\t\tconst struct cache_entry *ce = active_cache[nr];\n \t\tif (!S_ISREG(ce->ce_mode))\n \t\t\tcontinue;\n \t\tif (!match_pathspec_depth(pathspec, ce->name, ce_namelen(ce), 0, NULL))\ndiff --git a/builtin/ls-files.c b/builtin/ls-files.c\nindex 3a410c3..80fff23 100644\n--- a/builtin/ls-files.c\n+++ b/builtin/ls-files.c\n@@ -127,7 +127,7 @@ static void show_killed_files(struct dir_struct *dir)\n \t}\n }\n \n-static void show_ce_entry(const char *tag, struct cache_entry *ce)\n+static void show_ce_entry(const char *tag, const struct cache_entry *ce)\n {\n \tint len = max_prefix_len;\n \n@@ -165,7 +165,7 @@ static void show_ce_entry(const char *tag, struct cache_entry *ce)\n \t}\n \twrite_name(ce->name, ce_namelen(ce));\n \tif (debug_mode) {\n-\t\tstruct stat_data *sd = &ce->ce_stat_data;\n+\t\tconst struct stat_data *sd = &ce->ce_stat_data;\n \n \t\tprintf(\"  ctime: %d:%d\\n\", sd->sd_ctime.sec, sd->sd_ctime.nsec);\n \t\tprintf(\"  mtime: %d:%d\\n\", sd->sd_mtime.sec, sd->sd_mtime.nsec);\n@@ -203,7 +203,7 @@ static void show_ru_info(void)\n \t}\n }\n \n-static int ce_excluded(struct dir_struct *dir, struct cache_entry *ce)\n+static int ce_excluded(struct dir_struct *dir, const struct cache_entry *ce)\n {\n \tint dtype = ce_to_dtype(ce);\n \treturn is_excluded(dir, ce->name, &dtype);\n@@ -223,7 +223,7 @@ static void show_files(struct dir_struct *dir)\n \t}\n \tif (show_cached || show_stage) {\n \t\tfor (i = 0; i < active_nr; i++) {\n-\t\t\tstruct cache_entry *ce = active_cache[i];\n+\t\t\tconst struct cache_entry *ce = active_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@@ -237,7 +237,7 @@ static void show_files(struct dir_struct *dir)\n \t}\n \tif (show_deleted || show_modified) {\n \t\tfor (i = 0; i < active_nr; i++) {\n-\t\t\tstruct cache_entry *ce = active_cache[i];\n+\t\t\tconst struct cache_entry *ce = active_cache[i];\n \t\t\tstruct stat st;\n \t\t\tint err;\n \t\t\tif ((dir->flags & DIR_SHOW_IGNORED) &&\n@@ -273,7 +273,7 @@ static void prune_cache(const char *prefix)\n \tlast = active_nr;\n \twhile (last > first) {\n \t\tint next = (last + first) >> 1;\n-\t\tstruct cache_entry *ce = active_cache[next];\n+\t\tconst struct cache_entry *ce = active_cache[next];\n \t\tif (!strncmp(ce->name, prefix, max_prefix_len)) {\n \t\t\tfirst = next+1;\n \t\t\tcontinue;\ndiff --git a/builtin/merge-index.c b/builtin/merge-index.c\nindex be5e514..b416d92 100644\n--- a/builtin/merge-index.c\n+++ b/builtin/merge-index.c\n@@ -16,7 +16,7 @@ static int merge_entry(int pos, const char *path)\n \t\tdie(\"git merge-index: %s not in the cache\", path);\n \tfound = 0;\n \tdo {\n-\t\tstruct cache_entry *ce = active_cache[pos];\n+\t\tconst struct cache_entry *ce = active_cache[pos];\n \t\tint stage = ce_stage(ce);\n \n \t\tif (strcmp(ce->name, path))\n@@ -58,7 +58,7 @@ static void merge_all(void)\n {\n \tint i;\n \tfor (i = 0; i < active_nr; i++) {\n-\t\tstruct cache_entry *ce = active_cache[i];\n+\t\tconst struct cache_entry *ce = active_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 2ebe732..74c0746 100644\n--- a/builtin/merge.c\n+++ b/builtin/merge.c\n@@ -889,7 +889,7 @@ static int suggest_conflicts(int renormalizing)\n \t\tdie_errno(_(\"Could not open '%s' for writing\"), filename);\n \tfprintf(fp, \"\\nConflicts:\\n\");\n \tfor (pos = 0; pos < active_nr; pos++) {\n-\t\tstruct cache_entry *ce = active_cache[pos];\n+\t\tconst struct cache_entry *ce = active_cache[pos];\n \n \t\tif (ce_stage(ce)) {\n \t\t\tfprintf(fp, \"\\t%s\\n\", ce->name);\ndiff --git a/builtin/rm.c b/builtin/rm.c\nindex 06025a2..18916e0 100644\n--- a/builtin/rm.c\n+++ b/builtin/rm.c\n@@ -67,7 +67,7 @@ static int check_submodules_use_gitfiles(void)\n \tfor (i = 0; i < list.nr; i++) {\n \t\tconst char *name = list.entry[i].name;\n \t\tint pos;\n-\t\tstruct cache_entry *ce;\n+\t\tconst struct cache_entry *ce;\n \t\tstruct stat st;\n \n \t\tpos = cache_name_pos(name, strlen(name));\n@@ -120,7 +120,7 @@ static int check_local_mod(unsigned char *head, int index_only)\n \tfor (i = 0; i < list.nr; i++) {\n \t\tstruct stat st;\n \t\tint pos;\n-\t\tstruct cache_entry *ce;\n+\t\tconst struct cache_entry *ce;\n \t\tconst char *name = list.entry[i].name;\n \t\tunsigned char sha1[20];\n \t\tunsigned mode;\n@@ -321,7 +321,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)\n \tseen = xcalloc(i, 1);\n \n \tfor (i = 0; i < active_nr; i++) {\n-\t\tstruct cache_entry *ce = active_cache[i];\n+\t\tconst struct cache_entry *ce = active_cache[i];\n \t\tif (!match_pathspec(pathspec, ce->name, ce_namelen(ce), 0, seen))\n \t\t\tcontinue;\n \t\tALLOC_GROW(list.entry, list.nr + 1, list.alloc);\ndiff --git a/builtin/update-index.c b/builtin/update-index.c\nindex 5c7762e..c317981 100644\n--- a/builtin/update-index.c\n+++ b/builtin/update-index.c\n@@ -83,7 +83,7 @@ static int process_lstat_error(const char *path, int err)\n \treturn error(\"lstat(\\\"%s\\\"): %s\", path, strerror(errno));\n }\n \n-static int add_one_path(struct cache_entry *old, const char *path, int len, struct stat *st)\n+static int add_one_path(const struct cache_entry *old, const char *path, int len, struct stat *st)\n {\n \tint option, size;\n \tstruct cache_entry *ce;\n@@ -142,7 +142,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\tstruct cache_entry *ce = active_cache[pos];\n+\t\tconst struct cache_entry *ce = active_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@@ -158,7 +158,7 @@ static int process_directory(const char *path, int len, struct stat *st)\n \t/* Inexact match: is there perhaps a subdirectory match? */\n \tpos = -pos-1;\n \twhile (pos < active_nr) {\n-\t\tstruct cache_entry *ce = active_cache[pos++];\n+\t\tconst struct cache_entry *ce = active_cache[pos++];\n \n \t\tif (strncmp(ce->name, path, len))\n \t\t\tbreak;\n@@ -183,7 +183,7 @@ static int process_path(const char *path)\n {\n \tint pos, len;\n \tstruct stat st;\n-\tstruct cache_entry *ce;\n+\tconst struct cache_entry *ce;\n \n \tlen = strlen(path);\n \tif (has_symlink_leading_path(path, len))\n@@ -448,7 +448,7 @@ static int unresolve_one(const char *path)\n \t\t/* already merged */\n \t\tpos = unmerge_cache_entry_at(pos);\n \t\tif (pos < active_nr) {\n-\t\t\tstruct cache_entry *ce = active_cache[pos];\n+\t\t\tconst struct cache_entry *ce = active_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@@ -462,7 +462,7 @@ static int unresolve_one(const char *path)\n \t\t */\n \t\tpos = -pos-1;\n \t\tif (pos < active_nr) {\n-\t\t\tstruct cache_entry *ce = active_cache[pos];\n+\t\t\tconst struct cache_entry *ce = active_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@@ -558,7 +558,7 @@ static int do_reupdate(int ac, const char **av,\n \t\thas_head = 0;\n  redo:\n \tfor (pos = 0; pos < active_nr; pos++) {\n-\t\tstruct cache_entry *ce = active_cache[pos];\n+\t\tconst struct cache_entry *ce = active_cache[pos];\n \t\tstruct cache_entry *old = NULL;\n \t\tint save_nr;\n \ndiff --git a/cache-tree.c b/cache-tree.c\nindex 37e4d00..0bbec43 100644\n--- a/cache-tree.c\n+++ b/cache-tree.c\n@@ -149,7 +149,7 @@ void cache_tree_invalidate_path(struct cache_tree *it, const char *path)\n \t\tcache_tree_invalidate_path(down->cache_tree, slash + 1);\n }\n \n-static int verify_cache(struct cache_entry **cache,\n+static int verify_cache(const struct cache_entry * const *cache,\n \t\t\tint entries, int flags)\n {\n \tint i, funny;\n@@ -158,7 +158,7 @@ static int verify_cache(struct cache_entry **cache,\n \t/* Verify that the tree is merged */\n \tfunny = 0;\n \tfor (i = 0; i < entries; i++) {\n-\t\tstruct cache_entry *ce = cache[i];\n+\t\tconst struct cache_entry *ce = cache[i];\n \t\tif (ce_stage(ce)) {\n \t\t\tif (silent)\n \t\t\t\treturn -1;\n@@ -234,7 +234,7 @@ int cache_tree_fully_valid(struct cache_tree *it)\n }\n \n static int update_one(struct cache_tree *it,\n-\t\t      struct cache_entry **cache,\n+\t\t      const struct cache_entry * const *cache,\n \t\t      int entries,\n \t\t      const char *base,\n \t\t      int baselen,\n@@ -265,7 +265,7 @@ static int update_one(struct cache_tree *it,\n \t */\n \ti = 0;\n \twhile (i < entries) {\n-\t\tstruct cache_entry *ce = cache[i];\n+\t\tconst struct cache_entry *ce = cache[i];\n \t\tstruct cache_tree_sub *sub;\n \t\tconst char *path, *slash;\n \t\tint pathlen, sublen, subcnt, subskip;\n@@ -312,7 +312,7 @@ static int update_one(struct cache_tree *it,\n \n \ti = 0;\n \twhile (i < entries) {\n-\t\tstruct cache_entry *ce = cache[i];\n+\t\tconst struct cache_entry *ce = cache[i];\n \t\tstruct cache_tree_sub *sub;\n \t\tconst char *path, *slash;\n \t\tint pathlen, entlen;\n@@ -397,7 +397,7 @@ static int update_one(struct cache_tree *it,\n }\n \n int cache_tree_update(struct cache_tree *it,\n-\t\t      struct cache_entry **cache,\n+\t\t      const struct cache_entry * const *cache,\n \t\t      int entries,\n \t\t      int flags)\n {\n@@ -599,8 +599,8 @@ int write_cache_as_tree(unsigned char *sha1, int flags, const char *prefix)\n \twas_valid = cache_tree_fully_valid(active_cache_tree);\n \tif (!was_valid) {\n \t\tif (cache_tree_update(active_cache_tree,\n-\t\t\t\t      active_cache, active_nr,\n-\t\t\t\t      flags) < 0)\n+\t\t\t\t      (const struct cache_entry * const *)active_cache,\n+\t\t\t\t      active_nr, flags) < 0)\n \t\t\treturn WRITE_TREE_UNMERGED_INDEX;\n \t\tif (0 <= newfd) {\n \t\t\tif (!write_cache(newfd, active_cache, active_nr) &&\n@@ -701,5 +701,6 @@ int update_main_cache_tree(int flags)\n \tif (!the_index.cache_tree)\n \t\tthe_index.cache_tree = cache_tree();\n \treturn cache_tree_update(the_index.cache_tree,\n-\t\t\t\t the_index.cache, the_index.cache_nr, flags);\n+\t\t\t\t (const struct cache_entry * const *)the_index.cache,\n+\t\t\t\t the_index.cache_nr, flags);\n }\ndiff --git a/cache-tree.h b/cache-tree.h\nindex 55d0f59..f1923ad 100644\n--- a/cache-tree.h\n+++ b/cache-tree.h\n@@ -30,7 +30,7 @@ void cache_tree_write(struct strbuf *, struct cache_tree *root);\n struct cache_tree *cache_tree_read(const char *buffer, unsigned long size);\n \n int cache_tree_fully_valid(struct cache_tree *);\n-int cache_tree_update(struct cache_tree *, struct cache_entry **, int, int);\n+int cache_tree_update(struct cache_tree *, const struct cache_entry * const *, int, int);\n \n int update_main_cache_tree(int);\n \ndiff --git a/cache.h b/cache.h\nindex dd0fb33..430d021 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -476,7 +476,7 @@ extern int remove_file_from_index(struct index_state *, const char *path);\n extern int add_to_index(struct index_state *, const char *path, struct stat *, int flags);\n extern int add_file_to_index(struct index_state *, const char *path, int flags);\n extern struct cache_entry *make_cache_entry(unsigned int mode, const unsigned char *sha1, const char *path, int stage, int refresh);\n-extern int ce_same_name(struct cache_entry *a, struct cache_entry *b);\n+extern int ce_same_name(const struct cache_entry *a, const struct cache_entry *b);\n extern int index_name_is_other(const struct index_state *, const char *, int);\n extern void *read_blob_data_from_index(struct index_state *, const char *, unsigned long *);\n \ndiff --git a/diff.c b/diff.c\nindex 208094f..126abbf 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -2586,7 +2586,7 @@ void fill_filespec(struct diff_filespec *spec, const unsigned char *sha1,\n  */\n static int reuse_worktree_file(const char *name, const unsigned char *sha1, int want_file)\n {\n-\tstruct cache_entry *ce;\n+\tconst struct cache_entry *ce;\n \tstruct stat st;\n \tint pos, len;\n \ndiff --git a/dir.c b/dir.c\nindex 897c874..bb1f4e4 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -933,7 +933,7 @@ enum exist_status {\n  */\n static enum exist_status directory_exists_in_index_icase(const char *dirname, int len)\n {\n-\tstruct cache_entry *ce = index_name_exists(&the_index, dirname, len + 1, ignore_case);\n+\tconst struct cache_entry *ce = index_name_exists(&the_index, dirname, len + 1, ignore_case);\n \tunsigned char endchar;\n \n \tif (!ce)\n@@ -977,7 +977,7 @@ static enum exist_status directory_exists_in_index(const char *dirname, int len)\n \tif (pos < 0)\n \t\tpos = -pos-1;\n \twhile (pos < active_nr) {\n-\t\tstruct cache_entry *ce = active_cache[pos++];\n+\t\tconst struct cache_entry *ce = active_cache[pos++];\n \t\tunsigned char endchar;\n \n \t\tif (strncmp(ce->name, dirname, len))\n@@ -1115,7 +1115,7 @@ static int exclude_matches_pathspec(const char *path, int len,\n static int get_index_dtype(const char *path, int len)\n {\n \tint pos;\n-\tstruct cache_entry *ce;\n+\tconst struct cache_entry *ce;\n \n \tce = cache_name_exists(path, len, 0);\n \tif (ce) {\ndiff --git a/entry.c b/entry.c\nindex d7c131d..c6f7fd7 100644\n--- a/entry.c\n+++ b/entry.c\n@@ -79,7 +79,7 @@ static int create_file(const char *path, unsigned int mode)\n \treturn open(path, O_WRONLY | O_CREAT | O_EXCL, mode);\n }\n \n-static void *read_blob_entry(struct cache_entry *ce, unsigned long *size)\n+static void *read_blob_entry(const struct cache_entry *ce, unsigned long *size)\n {\n \tenum object_type type;\n \tvoid *new = read_sha1_file(ce->sha1, &type, size);\n@@ -92,7 +92,7 @@ static void *read_blob_entry(struct cache_entry *ce, unsigned long *size)\n \treturn NULL;\n }\n \n-static int open_output_fd(char *path, struct cache_entry *ce, int to_tempfile)\n+static int open_output_fd(char *path, const struct cache_entry *ce, int to_tempfile)\n {\n \tint symlink = (ce->ce_mode & S_IFMT) != S_IFREG;\n \tif (to_tempfile) {\n@@ -115,7 +115,7 @@ static int fstat_output(int fd, const struct checkout *state, struct stat *st)\n \treturn 0;\n }\n \n-static int streaming_write_entry(struct cache_entry *ce, char *path,\n+static int streaming_write_entry(const struct cache_entry *ce, char *path,\n \t\t\t\t struct stream_filter *filter,\n \t\t\t\t const struct checkout *state, int to_tempfile,\n \t\t\t\t int *fstat_done, struct stat *statbuf)\n@@ -136,7 +136,8 @@ static int streaming_write_entry(struct cache_entry *ce, char *path,\n \treturn result;\n }\n \n-static int write_entry(struct cache_entry *ce, char *path, const struct checkout *state, int to_tempfile)\n+static int write_entry(struct cache_entry *ce,\n+\t\t       char *path, const struct checkout *state, int to_tempfile)\n {\n \tunsigned int ce_mode_s_ifmt = ce->ce_mode & S_IFMT;\n \tint fd, ret, fstat_done = 0;\n@@ -233,7 +234,8 @@ static int check_path(const char *path, int len, struct stat *st, int skiplen)\n \treturn lstat(path, st);\n }\n \n-int checkout_entry(struct cache_entry *ce, const struct checkout *state, char *topath)\n+int checkout_entry(struct cache_entry *ce,\n+\t\t   const struct checkout *state, char *topath)\n {\n \tstatic char path[PATH_MAX + 1];\n \tstruct stat st;\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex ea9dbd3..f95933b 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -251,7 +251,7 @@ struct tree *write_tree_from_memory(struct merge_options *o)\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\tstruct cache_entry *ce = active_cache[i];\n+\t\t\tconst struct cache_entry *ce = active_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@@ -264,7 +264,8 @@ struct tree *write_tree_from_memory(struct merge_options *o)\n \n \tif (!cache_tree_fully_valid(active_cache_tree) &&\n \t    cache_tree_update(active_cache_tree,\n-\t\t\t      active_cache, active_nr, 0) < 0)\n+\t\t\t      (const struct cache_entry * const *)active_cache,\n+\t\t\t      active_nr, 0) < 0)\n \t\tdie(_(\"error building trees\"));\n \n \tresult = lookup_tree(active_cache_tree->sha1);\n@@ -339,7 +340,7 @@ static struct string_list *get_unmerged(void)\n \tfor (i = 0; i < active_nr; i++) {\n \t\tstruct string_list_item *item;\n \t\tstruct stage_data *e;\n-\t\tstruct cache_entry *ce = active_cache[i];\n+\t\tconst struct cache_entry *ce = active_cache[i];\n \t\tif (!ce_stage(ce))\n \t\t\tcontinue;\n \ndiff --git a/pathspec.c b/pathspec.c\nindex 284f397..6ea0867 100644\n--- a/pathspec.c\n+++ b/pathspec.c\n@@ -32,7 +32,7 @@ void add_pathspec_matches_against_index(const char **pathspec,\n \tif (!num_unmatched)\n \t\treturn;\n \tfor (i = 0; i < active_nr; i++) {\n-\t\tstruct cache_entry *ce = active_cache[i];\n+\t\tconst struct cache_entry *ce = active_cache[i];\n \t\tmatch_pathspec(pathspec, ce->name, ce_namelen(ce), 0, seen);\n \t}\n }\n@@ -67,7 +67,7 @@ const char *check_path_for_gitlink(const char *path)\n {\n \tint i, path_len = strlen(path);\n \tfor (i = 0; i < active_nr; i++) {\n-\t\tstruct cache_entry *ce = active_cache[i];\n+\t\tconst struct cache_entry *ce = active_cache[i];\n \t\tif (S_ISGITLINK(ce->ce_mode)) {\n \t\t\tint ce_len = ce_namelen(ce);\n \t\t\tif (path_len <= ce_len || path[ce_len] != '/' ||\ndiff --git a/read-cache.c b/read-cache.c\nindex d5201f9..d4474ea 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -722,7 +722,7 @@ struct cache_entry *make_cache_entry(unsigned int mode,\n \treturn ce;\n }\n \n-int ce_same_name(struct cache_entry *a, struct cache_entry *b)\n+int ce_same_name(const struct cache_entry *a, const struct cache_entry *b)\n {\n \tint len = ce_namelen(a);\n \treturn ce_namelen(b) == len && !memcmp(a->name, b->name, len);\ndiff --git a/rerere.c b/rerere.c\nindex 98e3e29..6fde8f9 100644\n--- a/rerere.c\n+++ b/rerere.c\n@@ -299,7 +299,7 @@ static int handle_cache(const char *path, unsigned char *sha1, const char *outpu\n {\n \tmmfile_t mmfile[3] = {{NULL}};\n \tmmbuffer_t result = {NULL, 0};\n-\tstruct cache_entry *ce;\n+\tconst struct cache_entry *ce;\n \tint pos, len, i, hunk_no;\n \tstruct rerere_io_mem io;\n \tint marker_size = ll_merge_marker_size(path);\n@@ -359,7 +359,7 @@ static int handle_cache(const char *path, unsigned char *sha1, const char *outpu\n \n static int check_one_conflict(int i, int *type)\n {\n-\tstruct cache_entry *e = active_cache[i];\n+\tconst struct cache_entry *e = active_cache[i];\n \n \tif (!ce_stage(e)) {\n \t\t*type = RESOLVED;\n@@ -374,8 +374,8 @@ static int check_one_conflict(int i, int *type)\n \n \t/* Only handle regular files with both stages #2 and #3 */\n \tif (i + 1 < active_nr) {\n-\t\tstruct cache_entry *e2 = active_cache[i];\n-\t\tstruct cache_entry *e3 = active_cache[i + 1];\n+\t\tconst struct cache_entry *e2 = active_cache[i];\n+\t\tconst struct cache_entry *e3 = active_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@@ -398,7 +398,7 @@ static int find_conflict(struct string_list *conflict)\n \n \tfor (i = 0; i < active_nr;) {\n \t\tint conflict_type;\n-\t\tstruct cache_entry *e = active_cache[i];\n+\t\tconst struct cache_entry *e = active_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@@ -414,7 +414,7 @@ int rerere_remaining(struct string_list *merge_rr)\n \n \tfor (i = 0; i < active_nr;) {\n \t\tint conflict_type;\n-\t\tstruct cache_entry *e = active_cache[i];\n+\t\tconst struct cache_entry *e = active_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);\ndiff --git a/resolve-undo.c b/resolve-undo.c\nindex 639eb9c..77101f5 100644\n--- a/resolve-undo.c\n+++ b/resolve-undo.c\n@@ -115,7 +115,7 @@ void resolve_undo_clear_index(struct index_state *istate)\n \n int unmerge_index_entry_at(struct index_state *istate, int pos)\n {\n-\tstruct cache_entry *ce;\n+\tconst struct cache_entry *ce;\n \tstruct string_list_item *item;\n \tstruct resolve_undo_info *ru;\n \tint i, err = 0, matched;\n@@ -167,7 +167,7 @@ void unmerge_marked_index(struct index_state *istate)\n \t\treturn;\n \n \tfor (i = 0; i < istate->cache_nr; i++) {\n-\t\tstruct cache_entry *ce = istate->cache[i];\n+\t\tconst struct cache_entry *ce = istate->cache[i];\n \t\tif (ce->ce_flags & CE_MATCHED)\n \t\t\ti = unmerge_index_entry_at(istate, i);\n \t}\n@@ -181,7 +181,7 @@ void unmerge_index(struct index_state *istate, const char **pathspec)\n \t\treturn;\n \n \tfor (i = 0; i < istate->cache_nr; i++) {\n-\t\tstruct cache_entry *ce = istate->cache[i];\n+\t\tconst struct cache_entry *ce = istate->cache[i];\n \t\tif (!match_pathspec(pathspec, ce->name, ce_namelen(ce), 0, NULL))\n \t\t\tcontinue;\n \t\ti = unmerge_index_entry_at(istate, i);\ndiff --git a/revision.c b/revision.c\nindex 2f0142f..84ccc05 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -1358,7 +1358,7 @@ static void prepare_show_merge(struct rev_info *revs)\n \tif (!active_nr)\n \t\tread_cache();\n \tfor (i = 0; i < active_nr; i++) {\n-\t\tstruct cache_entry *ce = active_cache[i];\n+\t\tconst struct cache_entry *ce = active_cache[i];\n \t\tif (!ce_stage(ce))\n \t\t\tcontinue;\n \t\tif (ce_path_match(ce, &revs->prune_data)) {\ndiff --git a/sequencer.c b/sequencer.c\nindex 425207a..351548f 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -331,7 +331,7 @@ static int do_recursive_merge(struct commit *base, struct commit *next,\n \t\tint i;\n \t\tstrbuf_addstr(msgbuf, \"\\nConflicts:\\n\");\n \t\tfor (i = 0; i < active_nr;) {\n-\t\t\tstruct cache_entry *ce = active_cache[i++];\n+\t\t\tconst struct cache_entry *ce = active_cache[i++];\n \t\t\tif (ce_stage(ce)) {\n \t\t\t\tstrbuf_addch(msgbuf, '\\t');\n \t\t\t\tstrbuf_addstr(msgbuf, ce->name);\n@@ -371,8 +371,9 @@ static int is_index_unchanged(void)\n \t\tactive_cache_tree = cache_tree();\n \n \tif (!cache_tree_fully_valid(active_cache_tree))\n-\t\tif (cache_tree_update(active_cache_tree, active_cache,\n-\t\t\t\t  active_nr, 0))\n+\t\tif (cache_tree_update(active_cache_tree,\n+\t\t\t\t      (const struct cache_entry * const *)active_cache,\n+\t\t\t\t      active_nr, 0))\n \t\t\treturn error(_(\"Unable to update cache tree\\n\"));\n \n \treturn !hashcmp(active_cache_tree->sha1, head_commit->tree->object.sha1);\ndiff --git a/sha1_name.c b/sha1_name.c\nindex 90419ef..86e8a5c 100644\n--- a/sha1_name.c\n+++ b/sha1_name.c\n@@ -1234,7 +1234,7 @@ static void diagnose_invalid_index_path(int stage,\n \t\t\t\t\tconst char *filename)\n {\n \tstruct stat st;\n-\tstruct cache_entry *ce;\n+\tconst struct cache_entry *ce;\n \tint pos;\n \tunsigned namelen = strlen(filename);\n \tunsigned fullnamelen;\n@@ -1328,7 +1328,7 @@ static int get_sha1_with_context_1(const char *name,\n \t */\n \tif (name[0] == ':') {\n \t\tint stage = 0;\n-\t\tstruct cache_entry *ce;\n+\t\tconst struct cache_entry *ce;\n \t\tchar *new_path = NULL;\n \t\tint pos;\n \t\tif (!only_to_die && namelen > 2 && name[1] == '/') {\ndiff --git a/submodule.c b/submodule.c\nindex 8685424..4045d53 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -623,7 +623,7 @@ int fetch_populated_submodules(const struct argv_array *options,\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\tstruct cache_entry *ce = active_cache[i];\n+\t\tconst struct cache_entry *ce = active_cache[i];\n \t\tconst char *git_dir, *name, *default_argv;\n \n \t\tif (!S_ISGITLINK(ce->ce_mode))\ndiff --git a/test-dump-cache-tree.c b/test-dump-cache-tree.c\nindex a6ffdf3..47eab97 100644\n--- a/test-dump-cache-tree.c\n+++ b/test-dump-cache-tree.c\n@@ -59,6 +59,8 @@ int main(int ac, char **av)\n \tstruct cache_tree *another = cache_tree();\n \tif (read_cache() < 0)\n \t\tdie(\"unable to read index file\");\n-\tcache_tree_update(another, active_cache, active_nr, WRITE_TREE_DRY_RUN);\n+\tcache_tree_update(another,\n+\t\t\t  (const struct cache_entry * const *)active_cache,\n+\t\t\t  active_nr, WRITE_TREE_DRY_RUN);\n \treturn dump_cache_tree(active_cache_tree, another, \"\");\n }\ndiff --git a/tree.c b/tree.c\nindex 62fed63..c0e568c 100644\n--- a/tree.c\n+++ b/tree.c\n@@ -159,7 +159,7 @@ int read_tree(struct tree *tree, int stage, struct pathspec *match)\n \t * sort at the end.\n \t */\n \tfor (i = 0; !fn && i < active_nr; i++) {\n-\t\tstruct cache_entry *ce = active_cache[i];\n+\t\tconst struct cache_entry *ce = active_cache[i];\n \t\tif (ce_stage(ce) == stage)\n \t\t\tfn = read_one_entry;\n \t}\ndiff --git a/unpack-trees.c b/unpack-trees.c\nindex b27f2a6..bf01717 100644\n--- a/unpack-trees.c\n+++ b/unpack-trees.c\n@@ -179,7 +179,7 @@ static void display_error_msgs(struct unpack_trees_options *o)\n  * Unlink the last component and schedule the leading directories for\n  * removal, such that empty directories get removed.\n  */\n-static void unlink_entry(struct cache_entry *ce)\n+static void unlink_entry(const struct cache_entry *ce)\n {\n \tif (!check_leading_path(ce->name, ce_namelen(ce)))\n \t\treturn;\n@@ -199,7 +199,7 @@ static int check_updates(struct unpack_trees_options *o)\n \n \tif (o->update && o->verbose_update) {\n \t\tfor (total = cnt = 0; cnt < index->cache_nr; cnt++) {\n-\t\t\tstruct cache_entry *ce = index->cache[cnt];\n+\t\t\tconst struct cache_entry *ce = index->cache[cnt];\n \t\t\tif (ce->ce_flags & (CE_UPDATE | CE_WT_REMOVE))\n \t\t\t\ttotal++;\n \t\t}\n@@ -212,7 +212,7 @@ static int check_updates(struct unpack_trees_options *o)\n \tif (o->update)\n \t\tgit_attr_set_direction(GIT_ATTR_CHECKOUT, &o->result);\n \tfor (i = 0; i < index->cache_nr; i++) {\n-\t\tstruct cache_entry *ce = index->cache[i];\n+\t\tconst struct cache_entry *ce = index->cache[i];\n \n \t\tif (ce->ce_flags & CE_WT_REMOVE) {\n \t\t\tdisplay_progress(progress, ++cnt);\n@@ -376,7 +376,7 @@ static struct cache_entry *next_cache_entry(struct unpack_trees_options *o)\n \treturn NULL;\n }\n \n-static void add_same_unmerged(struct cache_entry *ce,\n+static void add_same_unmerged(const struct cache_entry *ce,\n \t\t\t      struct unpack_trees_options *o)\n {\n \tstruct index_state *index = o->src_index;\n@@ -650,7 +650,7 @@ static int find_cache_pos(struct traverse_info *info,\n \tint p_len = tree_entry_len(p);\n \n \tfor (pos = o->cache_bottom; pos < index->cache_nr; pos++) {\n-\t\tstruct cache_entry *ce = index->cache[pos];\n+\t\tconst struct cache_entry *ce = index->cache[pos];\n \t\tconst char *ce_name, *ce_slash;\n \t\tint cmp, ce_len;\n \n@@ -1353,7 +1353,7 @@ static int verify_clean_subdirectory(const struct cache_entry *ce,\n  */\n static int icase_exists(struct unpack_trees_options *o, const char *name, int len, struct stat *st)\n {\n-\tstruct cache_entry *src;\n+\tconst struct cache_entry *src;\n \n \tsrc = index_name_exists(o->src_index, name, len, 1);\n \treturn src && !ie_match_stat(o->src_index, src, st, CE_MATCH_IGNORE_VALID|CE_MATCH_IGNORE_SKIP_WORKTREE);\n@@ -1364,7 +1364,7 @@ static int check_ok_to_remove(const char *name, int len, int dtype,\n \t\t\t      enum unpack_trees_error_types error_type,\n \t\t\t      struct unpack_trees_options *o)\n {\n-\tstruct cache_entry *result;\n+\tconst struct cache_entry *result;\n \n \t/*\n \t * It may be that the 'lstat()' succeeded even though\ndiff --git a/wt-status.c b/wt-status.c\nindex b191c65..08aba7c 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -371,7 +371,7 @@ static void wt_status_collect_changed_cb(struct diff_queue_struct *q,\n static int unmerged_mask(const char *path)\n {\n \tint pos, mask;\n-\tstruct cache_entry *ce;\n+\tconst struct cache_entry *ce;\n \n \tpos = cache_name_pos(path, strlen(path));\n \tif (0 <= pos)\n@@ -475,7 +475,7 @@ static void wt_status_collect_changes_initial(struct wt_status *s)\n \tfor (i = 0; i < active_nr; i++) {\n \t\tstruct string_list_item *it;\n \t\tstruct wt_status_change_data *d;\n-\t\tstruct cache_entry *ce = active_cache[i];\n+\t\tconst struct cache_entry *ce = active_cache[i];\n \n \t\tif (!ce_path_match(ce, &pathspec))\n \t\t\tcontinue;\n-- \n1.8.2.83.gc99314b\n"},{"id":"222934","messageId":"7va9lvwvyj.fsf@alter.siamese.dyndns.org","threadId":"34390","inReplyTo":"1373383740-24440-1-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH] Convert \"struct cache_entry *\" to \"const ...\" wherever possible","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-07-09T16:15:48Z","receivedAt":"2013-07-09T16:15:48Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:\n\n> I attempted to make index_state->cache[] a \"const struct cache_entry **\"\n> to find out how existing entries in index are modified and where. The\n> question I have is what do we do if we really need to keep track of on-disk\n> changes in the index. The result is\n>\n>  - diff-lib.c: setting CE_UPTODATE\n>\n>  - name-hash.c: setting CE_HASHED\n>\n>  - preload-index.c, read-cache.c, unpack-trees.c and\n>    builtin/update-index: obvious\n>\n>  - entry.c: write_entry() may refresh the checked out entry via\n>    fill_stat_cache_info(). This causes \"non-const struct cache_entry\n>    *\" in builtin/apply.c, builtin/checkout-index.c and\n>    builtin/checkout.c\n>\n>  - builtin/ls-files.c: --with-tree changes stagemask and may set\n>    CE_UPDATE\n>\n> Of these, write_entry() and its call sites are probably most\n> interesting because it modifies on-disk info. But this is stat info\n> and can be retrieved via refresh, at least for porcelain\n> commands. Other just uses ce_flags for local purposes.\n>\n> So, keeping track of \"dirty\" entries is just a matter of setting a\n> flag in index modification functions exposed by read-cache.c. Except\n> unpack-trees, the rest of the code base does not do anything funny\n> behind read-cache's back.\n>\n> The actual patch is less valueable than the summary above. But if\n> anyone wants to re-identify the above sites. Applying this patch, then\n> this:\n>\n>     diff --git a/cache.h b/cache.h\n>     index 430d021..1692891 100644\n>     --- a/cache.h\n>     +++ b/cache.h\n>     @@ -267,7 +267,7 @@ static inline unsigned int canon_mode(unsigned int mode)\n>      #define cache_entry_size(len) (offsetof(struct cache_entry,name) + (len) + 1)\n>     \n>      struct index_state {\n>     -\tstruct cache_entry **cache;\n>     +\tconst struct cache_entry **cache;\n>      \tunsigned int version;\n>      \tunsigned int cache_nr, cache_alloc, cache_changed;\n>      \tstruct string_list *resolve_undo;\n>\n> will help quickly identify them without bogus warnings.\n\nNicely done and a very interesting result.  I quickly eyeballed the\noutput of\n\n$ git grep -e 'struct cache_entry' --and --not -e 'const struct cache_entry'\n\nand the result matches what I would expect to see.\n"}]}