From dc87183189b54441e315d35d48983d80ab085299 Mon Sep 17 00:00:00 2001 From: Daniel Barkalow Date: Mon, 30 Jun 2008 03:37:47 -0400 Subject: Only use GIT_CONFIG in "git config", not other programs For everything other than using "git config" to read or write a git-style config file that isn't the current repo's config file, GIT_CONFIG was actively detrimental. Rather than argue over which programs are important enough to have work anyway, just fix all of them at the root. Also removes GIT_LOCAL_CONFIG, which would only be useful for programs that do want to use global git-specific config, but not the repo's own git-specific config, and want to use some other, presumably git-specific config. Despite being documented, I can't find any sign that it was ever used. Signed-off-by: Daniel Barkalow Signed-off-by: Junio C Hamano --- builtin-config.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'builtin-config.c') diff --git a/builtin-config.c b/builtin-config.c index 3a441ef648..39f63d7b10 100644 --- a/builtin-config.c +++ b/builtin-config.c @@ -81,12 +81,10 @@ static int get_value(const char* key_, const char* regex_) char *global = NULL, *repo_config = NULL; const char *system_wide = NULL, *local; - local = getenv(CONFIG_ENVIRONMENT); + local = config_exclusive_filename; if (!local) { const char *home = getenv("HOME"); - local = getenv(CONFIG_LOCAL_ENVIRONMENT); - if (!local) - local = repo_config = xstrdup(git_path("config")); + local = repo_config = xstrdup(git_path("config")); if (git_config_global() && home) global = xstrdup(mkpath("%s/.gitconfig", home)); if (git_config_system()) @@ -289,6 +287,8 @@ int cmd_config(int argc, const char **argv, const char *prefix) char* value; const char *file = setup_git_directory_gently(&nongit); + config_exclusive_filename = getenv(CONFIG_ENVIRONMENT); + while (1 < argc) { if (!strcmp(argv[1], "--int")) type = T_INT; @@ -309,14 +309,13 @@ int cmd_config(int argc, const char **argv, const char *prefix) char *home = getenv("HOME"); if (home) { char *user_config = xstrdup(mkpath("%s/.gitconfig", home)); - setenv(CONFIG_ENVIRONMENT, user_config, 1); - free(user_config); + config_exclusive_filename = user_config; } else { die("$HOME not set"); } } else if (!strcmp(argv[1], "--system")) - setenv(CONFIG_ENVIRONMENT, git_etc_gitconfig(), 1); + config_exclusive_filename = git_etc_gitconfig(); else if (!strcmp(argv[1], "--file") || !strcmp(argv[1], "-f")) { if (argc < 3) usage(git_config_set_usage); @@ -325,7 +324,7 @@ int cmd_config(int argc, const char **argv, const char *prefix) argv[2]); else file = argv[2]; - setenv(CONFIG_ENVIRONMENT, file, 1); + config_exclusive_filename = file; argc--; argv++; } -- cgit v1.2.3