Skip to content

Commit ed69e11

Browse files
jonathantanmygitster
authored andcommitted
config: make git_config_include() static
It is not used from outside the file in which it is declared. Signed-off-by: Jonathan Tan <[email protected]> Acked-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent abe6bb3 commit ed69e11

File tree

2 files changed

+15
-34
lines changed

2 files changed

+15
-34
lines changed

config.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,16 @@ static long config_buf_ftell(struct config_source *conf)
120120
return conf->u.buf.pos;
121121
}
122122

123+
struct config_include_data {
124+
int depth;
125+
config_fn_t fn;
126+
void *data;
127+
const struct config_options *opts;
128+
};
129+
#define CONFIG_INCLUDE_INIT { 0 }
130+
131+
static int git_config_include(const char *var, const char *value, void *data);
132+
123133
#define MAX_INCLUDE_DEPTH 10
124134
static const char include_depth_advice[] = N_(
125135
"exceeded maximum include depth (%d) while including\n"
@@ -309,7 +319,7 @@ static int include_condition_is_true(const struct config_options *opts,
309319
return 0;
310320
}
311321

312-
int git_config_include(const char *var, const char *value, void *data)
322+
static int git_config_include(const char *var, const char *value, void *data)
313323
{
314324
struct config_include_data *inc = data;
315325
const char *cond, *key;

config.h

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ int git_default_config(const char *, const char *, void *);
126126
/**
127127
* Read a specific file in git-config format.
128128
* This function takes the same callback and data parameters as `git_config`.
129+
*
130+
* Unlike git_config(), this function does not respect includes.
129131
*/
130132
int git_config_from_file(config_fn_t fn, const char *, void *);
131133

@@ -158,6 +160,8 @@ void read_very_early_config(config_fn_t cb, void *data);
158160
* will first feed the user-wide one to the callback, and then the
159161
* repo-specific one; by overwriting, the higher-priority repo-specific
160162
* value is left at the end).
163+
*
164+
* Unlike git_config_from_file(), this function respects includes.
161165
*/
162166
void git_config(config_fn_t fn, void *);
163167

@@ -338,39 +342,6 @@ const char *current_config_origin_type(void);
338342
const char *current_config_name(void);
339343
int current_config_line(void);
340344

341-
/**
342-
* Include Directives
343-
* ------------------
344-
*
345-
* By default, the config parser does not respect include directives.
346-
* However, a caller can use the special `git_config_include` wrapper
347-
* callback to support them. To do so, you simply wrap your "real" callback
348-
* function and data pointer in a `struct config_include_data`, and pass
349-
* the wrapper to the regular config-reading functions. For example:
350-
*
351-
* -------------------------------------------
352-
* int read_file_with_include(const char *file, config_fn_t fn, void *data)
353-
* {
354-
* struct config_include_data inc = CONFIG_INCLUDE_INIT;
355-
* inc.fn = fn;
356-
* inc.data = data;
357-
* return git_config_from_file(git_config_include, file, &inc);
358-
* }
359-
* -------------------------------------------
360-
*
361-
* `git_config` respects includes automatically. The lower-level
362-
* `git_config_from_file` does not.
363-
*
364-
*/
365-
struct config_include_data {
366-
int depth;
367-
config_fn_t fn;
368-
void *data;
369-
const struct config_options *opts;
370-
};
371-
#define CONFIG_INCLUDE_INIT { 0 }
372-
int git_config_include(const char *name, const char *value, void *data);
373-
374345
/*
375346
* Match and parse a config key of the form:
376347
*

0 commit comments

Comments
 (0)