зеркало из https://github.com/microsoft/git.git
Merge branch 'jk/parse-config-key-cleanup' into maint
The "parse_config_key()" API function has been cleaned up. * jk/parse-config-key-cleanup: parse_hide_refs_config: tell parse_config_key we don't want a subsection parse_config_key: allow matching single-level config parse_config_key: use skip_prefix instead of starts_with refs: parse_hide_refs_config to use parse_config_key
This commit is contained in:
Коммит
c772d1bcdc
5
cache.h
5
cache.h
|
@ -1816,8 +1816,11 @@ extern int git_config_include(const char *name, const char *value, void *data);
|
||||||
*
|
*
|
||||||
* (i.e., what gets handed to a config_fn_t). The caller provides the section;
|
* (i.e., what gets handed to a config_fn_t). The caller provides the section;
|
||||||
* we return -1 if it does not match, 0 otherwise. The subsection and key
|
* we return -1 if it does not match, 0 otherwise. The subsection and key
|
||||||
* out-parameters are filled by the function (and subsection is NULL if it is
|
* out-parameters are filled by the function (and *subsection is NULL if it is
|
||||||
* missing).
|
* missing).
|
||||||
|
*
|
||||||
|
* If the subsection pointer-to-pointer passed in is NULL, returns 0 only if
|
||||||
|
* there is no subsection at all.
|
||||||
*/
|
*/
|
||||||
extern int parse_config_key(const char *var,
|
extern int parse_config_key(const char *var,
|
||||||
const char *section,
|
const char *section,
|
||||||
|
|
11
config.c
11
config.c
|
@ -2540,11 +2540,10 @@ int parse_config_key(const char *var,
|
||||||
const char **subsection, int *subsection_len,
|
const char **subsection, int *subsection_len,
|
||||||
const char **key)
|
const char **key)
|
||||||
{
|
{
|
||||||
int section_len = strlen(section);
|
|
||||||
const char *dot;
|
const char *dot;
|
||||||
|
|
||||||
/* Does it start with "section." ? */
|
/* Does it start with "section." ? */
|
||||||
if (!starts_with(var, section) || var[section_len] != '.')
|
if (!skip_prefix(var, section, &var) || *var != '.')
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2556,12 +2555,16 @@ int parse_config_key(const char *var,
|
||||||
*key = dot + 1;
|
*key = dot + 1;
|
||||||
|
|
||||||
/* Did we have a subsection at all? */
|
/* Did we have a subsection at all? */
|
||||||
if (dot == var + section_len) {
|
if (dot == var) {
|
||||||
|
if (subsection) {
|
||||||
*subsection = NULL;
|
*subsection = NULL;
|
||||||
*subsection_len = 0;
|
*subsection_len = 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
*subsection = var + section_len + 1;
|
if (!subsection)
|
||||||
|
return -1;
|
||||||
|
*subsection = var + 1;
|
||||||
*subsection_len = dot - *subsection;
|
*subsection_len = dot - *subsection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
6
refs.c
6
refs.c
|
@ -1034,10 +1034,10 @@ static struct string_list *hide_refs;
|
||||||
|
|
||||||
int parse_hide_refs_config(const char *var, const char *value, const char *section)
|
int parse_hide_refs_config(const char *var, const char *value, const char *section)
|
||||||
{
|
{
|
||||||
|
const char *key;
|
||||||
if (!strcmp("transfer.hiderefs", var) ||
|
if (!strcmp("transfer.hiderefs", var) ||
|
||||||
/* NEEDSWORK: use parse_config_key() once both are merged */
|
(!parse_config_key(var, section, NULL, NULL, &key) &&
|
||||||
(starts_with(var, section) && var[strlen(section)] == '.' &&
|
!strcmp(key, "hiderefs"))) {
|
||||||
!strcmp(var + strlen(section), ".hiderefs"))) {
|
|
||||||
char *ref;
|
char *ref;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче