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
This commit is contained in:
17
config.c
17
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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user