[PATCH v5 7/7] meson/Makefile: allow setting submodule encoding at build time
- From
Adrian Ratiu <adrian.ratiu@collabora.com>
- Date
- Nov 19, 2025, 21:10 UTC
- Message-ID
- <20251119211030.2008441-8-adrian.ratiu@collabora.com>
- In-Reply-To
- <20251119211030.2008441-1-adrian.ratiu@collabora.com>
Some users find it difficult to distribute repo config changes for enabling extensions.submoduleEncoding, or to enable it by passing the config via cmdline, so we add a build-time option which can enable the extension for convenience.
It is still disabled by default and the build-time default is overridden by the repo-specific configs.
Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com> --- Documentation/config/extensions.adoc | 2 ++ Makefile | 5 +++++ configure.ac | 23 +++++++++++++++++++++++ meson.build | 4 ++++ meson_options.txt | 2 ++ setup.c | 8 ++++++++ 6 files changed, 44 insertions(+)
diff --git a/Documentation/config/extensions.adoc b/Documentation/config/extensions.adoc index 4861d01894..436f7fb52e 100644 --- a/Documentation/config/extensions.adoc +++ b/Documentation/config/extensions.adoc @@ -78,6 +78,8 @@ submoduleEncoding::: conflicts due to nested gitdirs, case insensitivity or other issues. When enabled, the submodule.<name>.gitdir config is always set for all submodules and is the single point of authority for gitdir paths. + Can also be enabled via the submodule-encoding build option. The repo + config takes precedence over the build-time default. worktreeConfig::: If enabled, then worktrees will load config settings from the diff --git a/Makefile b/Makefile index 7e0f77e298..4c7bf75c68 100644 --- a/Makefile +++ b/Makefile @@ -2344,6 +2344,11 @@ ifdef INCLUDE_LIBGIT_RS BASIC_CFLAGS += -fvisibility=hidden endif +ifdef SUBMODULE_ENCODING_BY_DEFAULT + # Set submoduleEncoding extension default specified at build time + BASIC_CFLAGS += -DSUBMODULE_ENCODING_BY_DEFAULT=$(SUBMODULE_ENCODING_BY_DEFAULT) +endif + ifeq ($(TCLTK_PATH),) NO_TCLTK = NoThanks endif diff --git a/configure.ac b/configure.ac index cfb50112bf..202b1e309b 100644 --- a/configure.ac +++ b/configure.ac @@ -229,6 +229,29 @@ AC_ARG_ENABLE([cssmin], GIT_CONF_SUBST([CSSMIN]) ]) +# Define option to enable the submodule encoding extension by default +AC_ARG_ENABLE([submodule-encoding], + [AS_HELP_STRING([--enable-submodule-encoding], + [Enable the submoduleEncoding extension by default at build time.] + [--disable-submodule-encoding will keep the current default (disabled).])], +[ +case "$enableval" in + yes) SUBMODULE_ENCODING_BY_DEFAULT=1 + AC_MSG_NOTICE([Submodule encoding will be enabled by default.]) + ;; + no) SUBMODULE_ENCODING_BY_DEFAULT=0 + AC_MSG_NOTICE([Submodule encoding will not be enabled by default.]) + ;; + *) AC_MSG_ERROR([--enable-submodule-encoding takes yes or no.]) + ;; +esac +], +[ + SUBMODULE_ENCODING_BY_DEFAULT=0 +]) + +GIT_CONF_SUBST([SUBMODULE_ENCODING_BY_DEFAULT]) + ## Site configuration (override autodetection) ## --with-PACKAGE[=ARG] and --without-PACKAGE AC_MSG_NOTICE([CHECKS for site configuration]) diff --git a/meson.build b/meson.build index 1f95a06edb..992d433efd 100644 --- a/meson.build +++ b/meson.build @@ -945,6 +945,10 @@ else build_options_config.set('NO_PERL_CPAN_FALLBACKS', '') endif +submodule_encoding_by_default = get_option('submodule-encoding').to_int() +libgit_c_args += '-DSUBMODULE_ENCODING_BY_DEFAULT=' + submodule_encoding_by_default.to_string() +build_options_config.set('SUBMODULE_ENCODING_BY_DEFAULT', submodule_encoding_by_default) + zlib_backend = get_option('zlib_backend') if zlib_backend in ['auto', 'zlib-ng'] zlib_ng = dependency('zlib-ng', required: zlib_backend == 'zlib-ng') diff --git a/meson_options.txt b/meson_options.txt index e0be260ae1..d9d569a166 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -21,6 +21,8 @@ option('runtime_prefix', type: 'boolean', value: false, description: 'Resolve ancillary tooling and support files relative to the location of the runtime binary instead of hard-coding them into the binary.') option('sane_tool_path', type: 'array', value: [], description: 'An array of paths to pick up tools from in case the normal tools are broken or lacking.') +option('submodule-encoding', type: 'boolean', value: false, + description: 'Enable submoduleEncoding extension by default at build time.') # Build information compiled into Git and other parts like documentation. option('build_date', type: 'string', value: '', diff --git a/setup.c b/setup.c index bf6e815105..de2d4e7238 100644 --- a/setup.c +++ b/setup.c @@ -1747,6 +1747,14 @@ const char *setup_git_directory_gently(int *nongit_ok) */ repo_config_clear(the_repository); + /* + * Set build-time default for submodule encoding. + * This can be overridden by the repository's config. + */ +#ifdef SUBMODULE_ENCODING_BY_DEFAULT + repo_fmt.submodule_encoding = SUBMODULE_ENCODING_BY_DEFAULT; +#endif + /* * Let's assume that we are in a git repository. * If it turns out later that we are somewhere else, the value will be
-- 2.51.0