MCPcopy Create free account
hub / github.com/git/git / read_default_format_config

Function read_default_format_config

setup.c:2685–2729  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2683};
2684
2685static int read_default_format_config(const char *key, const char *value,
2686 const struct config_context *ctx UNUSED,
2687 void *payload)
2688{
2689 struct default_format_config *cfg = payload;
2690 char *str = NULL;
2691 int ret;
2692
2693 if (!strcmp(key, "init.defaultobjectformat")) {
2694 ret = git_config_string(&str, key, value);
2695 if (ret)
2696 goto out;
2697 cfg->hash = hash_algo_by_name(str);
2698 if (cfg->hash == GIT_HASH_UNKNOWN)
2699 warning(_("unknown hash algorithm '%s'"), str);
2700 goto out;
2701 }
2702
2703 if (!strcmp(key, "init.defaultrefformat")) {
2704 ret = git_config_string(&str, key, value);
2705 if (ret)
2706 goto out;
2707 cfg->ref_format = ref_storage_format_by_name(str);
2708 if (cfg->ref_format == REF_STORAGE_FORMAT_UNKNOWN)
2709 warning(_("unknown ref storage format '%s'"), str);
2710 goto out;
2711 }
2712
2713 /*
2714 * Enable the reftable format when "features.experimental" is enabled.
2715 * "init.defaultRefFormat" takes precedence over this setting.
2716 */
2717 if (!strcmp(key, "feature.experimental") &&
2718 cfg->ref_format == REF_STORAGE_FORMAT_UNKNOWN &&
2719 git_config_bool(key, value)) {
2720 cfg->ref_format = REF_STORAGE_FORMAT_REFTABLE;
2721 ret = 0;
2722 goto out;
2723 }
2724
2725 ret = 0;
2726out:
2727 free(str);
2728 return ret;
2729}
2730
2731static void repository_format_configure(struct repository *repo,
2732 struct repository_format *repo_fmt,

Callers

nothing calls this directly

Calls 5

git_config_stringFunction · 0.85
hash_algo_by_nameFunction · 0.85
warningFunction · 0.85
git_config_boolFunction · 0.85

Tested by

no test coverage detected