From: Junio C Hamano Date: Fri, 17 Aug 2018 20:09:58 +0000 (-0700) Subject: Merge branch 'hn/config-in-code-comment' X-Git-Tag: v2.19.0-rc0~40 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/f382c24ef0331d5b56461cb0c0480b58ae75cf7c?ds=inline;hp=-c Merge branch 'hn/config-in-code-comment' Header update. * hn/config-in-code-comment: config: document git config getter return value --- f382c24ef0331d5b56461cb0c0480b58ae75cf7c diff --combined config.h index 1d56fe6aa2,38e55c86bf..2d5c18b05f --- a/config.h +++ b/config.h @@@ -54,12 -54,6 +54,12 @@@ struct config_options const char *git_dir; config_parser_event_fn_t event_fn; void *event_fn_data; + enum config_error_action { + CONFIG_ERROR_UNSET = 0, /* use source-specific default */ + CONFIG_ERROR_DIE, /* die() on error */ + CONFIG_ERROR_ERROR, /* error() on error, return -1 */ + CONFIG_ERROR_SILENT, /* return -1 */ + } error_action; }; typedef int (*config_fn_t)(const char *, const char *, void *); @@@ -68,11 -62,8 +68,11 @@@ extern int git_config_from_file(config_ extern int git_config_from_file_with_options(config_fn_t fn, const char *, void *, const struct config_options *); -extern int git_config_from_mem(config_fn_t fn, const enum config_origin_type, - const char *name, const char *buf, size_t len, void *data); +extern int git_config_from_mem(config_fn_t fn, + const enum config_origin_type, + const char *name, + const char *buf, size_t len, + void *data, const struct config_options *opts); extern int git_config_from_blob_oid(config_fn_t fn, const char *name, const struct object_id *oid, void *data); extern void git_config_push_parameter(const char *text); @@@ -82,7 -73,6 +82,7 @@@ extern void git_config(config_fn_t fn, extern int config_with_options(config_fn_t fn, void *, struct git_config_source *config_source, const struct config_options *opts); +extern int git_parse_ssize_t(const char *, ssize_t *); extern int git_parse_ulong(const char *, unsigned long *); extern int git_parse_maybe_bool(const char *); extern int git_config_int(const char *, const char *); @@@ -189,9 -179,14 +189,14 @@@ struct config_set extern void git_configset_init(struct config_set *cs); extern int git_configset_add_file(struct config_set *cs, const char *filename); - extern int git_configset_get_value(struct config_set *cs, const char *key, const char **value); extern const struct string_list *git_configset_get_value_multi(struct config_set *cs, const char *key); extern void git_configset_clear(struct config_set *cs); + + /* + * These functions return 1 if not found, and 0 if found, leaving the found + * value in the 'dest' pointer. + */ + extern int git_configset_get_value(struct config_set *cs, const char *key, const char **dest); extern int git_configset_get_string_const(struct config_set *cs, const char *key, const char **dest); extern int git_configset_get_string(struct config_set *cs, const char *key, char **dest); extern int git_configset_get_int(struct config_set *cs, const char *key, int *dest); @@@ -225,6 -220,16 +230,6 @@@ extern int repo_config_get_maybe_bool(s extern int repo_config_get_pathname(struct repository *repo, const char *key, const char **dest); -/* - * Note: This function exists solely to maintain backward compatibility with - * 'fetch' and 'update_clone' storing configuration in '.gitmodules' and should - * NOT be used anywhere else. - * - * Runs the provided config function on the '.gitmodules' file found in the - * working directory. - */ -extern void config_from_gitmodules(config_fn_t fn, void *data); - extern int git_config_get_value(const char *key, const char **value); extern const struct string_list *git_config_get_value_multi(const char *key); extern void git_config_clear(void); @@@ -257,8 -262,4 +262,8 @@@ struct key_value_info extern NORETURN void git_die_config(const char *key, const char *err, ...) __attribute__((format(printf, 2, 3))); extern NORETURN void git_die_config_linenr(const char *key, const char *filename, int linenr); +#define LOOKUP_CONFIG(mapping, var) \ + lookup_config(mapping, ARRAY_SIZE(mapping), var) +int lookup_config(const char **mapping, int nr_mapping, const char *var); + #endif /* CONFIG_H */