summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b828fef)
raw | patch | inline | side by side (parent: b828fef)
author | Jeff King <peff@peff.net> | |
Wed, 6 Feb 2008 10:11:18 +0000 (05:11 -0500) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 6 Feb 2008 22:52:23 +0000 (14:52 -0800) |
The GIT_CONFIG_NOGLOBAL and GIT_CONFIG_NOSYSTEM environment
variables are magic undocumented switches that can be used
to ensure a totally clean environment. This is necessary for
running reliable tests, since those config files may contain
settings that change the outcome of tests.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
variables are magic undocumented switches that can be used
to ensure a totally clean environment. This is necessary for
running reliable tests, since those config files may contain
settings that change the outcome of tests.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-config.c | patch | blob | history | |
cache.h | patch | blob | history | |
config.c | patch | blob | history |
diff --git a/builtin-config.c b/builtin-config.c
index e4a12e316648e6b0ab1ee0b424773f3c672c751e..404bb449aec1e24012b390b1d76f05d4cc9c74af 100644 (file)
--- a/builtin-config.c
+++ b/builtin-config.c
local = getenv(CONFIG_LOCAL_ENVIRONMENT);
if (!local)
local = repo_config = xstrdup(git_path("config"));
- if (home)
+ if (git_config_global() && home)
global = xstrdup(mkpath("%s/.gitconfig", home));
- system_wide = git_etc_gitconfig();
+ if (git_config_system())
+ system_wide = git_etc_gitconfig();
}
key = xstrdup(key_);
index 549f4bbac7242714283e58dd576460ca86015d52..af74e203b71333c47b898ce7b7a36eb6c4f1608b 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -589,6 +589,9 @@ extern int git_config_set_multivar(const char *, const char *, const char *, int
extern int git_config_rename_section(const char *, const char *);
extern const char *git_etc_gitconfig(void);
extern int check_repository_format_version(const char *var, const char *value);
+extern int git_env_bool(const char *, int);
+extern int git_config_system(void);
+extern int git_config_global(void);
#define MAX_GITNAME (1000)
extern char git_default_email[MAX_GITNAME];
diff --git a/config.c b/config.c
index 498259ebefb3ba61a75aa5a5ca03d75576a501c0..2f85e9d3e3bcf2cc5ddc87223a797b833846af5b 100644 (file)
--- a/config.c
+++ b/config.c
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;
* 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);
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);