Add git_config_early()
This version of git_config() will be used during repository setup. As a repository is being set up, $GIT_DIR is not nailed down yet, git_pathdup() should not be used to get $GIT_DIR/config. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
80d868b068
commit
dbdf5854b2
1
cache.h
1
cache.h
@ -986,6 +986,7 @@ extern int git_config_parse_parameter(const char *text);
|
|||||||
extern int git_config_parse_environment(void);
|
extern int git_config_parse_environment(void);
|
||||||
extern int git_config_from_parameters(config_fn_t fn, void *data);
|
extern int git_config_from_parameters(config_fn_t fn, void *data);
|
||||||
extern int git_config(config_fn_t fn, void *);
|
extern int git_config(config_fn_t fn, void *);
|
||||||
|
extern int git_config_early(config_fn_t fn, void *, const char *repo_config);
|
||||||
extern int git_parse_ulong(const char *, unsigned long *);
|
extern int git_parse_ulong(const char *, unsigned long *);
|
||||||
extern int git_config_int(const char *, const char *);
|
extern int git_config_int(const char *, const char *);
|
||||||
extern unsigned long git_config_ulong(const char *, const char *);
|
extern unsigned long git_config_ulong(const char *, const char *);
|
||||||
|
19
config.c
19
config.c
@ -835,10 +835,9 @@ int git_config_from_parameters(config_fn_t fn, void *data)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int git_config(config_fn_t fn, void *data)
|
int git_config_early(config_fn_t fn, void *data, const char *repo_config)
|
||||||
{
|
{
|
||||||
int ret = 0, found = 0;
|
int ret = 0, found = 0;
|
||||||
char *repo_config = NULL;
|
|
||||||
const char *home = NULL;
|
const char *home = NULL;
|
||||||
|
|
||||||
/* Setting $GIT_CONFIG makes git read _only_ the given config file. */
|
/* Setting $GIT_CONFIG makes git read _only_ the given config file. */
|
||||||
@ -860,12 +859,10 @@ int git_config(config_fn_t fn, void *data)
|
|||||||
free(user_config);
|
free(user_config);
|
||||||
}
|
}
|
||||||
|
|
||||||
repo_config = git_pathdup("config");
|
if (repo_config && !access(repo_config, R_OK)) {
|
||||||
if (!access(repo_config, R_OK)) {
|
|
||||||
ret += git_config_from_file(fn, repo_config, data);
|
ret += git_config_from_file(fn, repo_config, data);
|
||||||
found += 1;
|
found += 1;
|
||||||
}
|
}
|
||||||
free(repo_config);
|
|
||||||
|
|
||||||
ret += git_config_from_parameters(fn, data);
|
ret += git_config_from_parameters(fn, data);
|
||||||
if (config_parameters)
|
if (config_parameters)
|
||||||
@ -876,6 +873,18 @@ int git_config(config_fn_t fn, void *data)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int git_config(config_fn_t fn, void *data)
|
||||||
|
{
|
||||||
|
char *repo_config = NULL;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
repo_config = git_pathdup("config");
|
||||||
|
ret = git_config_early(fn, data, repo_config);
|
||||||
|
if (repo_config)
|
||||||
|
free(repo_config);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Find all the stuff for git_config_set() below.
|
* Find all the stuff for git_config_set() below.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user