On 24/08/07 08:58AM, Patrick Steinhardt wrote: > The config subsytem provides a bunch of legacy functions that read or s/subsytem/subsystem/ > 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. Here we are making the same change done earlier to "path.h". Use of config functions that rely on `the_repository` implicitly now require the caller to define `USE_THE_REPOSITORY_VARIABLE` explicitly. Thus improving visibility of use. > Signed-off-by: Patrick Steinhardt <ps@xxxxxx> > --- [snip] > +# ifdef USE_THE_REPOSITORY_VARIABLE > +static inline void git_config(config_fn_t fn, void *data) > +{ > + repo_config(the_repository, fn, data); > +} > + > +static inline void git_config_clear(void) > +{ > + repo_config_clear(the_repository); > +} > + > +static inline int git_config_get(const char *key) > +{ > + return repo_config_get(the_repository, key); > +} > + > +static inline int git_config_get_value(const char *key, const char **value) > +{ > + return repo_config_get_value(the_repository, key, value); > +} > + > +static inline int git_config_get_value_multi(const char *key, const struct string_list **dest) > +{ > + return repo_config_get_value_multi(the_repository, key, dest); > +} > + > +static inline int git_config_get_string_multi(const char *key, > + const struct string_list **dest) > +{ > + return repo_config_get_string_multi(the_repository, key, dest); > +} > + > +static inline int git_config_get_string(const char *key, char **dest) > +{ > + return repo_config_get_string(the_repository, key, dest); > +} > + > +static inline int git_config_get_string_tmp(const char *key, const char **dest) > +{ > + return repo_config_get_string_tmp(the_repository, key, dest); > +} > + > +static inline int git_config_get_int(const char *key, int *dest) > +{ > + return repo_config_get_int(the_repository, key, dest); > +} > + > +static inline int git_config_get_ulong(const char *key, unsigned long *dest) > +{ > + return repo_config_get_ulong(the_repository, key, dest); > +} > + > +static inline int git_config_get_bool(const char *key, int *dest) > +{ > + return repo_config_get_bool(the_repository, key, dest); > +} > + > +static inline int git_config_get_bool_or_int(const char *key, int *is_bool, int *dest) > +{ > + return repo_config_get_bool_or_int(the_repository, key, is_bool, dest); > +} > + > +static inline int git_config_get_maybe_bool(const char *key, int *dest) > +{ > + return repo_config_get_maybe_bool(the_repository, key, dest); > +} > + > +static inline int git_config_get_pathname(const char *key, char **dest) > +{ > + return repo_config_get_pathname(the_repository, key, dest); > +} > + > +static inline void git_config_set_in_file(const char *config_filename, > + const char *key, const char *value) > +{ > + repo_config_set_in_file(the_repository, config_filename, key, value); > +} > + > +static inline int git_config_set_gently(const char *key, const char *value) > +{ > + return repo_config_set_gently(the_repository, key, value); > +} > + > +static inline void git_config_set(const char *key, const char *value) > +{ > + repo_config_set(the_repository, key, value); > +} > + > +static inline int git_config_set_in_file_gently( > + const char *config_filename, > + const char *key, > + const char *comment, > + const char *value) > +{ > + return repo_config_set_in_file_gently(the_repository, config_filename, > + key, comment, value); > +} > + > +static inline int git_config_set_multivar_in_file_gently( > + const char *config_filename, > + const char *key, const char *value, > + const char *value_pattern, > + const char *comment, > + unsigned flags) > +{ > + return repo_config_set_multivar_in_file_gently(the_repository, config_filename, > + key, value, value_pattern, > + comment, flags); > +} > + > +static inline void git_config_set_multivar_in_file( > + const char *config_filename, > + const char *key, > + const char *value, > + const char *value_pattern, > + unsigned flags) > +{ > + repo_config_set_multivar_in_file(the_repository, config_filename, > + key, value, value_pattern, flags); > +} > + > +static inline int git_config_set_multivar_gently(const char *key, const char *value, > + const char *value_pattern, unsigned flags) > +{ > + return repo_config_set_multivar_gently(the_repository, key, value, > + value_pattern, flags); > +} > + > +static inline void git_config_set_multivar(const char *key, const char *value, > + const char *value_pattern, unsigned flags) > +{ > + repo_config_set_multivar(the_repository, key, value, > + value_pattern, flags); > +} > +# endif /* USE_THE_REPOSITORY_VARIABLE */ Once again, very neat to see this guarded behind `USE_THE_REPOSITORY_VARIABLE` now. :) -Justin