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 <barkalow@iabervon.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff --git a/builtin-config.c b/builtin-config.c
index 3a441ef..39f63d7 100644
--- a/builtin-config.c
+++ b/builtin-config.c
@@ -81,12 +81,10 @@
 	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 @@
 	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 @@
 			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 @@
 						       argv[2]);
 			else
 				file = argv[2];
-			setenv(CONFIG_ENVIRONMENT, file, 1);
+			config_exclusive_filename = file;
 			argc--;
 			argv++;
 		}