aboutsummaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorPetr Baudis <pasky@suse.cz>2006-06-18 01:23:58 +0200
committerJunio C Hamano <junkio@cox.net>2006-06-18 21:19:07 -0700
commit7f29f7a95c906250c9c99d08242c2c4084c48d24 (patch)
treecd28340e59a2c9528b5031328eab2e498701d9b1 /config.c
parent64e86c57867593ba0ee77a7b0ff0eb8e9d4d8ed5 (diff)
downloadgit-7f29f7a95c906250c9c99d08242c2c4084c48d24.tar.gz
git-7f29f7a95c906250c9c99d08242c2c4084c48d24.tar.xz
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>
Diffstat (limited to 'config.c')
-rw-r--r--config.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/config.c b/config.c
index 984c75f5d..d46eb6d82 100644
--- a/config.c
+++ b/config.c
@@ -317,7 +317,17 @@ int git_config_from_file(config_fn_t fn, const char *filename)
int git_config(config_fn_t fn)
{
- return git_config_from_file(fn, git_path("config"));
+ const char *filename = git_path("config");
+ /* Forward-compatibility cue: $GIT_CONFIG makes git read _only_
+ * the given config file, $GIT_CONFIG_LOCAL will make it process
+ * it in addition to the global config file, the same way it would
+ * the per-repository config file otherwise. */
+ if (getenv("GIT_CONFIG")) {
+ filename = getenv("GIT_CONFIG");
+ } else if (getenv("GIT_CONFIG_LOCAL")) {
+ filename = getenv("GIT_CONFIG_LOCAL");
+ }
+ return git_config_from_file(fn, filename);
}
/*