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>
Jeff King committed
Mar 11, 2016 at 17:37 UTC
801818680ab907abf347fbdc48623f43a49beee9
3 files changed
+4
-16
Documentation/technical/api-config.txt
-7
@@ -63,13 +63,6 @@ parse for configuration, rather than looking in the usual files. Regular
63
Specify whether include directives should be followed in parsed files.
64
Regular `git_config` defaults to `1`.
65
66
-There is a special version of `git_config` called `git_config_early`.
67
-This version takes an additional parameter to specify the repository
68
-config, instead of having it looked up via `git_path`. This is useful
69
-early in a Git program before the repository has been found. Unless
70
-you're working with early setup code, you probably don't want to use
71
-this.
72
-
66
Reading Specific Files
67
----------------------
68
cache.h
-1
@@ -1535,7 +1535,6 @@ extern void git_config(config_fn_t fn, void *);
1535
extern int git_config_with_options(config_fn_t fn, void *,
1536
struct git_config_source *config_source,
1537
int respect_includes);
1538
-extern int git_config_early(config_fn_t fn, void *, const char *repo_config);
1538
extern int git_parse_ulong(const char *, unsigned long *);
1539
extern int git_parse_maybe_bool(const char *);
1540
extern int git_config_int(const char *, const char *);
config.c
+4
-8
@@ -1188,11 +1188,12 @@ int git_config_system(void)
1188
return !git_env_bool("GIT_CONFIG_NOSYSTEM", 0);
1189
}
1190
1191
-int git_config_early(config_fn_t fn, void *data, const char *repo_config)
1191
+static int do_git_config_sequence(config_fn_t fn, void *data)
1192
{
1193
int ret = 0, found = 0;
1194
char *xdg_config = xdg_config_home("config");
1195
char *user_config = expand_user_path("~/.gitconfig");
1196
+ char *repo_config = git_pathdup("config");
1197
1198
if (git_config_system() && !access_or_die(git_etc_gitconfig(), R_OK, 0)) {
1199
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)
1229
1230
free(xdg_config);
1231
free(user_config);
1232
+ free(repo_config);
1233
return ret == 0 ? found : ret;
1234
}
1235
@@ -1235,8 +1237,6 @@ int git_config_with_options(config_fn_t fn, void *data,
1237
struct git_config_source *config_source,
1238
int respect_includes)
1239
{
1238
- char *repo_config = NULL;
1239
- int ret;
1240
struct config_include_data inc = CONFIG_INCLUDE_INIT;
1241
1242
if (respect_includes) {
@@ -1257,11 +1257,7 @@ int git_config_with_options(config_fn_t fn, void *data,
1257
else if (config_source && config_source->blob)
1258
return git_config_from_blob_ref(fn, config_source->blob, data);
1259
1260
- repo_config = git_pathdup("config");
1261
- ret = git_config_early(fn, data, repo_config);
1262
- if (repo_config)
1263
- free(repo_config);
1264
- return ret;
1260
+ return do_git_config_sequence(fn, data);
1261
}
1262
1263
static void git_config_raw(config_fn_t fn, void *data)