Skip to content

Commit 036876a

Browse files
pks-tgitster
authored andcommitted
config: hide functions using the_repository by default
The config subsystem provides a bunch of legacy functions that read or set configuration for `the_repository`. The use of those functions is discouraged, and it is easy to miss the implicit dependency on `the_repository` that calls to those functions may cause. Move all config-related functions that use `the_repository` into a block that gets only conditionally compiled depending on whether or not the macro has been defined. This also removes all dependencies on that variable in "config.c", allowing us to remove the definition of said preprocessor macro. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 219de84 commit 036876a

File tree

2 files changed

+171
-208
lines changed

2 files changed

+171
-208
lines changed

config.c

Lines changed: 0 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
*
77
*/
88

9-
#define USE_THE_REPOSITORY_VARIABLE
10-
119
#include "git-compat-util.h"
1210
#include "abspath.h"
1311
#include "advice.h"
@@ -2695,78 +2693,6 @@ void git_protected_config(config_fn_t fn, void *data)
26952693
configset_iter(&protected_config, fn, data);
26962694
}
26972695

2698-
/* Functions used historically to read configuration from 'the_repository' */
2699-
void git_config(config_fn_t fn, void *data)
2700-
{
2701-
repo_config(the_repository, fn, data);
2702-
}
2703-
2704-
void git_config_clear(void)
2705-
{
2706-
repo_config_clear(the_repository);
2707-
}
2708-
2709-
int git_config_get(const char *key)
2710-
{
2711-
return repo_config_get(the_repository, key);
2712-
}
2713-
2714-
int git_config_get_value(const char *key, const char **value)
2715-
{
2716-
return repo_config_get_value(the_repository, key, value);
2717-
}
2718-
2719-
int git_config_get_value_multi(const char *key, const struct string_list **dest)
2720-
{
2721-
return repo_config_get_value_multi(the_repository, key, dest);
2722-
}
2723-
2724-
int git_config_get_string_multi(const char *key,
2725-
const struct string_list **dest)
2726-
{
2727-
return repo_config_get_string_multi(the_repository, key, dest);
2728-
}
2729-
2730-
int git_config_get_string(const char *key, char **dest)
2731-
{
2732-
return repo_config_get_string(the_repository, key, dest);
2733-
}
2734-
2735-
int git_config_get_string_tmp(const char *key, const char **dest)
2736-
{
2737-
return repo_config_get_string_tmp(the_repository, key, dest);
2738-
}
2739-
2740-
int git_config_get_int(const char *key, int *dest)
2741-
{
2742-
return repo_config_get_int(the_repository, key, dest);
2743-
}
2744-
2745-
int git_config_get_ulong(const char *key, unsigned long *dest)
2746-
{
2747-
return repo_config_get_ulong(the_repository, key, dest);
2748-
}
2749-
2750-
int git_config_get_bool(const char *key, int *dest)
2751-
{
2752-
return repo_config_get_bool(the_repository, key, dest);
2753-
}
2754-
2755-
int git_config_get_bool_or_int(const char *key, int *is_bool, int *dest)
2756-
{
2757-
return repo_config_get_bool_or_int(the_repository, key, is_bool, dest);
2758-
}
2759-
2760-
int git_config_get_maybe_bool(const char *key, int *dest)
2761-
{
2762-
return repo_config_get_maybe_bool(the_repository, key, dest);
2763-
}
2764-
2765-
int git_config_get_pathname(const char *key, char **dest)
2766-
{
2767-
return repo_config_get_pathname(the_repository, key, dest);
2768-
}
2769-
27702696
int repo_config_get_expiry(struct repository *r, const char *key, const char **output)
27712697
{
27722698
int ret = repo_config_get_string(r, key, (char **)output);
@@ -3186,35 +3112,17 @@ int repo_config_set_in_file_gently(struct repository *r, const char *config_file
31863112
return repo_config_set_multivar_in_file_gently(r, config_filename, key, value, NULL, comment, 0);
31873113
}
31883114

3189-
int git_config_set_in_file_gently(const char *config_filename,
3190-
const char *key, const char *comment, const char *value)
3191-
{
3192-
return repo_config_set_in_file_gently(the_repository, config_filename,
3193-
key, comment, value);
3194-
}
3195-
31963115
void repo_config_set_in_file(struct repository *r, const char *config_filename,
31973116
const char *key, const char *value)
31983117
{
31993118
repo_config_set_multivar_in_file(r, config_filename, key, value, NULL, 0);
32003119
}
32013120

3202-
void git_config_set_in_file(const char *config_filename,
3203-
const char *key, const char *value)
3204-
{
3205-
repo_config_set_in_file(the_repository, config_filename, key, value);
3206-
}
3207-
32083121
int repo_config_set_gently(struct repository *r, const char *key, const char *value)
32093122
{
32103123
return repo_config_set_multivar_gently(r, key, value, NULL, 0);
32113124
}
32123125

3213-
int git_config_set_gently(const char *key, const char *value)
3214-
{
3215-
return repo_config_set_gently(the_repository, key, value);
3216-
}
3217-
32183126
int repo_config_set_worktree_gently(struct repository *r,
32193127
const char *key, const char *value)
32203128
{
@@ -3236,11 +3144,6 @@ void repo_config_set(struct repository *r, const char *key, const char *value)
32363144
trace2_cmd_set_config(key, value);
32373145
}
32383146

3239-
void git_config_set(const char *key, const char *value)
3240-
{
3241-
repo_config_set(the_repository, key, value);
3242-
}
3243-
32443147
char *git_config_prepare_comment_string(const char *comment)
32453148
{
32463149
size_t leading_blanks;
@@ -3569,17 +3472,6 @@ int repo_config_set_multivar_in_file_gently(struct repository *r,
35693472
goto out_free;
35703473
}
35713474

3572-
int git_config_set_multivar_in_file_gently(const char *config_filename,
3573-
const char *key, const char *value,
3574-
const char *value_pattern,
3575-
const char *comment,
3576-
unsigned flags)
3577-
{
3578-
return repo_config_set_multivar_in_file_gently(the_repository, config_filename,
3579-
key, value, value_pattern,
3580-
comment, flags);
3581-
}
3582-
35833475
void repo_config_set_multivar_in_file(struct repository *r,
35843476
const char *config_filename,
35853477
const char *key, const char *value,
@@ -3594,21 +3486,6 @@ void repo_config_set_multivar_in_file(struct repository *r,
35943486
die(_("could not unset '%s'"), key);
35953487
}
35963488

3597-
void git_config_set_multivar_in_file(const char *config_filename,
3598-
const char *key, const char *value,
3599-
const char *value_pattern, unsigned flags)
3600-
{
3601-
repo_config_set_multivar_in_file(the_repository, config_filename,
3602-
key, value, value_pattern, flags);
3603-
}
3604-
3605-
int git_config_set_multivar_gently(const char *key, const char *value,
3606-
const char *value_pattern, unsigned flags)
3607-
{
3608-
return repo_config_set_multivar_gently(the_repository, key, value,
3609-
value_pattern, flags);
3610-
}
3611-
36123489
int repo_config_set_multivar_gently(struct repository *r, const char *key,
36133490
const char *value,
36143491
const char *value_pattern, unsigned flags)
@@ -3632,13 +3509,6 @@ void repo_config_set_multivar(struct repository *r,
36323509
free(file);
36333510
}
36343511

3635-
void git_config_set_multivar(const char *key, const char *value,
3636-
const char *value_pattern, unsigned flags)
3637-
{
3638-
repo_config_set_multivar(the_repository, key, value,
3639-
value_pattern, flags);
3640-
}
3641-
36423512
static size_t section_name_match (const char *buf, const char *name)
36433513
{
36443514
size_t i = 0, j = 0;

0 commit comments

Comments
 (0)