diff options
| author | Patrick Steinhardt <ps@pks.im> | 2024-08-16 10:57:12 +0200 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2024-08-16 09:55:22 -0700 |
| commit | d2511eeae5fc679cf1b1591b3604e6abf5c056c2 (patch) | |
| tree | a727383830e32fb3ddfe8b235c17b201ac1675d0 /setup.c | |
| parent | setup: make object format configurable via config (diff) | |
| download | git-d2511eeae5fc679cf1b1591b3604e6abf5c056c2.tar.gz git-d2511eeae5fc679cf1b1591b3604e6abf5c056c2.zip | |
setup: make ref storage format configurable via config
Similar to the preceding commit, introduce a new "init.defaultRefFormat"
config that allows the user to globally set the ref storage format used
by newly created repositories.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'setup.c')
| -rw-r--r-- | setup.c | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -2286,6 +2286,7 @@ static void separate_git_dir(const char *git_dir, const char *git_link) struct default_format_config { int hash; + enum ref_storage_format ref_format; }; static int read_default_format_config(const char *key, const char *value, @@ -2306,6 +2307,16 @@ static int read_default_format_config(const char *key, const char *value, goto out; } + if (!strcmp(key, "init.defaultrefformat")) { + ret = git_config_string(&str, key, value); + if (ret) + goto out; + cfg->ref_format = ref_storage_format_by_name(str); + if (cfg->ref_format == REF_STORAGE_FORMAT_UNKNOWN) + warning(_("unknown ref storage format '%s'"), str); + goto out; + } + ret = 0; out: free(str); @@ -2317,6 +2328,7 @@ static void repository_format_configure(struct repository_format *repo_fmt, { struct default_format_config cfg = { .hash = GIT_HASH_UNKNOWN, + .ref_format = REF_STORAGE_FORMAT_UNKNOWN, }; struct config_options opts = { .respect_includes = 1, @@ -2359,6 +2371,8 @@ static void repository_format_configure(struct repository_format *repo_fmt, if (ref_format == REF_STORAGE_FORMAT_UNKNOWN) die(_("unknown ref storage format '%s'"), env); repo_fmt->ref_storage_format = ref_format; + } else if (cfg.ref_format != REF_STORAGE_FORMAT_UNKNOWN) { + repo_fmt->ref_storage_format = cfg.ref_format; } repo_set_ref_storage_format(the_repository, repo_fmt->ref_storage_format); } |
