Support for extracting configuration from different files
Add $GIT_CONFIG environment variable whose content is used instead of .git/config if set. Also add $GIT_CONFIG_LOCAL as a forward-compatibility cue for whenever we will finally come to support] global configuration files (properly). Signed-off-by: Petr Baudis <pasky@suse.cz> Signed-off-by: Junio C Hamano <junkio@cox.net>
Petr Baudis committed
Jun 18, 2006 at 01:23 UTC
7f29f7a95c906250c9c99d08242c2c4084c48d24
2 files changed
+23
-1
Documentation/git-repo-config.txt
+12
@@ -73,6 +73,18 @@ OPTIONS
73
List all variables set in .git/config.
74
75
76
+ENVIRONMENT
77
+-----------
78
+
79
+GIT_CONFIG::
80
+ Take the configuration from the given file instead of .git/config.
81
+
82
+GIT_CONFIG_LOCAL::
83
+ Currently the same as $GIT_CONFIG; when Git will support global
84
+ configuration files, this will cause it to take the configuration
85
+ from the global configuration file in addition to the given file.
86
+
87
+
88
EXAMPLE
89
-------
90
config.c
+11
-1
@@ -317,7 +317,17 @@ int git_config_from_file(config_fn_t fn, const char *filename)
317
318
int git_config(config_fn_t fn)
319
{
320
- return git_config_from_file(fn, git_path("config"));
320
+ const char *filename = git_path("config");
321
+ /* Forward-compatibility cue: $GIT_CONFIG makes git read _only_
322
+ * the given config file, $GIT_CONFIG_LOCAL will make it process
323
+ * it in addition to the global config file, the same way it would
324
+ * the per-repository config file otherwise. */
325
+ if (getenv("GIT_CONFIG")) {
326
+ filename = getenv("GIT_CONFIG");
327
+ } else if (getenv("GIT_CONFIG_LOCAL")) {
328
+ filename = getenv("GIT_CONFIG_LOCAL");
329
+ }
330
+ return git_config_from_file(fn, filename);
331
}
332
333
/*