]> git.ipfire.org Git - thirdparty/git.git/blobdiff - config.c
config: split repo scope to local and worktree
[thirdparty/git.git] / config.c
index e7052b39773e4c780b44007c1f06389e581ef82b..f68eec766f544e719d5babf38418e58e35a42a05 100644 (file)
--- a/config.c
+++ b/config.c
@@ -1364,6 +1364,11 @@ static int git_default_core_config(const char *var, const char *value, void *cb)
                return 0;
        }
 
+       if (!strcmp(var, "core.sparsecheckoutcone")) {
+               core_sparse_checkout_cone = git_config_bool(var, value);
+               return 0;
+       }
+
        if (!strcmp(var, "core.precomposeunicode")) {
                precomposed_unicode = git_config_bool(var, value);
                return 0;
@@ -1719,15 +1724,12 @@ static int do_git_config_sequence(const struct config_options *opts,
        if (user_config && !access_or_die(user_config, R_OK, ACCESS_EACCES_OK))
                ret += git_config_from_file(fn, user_config, data);
 
-       current_parsing_scope = CONFIG_SCOPE_REPO;
+       current_parsing_scope = CONFIG_SCOPE_LOCAL;
        if (!opts->ignore_repo && repo_config &&
            !access_or_die(repo_config, R_OK, 0))
                ret += git_config_from_file(fn, repo_config, data);
 
-       /*
-        * Note: this should have a new scope, CONFIG_SCOPE_WORKTREE.
-        * But let's not complicate things before it's actually needed.
-        */
+       current_parsing_scope = CONFIG_SCOPE_WORKTREE;
        if (!opts->ignore_worktree && repository_format_worktree_config) {
                char *path = git_pathdup("config.worktree");
                if (!access_or_die(path, R_OK, 0))
@@ -3292,6 +3294,24 @@ const char *current_config_origin_type(void)
        }
 }
 
+const char *config_scope_name(enum config_scope scope)
+{
+       switch (scope) {
+       case CONFIG_SCOPE_SYSTEM:
+               return "system";
+       case CONFIG_SCOPE_GLOBAL:
+               return "global";
+       case CONFIG_SCOPE_LOCAL:
+               return "local";
+       case CONFIG_SCOPE_WORKTREE:
+               return "worktree";
+       case CONFIG_SCOPE_CMDLINE:
+               return "cmdline";
+       default:
+               return "unknown";
+       }
+}
+
 const char *current_config_name(void)
 {
        const char *name;