summaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorLibravatar Daniel Barkalow <barkalow@iabervon.org>2008-06-30 03:37:47 -0400
committerLibravatar Junio C Hamano <gitster@pobox.com>2008-07-01 02:35:49 -0700
commitdc87183189b54441e315d35d48983d80ab085299 (patch)
tree975e86756cc3739cdfb7ac3f93981b37a2a8f8ad /config.c
parentMerge branch 'maint' (diff)
downloadtgif-dc87183189b54441e315d35d48983d80ab085299.tar.xz
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>
Diffstat (limited to 'config.c')
-rw-r--r--config.c47
1 files changed, 20 insertions, 27 deletions
diff --git a/config.c b/config.c
index 58749bf416..2862cc45cb 100644
--- a/config.c
+++ b/config.c
@@ -16,6 +16,8 @@ static int config_linenr;
static int config_file_eof;
static int zlib_compression_seen;
+const char *config_exclusive_filename = NULL;
+
static int get_next_char(void)
{
int c;
@@ -611,31 +613,28 @@ int git_config(config_fn_t fn, void *data)
{
int ret = 0;
char *repo_config = NULL;
- const char *home = NULL, *filename;
+ const char *home = NULL;
/* $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. */
- filename = getenv(CONFIG_ENVIRONMENT);
- if (!filename) {
- if (git_config_system() && !access(git_etc_gitconfig(), R_OK))
- ret += git_config_from_file(fn, git_etc_gitconfig(),
- data);
- home = getenv("HOME");
- filename = getenv(CONFIG_LOCAL_ENVIRONMENT);
- if (!filename)
- filename = repo_config = xstrdup(git_path("config"));
- }
+ if (config_exclusive_filename)
+ return git_config_from_file(fn, config_exclusive_filename, data);
+ if (git_config_system() && !access(git_etc_gitconfig(), R_OK))
+ ret += git_config_from_file(fn, git_etc_gitconfig(),
+ data);
+ home = getenv("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, data);
+ ret += git_config_from_file(fn, user_config, data);
free(user_config);
}
- ret += git_config_from_file(fn, filename, data);
+ repo_config = xstrdup(git_path("config"));
+ ret += git_config_from_file(fn, repo_config, data);
free(repo_config);
return ret;
}
@@ -873,13 +872,10 @@ int git_config_set_multivar(const char* key, const char* value,
struct lock_file *lock = NULL;
const char* last_dot = strrchr(key, '.');
- config_filename = getenv(CONFIG_ENVIRONMENT);
- if (!config_filename) {
- config_filename = getenv(CONFIG_LOCAL_ENVIRONMENT);
- if (!config_filename)
- config_filename = git_path("config");
- }
- config_filename = xstrdup(config_filename);
+ if (config_exclusive_filename)
+ config_filename = xstrdup(config_exclusive_filename);
+ else
+ config_filename = xstrdup(git_path("config"));
/*
* Since "key" actually contains the section name and the real
@@ -1136,13 +1132,10 @@ int git_config_rename_section(const char *old_name, const char *new_name)
int out_fd;
char buf[1024];
- config_filename = getenv(CONFIG_ENVIRONMENT);
- if (!config_filename) {
- config_filename = getenv(CONFIG_LOCAL_ENVIRONMENT);
- if (!config_filename)
- config_filename = git_path("config");
- }
- config_filename = xstrdup(config_filename);
+ if (config_exclusive_filename)
+ config_filename = xstrdup(config_exclusive_filename);
+ else
+ config_filename = xstrdup(git_path("config"));
out_fd = hold_lock_file_for_update(lock, config_filename, 0);
if (out_fd < 0) {
ret = error("could not lock config file %s", config_filename);