diff options
| author | Patrick Steinhardt <ps@pks.im> | 2023-12-29 08:26:52 +0100 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2024-01-02 09:24:48 -0800 |
| commit | aa19619a9835a9558630c25a5b8f361343af75ce (patch) | |
| tree | 81f945ce21db518bf3b9a4ef964baa453d8e19bc /setup.c | |
| parent | d7497a42b05bb810afeb6acc8c9447b77b1f075d (diff) | |
| download | git-aa19619a9835a9558630c25a5b8f361343af75ce.tar.gz | |
setup: introduce GIT_DEFAULT_REF_FORMAT envvar
Introduce a new GIT_DEFAULT_REF_FORMAT environment variable that lets
users control the default ref format used by both git-init(1) and
git-clone(1). This is modeled after GIT_DEFAULT_OBJECT_FORMAT, which
does the same thing for the repository's object format.
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 | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -2164,12 +2164,19 @@ static void validate_hash_algorithm(struct repository_format *repo_fmt, int hash static void validate_ref_storage_format(struct repository_format *repo_fmt, unsigned int format) { + const char *name = getenv("GIT_DEFAULT_REF_FORMAT"); + if (repo_fmt->version >= 0 && format != REF_STORAGE_FORMAT_UNKNOWN && format != repo_fmt->ref_storage_format) { die(_("attempt to reinitialize repository with different reference storage format")); } else if (format != REF_STORAGE_FORMAT_UNKNOWN) { repo_fmt->ref_storage_format = format; + } else if (name) { + format = ref_storage_format_by_name(name); + if (format == REF_STORAGE_FORMAT_UNKNOWN) + die(_("unknown ref storage format '%s'"), name); + repo_fmt->ref_storage_format = format; } } |
