diff options
author | Junio C Hamano <gitster@pobox.com> | 2008-02-16 17:56:51 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-02-16 17:56:51 -0800 |
commit | fef1c4c0a0766b83cfacaf6276d7bd0d1aa9a2e4 (patch) | |
tree | a3c4cf94132da5755e874ef44bd8072d679ba0c8 /config.c | |
parent | 093d50e0d226b879e24753ce18f4eb4b754807c6 (diff) | |
parent | 8bfa6bd6473b086ab2c5781daa08a7b5417c3d1f (diff) | |
download | git-fef1c4c0a0766b83cfacaf6276d7bd0d1aa9a2e4.tar.gz |
Merge branch 'jk/noetcconfig'
* jk/noetcconfig:
fix config reading in tests
allow suppressing of global and system config
Conflicts:
cache.h
Diffstat (limited to 'config.c')
-rw-r--r-- | config.c | 20 |
1 files changed, 18 insertions, 2 deletions
@@ -493,6 +493,22 @@ const char *git_etc_gitconfig(void) return system_wide; } +int git_env_bool(const char *k, int def) +{ + const char *v = getenv(k); + return v ? git_config_bool(k, v) : def; +} + +int git_config_system(void) +{ + return !git_env_bool("GIT_CONFIG_NOSYSTEM", 0); +} + +int git_config_global(void) +{ + return !git_env_bool("GIT_CONFIG_NOGLOBAL", 0); +} + int git_config(config_fn_t fn) { int ret = 0; @@ -505,7 +521,7 @@ int git_config(config_fn_t fn) * config file otherwise. */ filename = getenv(CONFIG_ENVIRONMENT); if (!filename) { - if (!access(git_etc_gitconfig(), R_OK)) + if (git_config_system() && !access(git_etc_gitconfig(), R_OK)) ret += git_config_from_file(fn, git_etc_gitconfig()); home = getenv("HOME"); filename = getenv(CONFIG_LOCAL_ENVIRONMENT); @@ -513,7 +529,7 @@ int git_config(config_fn_t fn) filename = repo_config = xstrdup(git_path("config")); } - if (home) { + if (git_config_global() && home) { char *user_config = xstrdup(mkpath("%s/.gitconfig", home)); if (!access(user_config, R_OK)) ret = git_config_from_file(fn, user_config); |