From 399b198489a041e2842fb4b257bea5adb02d28d1 Mon Sep 17 00:00:00 2001 From: Jonathan Tan Date: Tue, 18 Jan 2022 09:47:40 -0800 Subject: config: include file if remote URL matches a glob This is a feature that supports config file inclusion conditional on whether the repo has a remote with a URL that matches a glob. Similar to my previous work on remote-suggested hooks [1], the main motivation is to allow remote repo administrators to provide recommended configs in a way that can be consumed more easily (e.g. through a package installable by a package manager - it could, for example, contain a file to be included conditionally and a post-install script that adds the include directive to the system-wide config file). In order to do this, Git reruns the config parsing mechanism upon noticing the first URL-conditional include in order to find all remote URLs, and these remote URLs are then used to determine if that first and all subsequent includes are executed. Remote URLs are not allowed to be configued in any URL-conditionally-included file. [1] https://lore.kernel.org/git/cover.1623881977.git.jonathantanmy@google.com/ Signed-off-by: Jonathan Tan Acked-by: Elijah Newren Signed-off-by: Junio C Hamano --- config.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'config.h') diff --git a/config.h b/config.h index 48a5e472ca..ab0106d287 100644 --- a/config.h +++ b/config.h @@ -89,6 +89,15 @@ struct config_options { unsigned int ignore_worktree : 1; unsigned int ignore_cmdline : 1; unsigned int system_gently : 1; + + /* + * For internal use. Include all includeif.hasremoteurl paths without + * checking if the repo has that remote URL, and when doing so, verify + * that files included in this way do not configure any remote URLs + * themselves. + */ + unsigned int unconditional_remote_url : 1; + const char *commondir; const char *git_dir; config_parser_event_fn_t event_fn; -- cgit v1.2.3