summaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorChristian Couder <christian.couder@gmail.com>2016-01-27 06:58:05 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-01-27 20:30:00 (GMT)
commit435ec090ec6aed9c533e096b31947b3fa765548e (patch)
tree1c7669288cf6943b73ca531693013dcc02920308 /config.c
parent0e0f761842eafb51c1a5d93fbc84470e2d7ee7c3 (diff)
downloadgit-435ec090ec6aed9c533e096b31947b3fa765548e.zip
git-435ec090ec6aed9c533e096b31947b3fa765548e.tar.gz
git-435ec090ec6aed9c533e096b31947b3fa765548e.tar.bz2
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 <pclouds@gmail.com> Helped-by: Torsten Bögershausen <tboegi@web.de> Helped-by: Stefan Beller <sbeller@google.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> read-cache: Duy'sfixup Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'config.c')
-rw-r--r--config.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/config.c b/config.c
index 86a5eb2..647a15e 100644
--- a/config.c
+++ b/config.c
@@ -1594,6 +1594,26 @@ int git_config_get_pathname(const char *key, const char **dest)
return ret;
}
+int git_config_get_untracked_cache(void)
+{
+ int val = -1;
+ const char *v;
+
+ if (!git_config_get_maybe_bool("core.untrackedcache", &val))
+ return val;
+
+ if (!git_config_get_value("core.untrackedcache", &v)) {
+ if (!strcasecmp(v, "keep"))
+ return -1;
+
+ error("unknown core.untrackedCache value '%s'; "
+ "using 'keep' default value", v);
+ return -1;
+ }
+
+ return -1; /* default value */
+}
+
NORETURN
void git_die_config_linenr(const char *key, const char *filename, int linenr)
{