config: drop git_config_early

There are no more callers, and it's a rather confusing
interface. This could just be folded into
git_config_with_options(), but for the sake of readability,
we'll leave it as a separate (static) helper function.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Jeff King 2016-03-11 17:37:03 -05:00 committed by Junio C Hamano
parent 21627f9b6d
commit 801818680a
3 changed files with 4 additions and 16 deletions

View File

@ -63,13 +63,6 @@ parse for configuration, rather than looking in the usual files. Regular
Specify whether include directives should be followed in parsed files. Specify whether include directives should be followed in parsed files.
Regular `git_config` defaults to `1`. Regular `git_config` defaults to `1`.
There is a special version of `git_config` called `git_config_early`.
This version takes an additional parameter to specify the repository
config, instead of having it looked up via `git_path`. This is useful
early in a Git program before the repository has been found. Unless
you're working with early setup code, you probably don't want to use
this.
Reading Specific Files Reading Specific Files
---------------------- ----------------------

View File

@ -1535,7 +1535,6 @@ extern void git_config(config_fn_t fn, void *);
extern int git_config_with_options(config_fn_t fn, void *, extern int git_config_with_options(config_fn_t fn, void *,
struct git_config_source *config_source, struct git_config_source *config_source,
int respect_includes); int respect_includes);
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_parse_maybe_bool(const char *); extern int git_parse_maybe_bool(const char *);
extern int git_config_int(const char *, const char *); extern int git_config_int(const char *, const char *);

View File

@ -1188,11 +1188,12 @@ int git_config_system(void)
return !git_env_bool("GIT_CONFIG_NOSYSTEM", 0); return !git_env_bool("GIT_CONFIG_NOSYSTEM", 0);
} }
int git_config_early(config_fn_t fn, void *data, const char *repo_config) static int do_git_config_sequence(config_fn_t fn, void *data)
{ {
int ret = 0, found = 0; int ret = 0, found = 0;
char *xdg_config = xdg_config_home("config"); char *xdg_config = xdg_config_home("config");
char *user_config = expand_user_path("~/.gitconfig"); char *user_config = expand_user_path("~/.gitconfig");
char *repo_config = git_pathdup("config");
if (git_config_system() && !access_or_die(git_etc_gitconfig(), R_OK, 0)) { if (git_config_system() && !access_or_die(git_etc_gitconfig(), R_OK, 0)) {
ret += git_config_from_file(fn, git_etc_gitconfig(), ret += git_config_from_file(fn, git_etc_gitconfig(),
@ -1228,6 +1229,7 @@ int git_config_early(config_fn_t fn, void *data, const char *repo_config)
free(xdg_config); free(xdg_config);
free(user_config); free(user_config);
free(repo_config);
return ret == 0 ? found : ret; return ret == 0 ? found : ret;
} }
@ -1235,8 +1237,6 @@ int git_config_with_options(config_fn_t fn, void *data,
struct git_config_source *config_source, struct git_config_source *config_source,
int respect_includes) int respect_includes)
{ {
char *repo_config = NULL;
int ret;
struct config_include_data inc = CONFIG_INCLUDE_INIT; struct config_include_data inc = CONFIG_INCLUDE_INIT;
if (respect_includes) { if (respect_includes) {
@ -1257,11 +1257,7 @@ int git_config_with_options(config_fn_t fn, void *data,
else if (config_source && config_source->blob) else if (config_source && config_source->blob)
return git_config_from_blob_ref(fn, config_source->blob, data); return git_config_from_blob_ref(fn, config_source->blob, data);
repo_config = git_pathdup("config"); return do_git_config_sequence(fn, data);
ret = git_config_early(fn, data, repo_config);
if (repo_config)
free(repo_config);
return ret;
} }
static void git_config_raw(config_fn_t fn, void *data) static void git_config_raw(config_fn_t fn, void *data)