meson/Makefile: allow setting submodule encoding at build time

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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Adrian Ratiu
2025-11-19 23:10:30 +02:00
committed by Junio C Hamano
parent a75481e3b7
commit 7075000365
6 changed files with 44 additions and 0 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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])

View File

@@ -940,6 +940,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')

View File

@@ -19,6 +19,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: '',

View File

@@ -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