@@ -79,14 +79,20 @@ escape sequences) are invalid.
79
79
Includes
80
80
~~~~~~~~
81
81
82
+ The `include` and `includeIf` sections allow you to include config
83
+ directives from another source. These sections behave identically to
84
+ each other with the exception that `includeIf` sections may be ignored
85
+ if their condition does not evaluate to true; see "Conditional includes"
86
+ below.
87
+
82
88
You can include a config file from another by setting the special
83
- `include.path` variable to the name of the file to be included. The
84
- variable takes a pathname as its value, and is subject to tilde
85
- expansion. `include.path` can be given multiple times.
89
+ `include.path` (or `includeIf.*.path`) variable to the name of the file
90
+ to be included. The variable takes a pathname as its value, and is
91
+ subject to tilde expansion. These variables can be given multiple times.
86
92
87
- The included file is expanded immediately, as if its contents had been
88
- found at the location of the include directive. If the value of the
89
- `include.path` variable is a relative path, the path is considered to
93
+ The contents of the included file are inserted immediately, as if they
94
+ had been found at the location of the include directive. If the value of the
95
+ variable is a relative path, the path is considered to
90
96
be relative to the configuration file in which the include directive
91
97
was found. See below for examples.
92
98
@@ -95,8 +101,7 @@ Conditional includes
95
101
96
102
You can include a config file from another conditionally by setting a
97
103
`includeIf.<condition>.path` variable to the name of the file to be
98
- included. The variable's value is treated the same way as
99
- `include.path`. `includeIf.<condition>.path` can be given multiple times.
104
+ included.
100
105
101
106
The condition starts with a keyword followed by a colon and some data
102
107
whose format and meaning depends on the keyword. Supported keywords
@@ -167,8 +172,8 @@ Example
167
172
168
173
[include]
169
174
path = /path/to/foo.inc ; include by absolute path
170
- path = foo ; expand "foo" relative to the current file
171
- path = ~/foo ; expand "foo" in your `$HOME` directory
175
+ path = foo.inc ; find "foo.inc " relative to the current file
176
+ path = ~/foo.inc ; find "foo.inc " in your `$HOME` directory
172
177
173
178
; include if $GIT_DIR is /path/to/foo/.git
174
179
[includeIf "gitdir:/path/to/foo/.git"]
@@ -182,6 +187,12 @@ Example
182
187
[includeIf "gitdir:~/to/group/"]
183
188
path = /path/to/foo.inc
184
189
190
+ ; relative paths are always relative to the including
191
+ ; file (if the condition is true); their location is not
192
+ ; affected by the condition
193
+ [includeIf "gitdir:/path/to/group/"]
194
+ path = foo.inc
195
+
185
196
Values
186
197
~~~~~~
187
198
0 commit comments