Skip to content

Commit 8018186

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 21627f9 commit 8018186

File tree

3 files changed

+4
-16
lines changed

3 files changed

+4
-16
lines changed

Documentation/technical/api-config.txt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,6 @@ parse for configuration, rather than looking in the usual files. Regular
6363
Specify whether include directives should be followed in parsed files.
6464
Regular `git_config` defaults to `1`.
6565

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-
7366
Reading Specific Files
7467
----------------------
7568

cache.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1535,7 +1535,6 @@ extern void git_config(config_fn_t fn, void *);
15351535
extern int git_config_with_options(config_fn_t fn, void *,
15361536
struct git_config_source *config_source,
15371537
int respect_includes);
1538-
extern int git_config_early(config_fn_t fn, void *, const char *repo_config);
15391538
extern int git_parse_ulong(const char *, unsigned long *);
15401539
extern int git_parse_maybe_bool(const char *);
15411540
extern int git_config_int(const char *, const char *);

config.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,11 +1188,12 @@ int git_config_system(void)
11881188
return !git_env_bool("GIT_CONFIG_NOSYSTEM", 0);
11891189
}
11901190

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)
11921192
{
11931193
int ret = 0, found = 0;
11941194
char *xdg_config = xdg_config_home("config");
11951195
char *user_config = expand_user_path("~/.gitconfig");
1196+
char *repo_config = git_pathdup("config");
11961197

11971198
if (git_config_system() && !access_or_die(git_etc_gitconfig(), R_OK, 0)) {
11981199
ret += git_config_from_file(fn, git_etc_gitconfig(),
@@ -1228,15 +1229,14 @@ int git_config_early(config_fn_t fn, void *data, const char *repo_config)
12281229

12291230
free(xdg_config);
12301231
free(user_config);
1232+
free(repo_config);
12311233
return ret == 0 ? found : ret;
12321234
}
12331235

12341236
int git_config_with_options(config_fn_t fn, void *data,
12351237
struct git_config_source *config_source,
12361238
int respect_includes)
12371239
{
1238-
char *repo_config = NULL;
1239-
int ret;
12401240
struct config_include_data inc = CONFIG_INCLUDE_INIT;
12411241

12421242
if (respect_includes) {
@@ -1257,11 +1257,7 @@ int git_config_with_options(config_fn_t fn, void *data,
12571257
else if (config_source && config_source->blob)
12581258
return git_config_from_blob_ref(fn, config_source->blob, data);
12591259

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);
12651261
}
12661262

12671263
static void git_config_raw(config_fn_t fn, void *data)

0 commit comments

Comments
 (0)