path: root/builtin/update-index.c
diff options
authorChristian Couder <>2016-01-27 06:58:05 (GMT)
committerJunio C Hamano <>2016-01-27 20:30:00 (GMT)
commit435ec090ec6aed9c533e096b31947b3fa765548e (patch)
tree1c7669288cf6943b73ca531693013dcc02920308 /builtin/update-index.c
parent0e0f761842eafb51c1a5d93fbc84470e2d7ee7c3 (diff)
config: add core.untrackedCache
When we know that mtime on directory as given by the environment is usable for the purpose of untracked cache, we may want the untracked cache to be always used without any mtime test or kernel name check being performed. Also when we know that mtime is not usable for the purpose of untracked cache, for example because the repo is shared over a network file system, we may want the untracked-cache to be automatically removed from the index. Allow the user to express such preference by setting the 'core.untrackedCache' configuration variable, which can take 'keep', 'false', or 'true' and default to 'keep'. When read_index_from() is called, it now adds or removes the untracked cache in the index to respect the value of this variable. So it does nothing if the value is `keep` or if the variable is unset; it adds the untracked cache if the value is `true`; and it removes the cache if the value is `false`. `git update-index --[no-|force-]untracked-cache` still adds the untracked cache to, or removes it, from the index, but this shows a warning if it goes against the value of core.untrackedCache, because the next time the index is read the untracked cache will be added or removed if the configuration is set to do so. Also `--untracked-cache` used to check that the underlying operating system and file system change `st_mtime` field of a directory if files are added or deleted in that directory. But because those tests take a long time, `--untracked-cache` no longer performs them. Instead, there is now `--test-untracked-cache` to perform the tests. This change makes `--untracked-cache` the same as `--force-untracked-cache`. This last change is backward incompatible and should be mentioned in the release notes. Helped-by: Duy Nguyen <> Helped-by: Torsten Bögershausen <> Helped-by: Stefan Beller <> Signed-off-by: Christian Couder <> Signed-off-by: Ævar Arnfjörð Bjarmason <> read-cache: Duy'sfixup Signed-off-by: Christian Couder <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'builtin/update-index.c')
1 files changed, 24 insertions, 11 deletions
diff --git a/builtin/update-index.c b/builtin/update-index.c
index d90154c..7a55334 100644
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
@@ -1115,19 +1115,32 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
the_index.split_index = NULL;
the_index.cache_changed |= SOMETHING_CHANGED;
- if (untracked_cache > UC_DISABLE) {
- if (untracked_cache < UC_FORCE) {
- setup_work_tree();
- if (!test_if_untracked_cache_is_supported())
- return 1;
- if (untracked_cache == UC_TEST)
- return 0;
- }
- add_untracked_cache(&the_index);
- report(_("Untracked cache enabled for '%s'"), get_git_work_tree());
- } else if (untracked_cache == UC_DISABLE) {
+ switch (untracked_cache) {
+ break;
+ case UC_DISABLE:
+ if (git_config_get_untracked_cache() == 1)
+ warning("core.untrackedCache is set to true; "
+ "remove or change it, if you really want to "
+ "disable the untracked cache");
report(_("Untracked cache disabled"));
+ break;
+ case UC_TEST:
+ setup_work_tree();
+ return !test_if_untracked_cache_is_supported();
+ case UC_ENABLE:
+ case UC_FORCE:
+ if (git_config_get_untracked_cache() == 0)
+ warning("core.untrackedCache is set to false; "
+ "remove or change it, if you really want to "
+ "enable the untracked cache");
+ add_untracked_cache(&the_index);
+ report(_("Untracked cache enabled for '%s'"), get_git_work_tree());
+ break;
+ default:
+ die("Bug: bad untracked_cache value: %d", untracked_cache);
if (active_cache_changed) {