submodule-config: add helper function to get 'fetch' config from .gitmodules
Add a helper function to make it clearer that retrieving 'fetch' configuration from the .gitmodules file is a special case supported solely for backward compatibility purposes. This change removes one direct use of 'config_from_gitmodules' in code not strictly related to submodules, in the effort to communicate better that .gitmodules is not to be used as a mechanism to store arbitrary configuration in the repository that any command can retrieve. Signed-off-by: Antonio Ospite <ao2@ao2.it> Acked-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
ad136370b2
commit
71a6953d16
@ -688,3 +688,31 @@ void config_from_gitmodules(config_fn_t fn, void *data)
|
||||
free(file);
|
||||
}
|
||||
}
|
||||
|
||||
struct fetch_config {
|
||||
int *max_children;
|
||||
int *recurse_submodules;
|
||||
};
|
||||
|
||||
static int gitmodules_fetch_config(const char *var, const char *value, void *cb)
|
||||
{
|
||||
struct fetch_config *config = cb;
|
||||
if (!strcmp(var, "submodule.fetchjobs")) {
|
||||
*(config->max_children) = parse_submodule_fetchjobs(var, value);
|
||||
return 0;
|
||||
} else if (!strcmp(var, "fetch.recursesubmodules")) {
|
||||
*(config->recurse_submodules) = parse_fetch_recurse_submodules_arg(var, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void fetch_config_from_gitmodules(int *max_children, int *recurse_submodules)
|
||||
{
|
||||
struct fetch_config config = {
|
||||
.max_children = max_children,
|
||||
.recurse_submodules = recurse_submodules
|
||||
};
|
||||
config_from_gitmodules(gitmodules_fetch_config, &config);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user