diff options
Diffstat (limited to 'Documentation')
-rw-r--r-- | Documentation/config.txt | 15 | ||||
-rw-r--r-- | Documentation/git-config.txt | 5 | ||||
-rw-r--r-- | Documentation/technical/api-config.txt | 28 |
3 files changed, 47 insertions, 1 deletions
diff --git a/Documentation/config.txt b/Documentation/config.txt index abeb82b2c6..e55dae1806 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -84,6 +84,17 @@ customary UNIX fashion. Some variables may require a special value format. +Includes +~~~~~~~~ + +You can include one config file from another by setting the special +`include.path` variable to the name of the file to be included. The +included file is expanded immediately, as if its contents had been +found at the location of the include directive. If the value of the +`include.path` variable is a relative path, the path is considered to be +relative to the configuration file in which the include directive was +found. See below for examples. + Example ~~~~~~~ @@ -106,6 +117,10 @@ Example gitProxy="ssh" for "kernel.org" gitProxy=default-proxy ; for the rest + [include] + path = /path/to/foo.inc ; include by absolute path + path = foo ; expand "foo" relative to the current file + Variables ~~~~~~~~~ diff --git a/Documentation/git-config.txt b/Documentation/git-config.txt index e7ecf5d803..aa8303b1ad 100644 --- a/Documentation/git-config.txt +++ b/Documentation/git-config.txt @@ -178,6 +178,11 @@ See also <<FILES>>. Opens an editor to modify the specified config file; either '--system', '--global', or repository (default). +--includes:: +--no-includes:: + Respect `include.*` directives in config files when looking up + values. Defaults to on. + [[FILES]] FILES ----- diff --git a/Documentation/technical/api-config.txt b/Documentation/technical/api-config.txt index b0aeb2e481..edf8dfb99b 100644 --- a/Documentation/technical/api-config.txt +++ b/Documentation/technical/api-config.txt @@ -52,13 +52,17 @@ while adjusting some of the default behavior of `git_config`. It should almost never be used by "regular" git code that is looking up configuration variables. It is intended for advanced callers like `git-config`, which are intentionally tweaking the normal config-lookup -process. It takes one extra parameter: +process. It takes two extra parameters: `filename`:: If this parameter is non-NULL, it specifies the name of a file to parse for configuration, rather than looking in the usual files. Regular `git_config` defaults to `NULL`. +`respect_includes`:: +Specify whether include directives should be followed in parsed files. +Regular `git_config` defaults to `1`. + There is a special version of `git_config` called `git_config_early`. This version takes an additional parameter to specify the repository config, instead of having it looked up via `git_path`. This is useful @@ -108,6 +112,28 @@ string is given, prints an error message and returns -1. Similar to `git_config_string`, but expands `~` or `~user` into the user's home directory when found at the beginning of the path. +Include Directives +------------------ + +By default, the config parser does not respect include directives. +However, a caller can use the special `git_config_include` wrapper +callback to support them. To do so, you simply wrap your "real" callback +function and data pointer in a `struct config_include_data`, and pass +the wrapper to the regular config-reading functions. For example: + +------------------------------------------- +int read_file_with_include(const char *file, config_fn_t fn, void *data) +{ + struct config_include_data inc = CONFIG_INCLUDE_INIT; + inc.fn = fn; + inc.data = data; + return git_config_from_file(git_config_include, file, &inc); +} +------------------------------------------- + +`git_config` respects includes automatically. The lower-level +`git_config_from_file` does not. + Writing Config Files -------------------- |