summaryrefslogtreecommitdiff
path: root/repo-settings.c
diff options
context:
space:
mode:
authorDerrick Stolee <dstolee@microsoft.com>2019-08-13 18:37:46 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-08-13 20:33:55 (GMT)
commitad0fb65999382052cf21408df490d0b39800d487 (patch)
tree52e75283d8c994de331fe84f9082b6ed6953e564 /repo-settings.c
parent31b1de6a09bad59cc0d88419925486afc7add277 (diff)
downloadgit-ad0fb65999382052cf21408df490d0b39800d487.zip
git-ad0fb65999382052cf21408df490d0b39800d487.tar.gz
git-ad0fb65999382052cf21408df490d0b39800d487.tar.bz2
repo-settings: parse core.untrackedCache
The core.untrackedCache config setting is slightly complicated, so clarify its use and centralize its parsing into the repo settings. The default value is "keep" (returned as -1), which persists the untracked cache if it exists. If the value is set as "false" (returned as 0), then remove the untracked cache if it exists. If the value is set as "true" (returned as 1), then write the untracked cache and persist it. Instead of relying on magic values of -1, 0, and 1, split these options into an enum. This allows the use of "-1" as a default value. After parsing the config options, if the value is unset we can initialize it to UNTRACKED_CACHE_KEEP. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'repo-settings.c')
-rw-r--r--repo-settings.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/repo-settings.c b/repo-settings.c
index d00b675..abbc656 100644
--- a/repo-settings.c
+++ b/repo-settings.c
@@ -7,6 +7,7 @@
void prepare_repo_settings(struct repository *r)
{
int value;
+ char *strval;
if (r->settings.initialized)
return;
@@ -23,7 +24,25 @@ void prepare_repo_settings(struct repository *r)
if (!repo_config_get_bool(r, "index.version", &value))
r->settings.index_version = value;
+ if (!repo_config_get_maybe_bool(r, "core.untrackedcache", &value)) {
+ if (value == 0)
+ r->settings.core_untracked_cache = UNTRACKED_CACHE_REMOVE;
+ else
+ r->settings.core_untracked_cache = UNTRACKED_CACHE_WRITE;
+ } else if (!repo_config_get_string(r, "core.untrackedcache", &strval)) {
+ if (!strcasecmp(strval, "keep"))
+ r->settings.core_untracked_cache = UNTRACKED_CACHE_KEEP;
+
+ free(strval);
+ }
+
if (!repo_config_get_bool(r, "pack.usesparse", &value))
r->settings.pack_use_sparse = value;
+
+ /* Hack for test programs like test-dump-untracked-cache */
+ if (ignore_untracked_cache_config)
+ r->settings.core_untracked_cache = UNTRACKED_CACHE_KEEP;
+ else
+ UPDATE_DEFAULT_BOOL(r->settings.core_untracked_cache, UNTRACKED_CACHE_KEEP);
}