summaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-03-20 14:29:03 -0700
committerJunio C Hamano <gitster@pobox.com>2009-03-20 14:29:03 -0700
commit17e46ea6fea5273b51b424a8016f9da3412792d4 (patch)
treeb394b7c1d2d280d7a8fac60ff63e741c310c5bbf /config.c
parent8f0246551c3964eeb16d9c9f39845bd53af8bda8 (diff)
parentbf71b4b3ee07291e97c4dabfb97e7397eec904e0 (diff)
downloadgit-17e46ea6fea5273b51b424a8016f9da3412792d4.tar.gz
Merge branch 'fc/parseopt-config'
* fc/parseopt-config: config: test for --replace-all with one argument and fix documentation. config: set help text for --bool-or-int git config: don't allow --get-color* and variable type git config: don't allow extra arguments for -e or -l. git config: don't allow multiple variable types git config: don't allow multiple config file locations git config: reorganize to use parseopt git config: reorganize get_color* git config: trivial rename in preparation for parseopt git_config(): not having a per-repo config file is not an error
Diffstat (limited to 'config.c')
-rw-r--r--config.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/config.c b/config.c
index 0c8c76f13b..50efd639c4 100644
--- a/config.c
+++ b/config.c
@@ -644,28 +644,37 @@ int git_config_global(void)
int git_config(config_fn_t fn, void *data)
{
- int ret = 0;
+ int ret = 0, found = 0;
char *repo_config = NULL;
const char *home = NULL;
/* Setting $GIT_CONFIG makes git read _only_ the given config file. */
if (config_exclusive_filename)
return git_config_from_file(fn, config_exclusive_filename, data);
- if (git_config_system() && !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(),
data);
+ found += 1;
+ }
home = getenv("HOME");
if (git_config_global() && home) {
char *user_config = xstrdup(mkpath("%s/.gitconfig", home));
- if (!access(user_config, R_OK))
+ if (!access(user_config, R_OK)) {
ret += git_config_from_file(fn, user_config, data);
+ found += 1;
+ }
free(user_config);
}
repo_config = git_pathdup("config");
- ret += git_config_from_file(fn, repo_config, data);
+ if (!access(repo_config, R_OK)) {
+ ret += git_config_from_file(fn, repo_config, data);
+ found += 1;
+ }
free(repo_config);
+ if (found == 0)
+ return -1;
return ret;
}