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>
This commit is contained in:
committed by
Junio C Hamano
parent
31b1de6a09
commit
ad0fb65999
@ -966,6 +966,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
|
||||
struct parse_opt_ctx_t ctx;
|
||||
strbuf_getline_fn getline_fn;
|
||||
int parseopt_state = PARSE_OPT_UNKNOWN;
|
||||
struct repository *r = the_repository;
|
||||
struct option options[] = {
|
||||
OPT_BIT('q', NULL, &refresh_args.flags,
|
||||
N_("continue refresh even when index needs update"),
|
||||
@ -1180,11 +1181,12 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
|
||||
remove_split_index(&the_index);
|
||||
}
|
||||
|
||||
prepare_repo_settings(r);
|
||||
switch (untracked_cache) {
|
||||
case UC_UNSPECIFIED:
|
||||
break;
|
||||
case UC_DISABLE:
|
||||
if (git_config_get_untracked_cache() == 1)
|
||||
if (r->settings.core_untracked_cache == UNTRACKED_CACHE_WRITE)
|
||||
warning(_("core.untrackedCache is set to true; "
|
||||
"remove or change it, if you really want to "
|
||||
"disable the untracked cache"));
|
||||
@ -1196,7 +1198,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
|
||||
return !test_if_untracked_cache_is_supported();
|
||||
case UC_ENABLE:
|
||||
case UC_FORCE:
|
||||
if (git_config_get_untracked_cache() == 0)
|
||||
if (r->settings.core_untracked_cache == UNTRACKED_CACHE_REMOVE)
|
||||
warning(_("core.untrackedCache is set to false; "
|
||||
"remove or change it, if you really want to "
|
||||
"enable the untracked cache"));
|
||||
|
||||
Reference in New Issue
Block a user