Skip to content

Commit 7075000

Browse files
10ne1gitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a75481e commit 7075000

File tree

6 files changed

+44
-0
lines changed

6 files changed

+44
-0
lines changed

Documentation/config/extensions.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ submoduleEncoding:::
7878
conflicts due to nested gitdirs, case insensitivity or other issues.
7979
When enabled, the submodule.<name>.gitdir config is always set for
8080
all submodules and is the single point of authority for gitdir paths.
81+
Can also be enabled via the submodule-encoding build option. The repo
82+
config takes precedence over the build-time default.
8183
8284
worktreeConfig:::
8385
If enabled, then worktrees will load config settings from the

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2344,6 +2344,11 @@ ifdef INCLUDE_LIBGIT_RS
23442344
BASIC_CFLAGS += -fvisibility=hidden
23452345
endif
23462346

2347+
ifdef SUBMODULE_ENCODING_BY_DEFAULT
2348+
# Set submoduleEncoding extension default specified at build time
2349+
BASIC_CFLAGS += -DSUBMODULE_ENCODING_BY_DEFAULT=$(SUBMODULE_ENCODING_BY_DEFAULT)
2350+
endif
2351+
23472352
ifeq ($(TCLTK_PATH),)
23482353
NO_TCLTK = NoThanks
23492354
endif

configure.ac

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,29 @@ AC_ARG_ENABLE([cssmin],
229229
GIT_CONF_SUBST([CSSMIN])
230230
])
231231

232+
# Define option to enable the submodule encoding extension by default
233+
AC_ARG_ENABLE([submodule-encoding],
234+
[AS_HELP_STRING([--enable-submodule-encoding],
235+
[Enable the submoduleEncoding extension by default at build time.]
236+
[--disable-submodule-encoding will keep the current default (disabled).])],
237+
[
238+
case "$enableval" in
239+
yes) SUBMODULE_ENCODING_BY_DEFAULT=1
240+
AC_MSG_NOTICE([Submodule encoding will be enabled by default.])
241+
;;
242+
no) SUBMODULE_ENCODING_BY_DEFAULT=0
243+
AC_MSG_NOTICE([Submodule encoding will not be enabled by default.])
244+
;;
245+
*) AC_MSG_ERROR([--enable-submodule-encoding takes yes or no.])
246+
;;
247+
esac
248+
],
249+
[
250+
SUBMODULE_ENCODING_BY_DEFAULT=0
251+
])
252+
253+
GIT_CONF_SUBST([SUBMODULE_ENCODING_BY_DEFAULT])
254+
232255
## Site configuration (override autodetection)
233256
## --with-PACKAGE[=ARG] and --without-PACKAGE
234257
AC_MSG_NOTICE([CHECKS for site configuration])

meson.build

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,10 @@ else
940940
build_options_config.set('NO_PERL_CPAN_FALLBACKS', '')
941941
endif
942942

943+
submodule_encoding_by_default = get_option('submodule-encoding').to_int()
944+
libgit_c_args += '-DSUBMODULE_ENCODING_BY_DEFAULT=' + submodule_encoding_by_default.to_string()
945+
build_options_config.set('SUBMODULE_ENCODING_BY_DEFAULT', submodule_encoding_by_default)
946+
943947
zlib_backend = get_option('zlib_backend')
944948
if zlib_backend in ['auto', 'zlib-ng']
945949
zlib_ng = dependency('zlib-ng', required: zlib_backend == 'zlib-ng')

meson_options.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ option('runtime_prefix', type: 'boolean', value: false,
1919
description: 'Resolve ancillary tooling and support files relative to the location of the runtime binary instead of hard-coding them into the binary.')
2020
option('sane_tool_path', type: 'array', value: [],
2121
description: 'An array of paths to pick up tools from in case the normal tools are broken or lacking.')
22+
option('submodule-encoding', type: 'boolean', value: false,
23+
description: 'Enable submoduleEncoding extension by default at build time.')
2224

2325
# Build information compiled into Git and other parts like documentation.
2426
option('build_date', type: 'string', value: '',

setup.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1747,6 +1747,14 @@ const char *setup_git_directory_gently(int *nongit_ok)
17471747
*/
17481748
repo_config_clear(the_repository);
17491749

1750+
/*
1751+
* Set build-time default for submodule encoding.
1752+
* This can be overridden by the repository's config.
1753+
*/
1754+
#ifdef SUBMODULE_ENCODING_BY_DEFAULT
1755+
repo_fmt.submodule_encoding = SUBMODULE_ENCODING_BY_DEFAULT;
1756+
#endif
1757+
17501758
/*
17511759
* Let's assume that we are in a git repository.
17521760
* If it turns out later that we are somewhere else, the value will be

0 commit comments

Comments
 (0)