@@ -531,6 +531,7 @@ static int module_init(int argc, const char **argv, const char *prefix)
struct init_cb info = INIT_CB_INIT;
struct pathspec pathspec = { 0 };
struct module_list list = MODULE_LIST_INIT;
+ const struct string_list *active_modules;
int quiet = 0;
struct option module_init_options[] = {
OPT__QUIET(&quiet, N_("suppress output for initializing a submodule")),
@@ -552,7 +553,9 @@ static int module_init(int argc, const char **argv, const char *prefix)
* If there are no path args and submodule.active is set then,
* by default, only initialize 'active' modules.
*/
- if (!argc && git_config_get_value_multi("submodule.active"))
+ if (!argc &&
+ (active_modules = git_config_get_value_multi("submodule.active")) &&
+ active_modules->nr)
module_list_active(&list);
info.prefix = prefix;
@@ -2706,6 +2709,7 @@ static int module_update(int argc, const char **argv, const char *prefix)
opt.warn_if_uninitialized = 1;
if (opt.init) {
+ const struct string_list *active_modules;
struct module_list list = MODULE_LIST_INIT;
struct init_cb info = INIT_CB_INIT;
@@ -2720,7 +2724,9 @@ static int module_update(int argc, const char **argv, const char *prefix)
* If there are no path args and submodule.active is set then,
* by default, only initialize 'active' modules.
*/
- if (!argc && git_config_get_value_multi("submodule.active"))
+ if (!argc &&
+ (active_modules = git_config_get_value_multi("submodule.active")) &&
+ active_modules->nr)
module_list_active(&list);
info.prefix = opt.prefix;
@@ -275,7 +275,7 @@ int is_tree_submodule_active(struct repository *repo,
/* submodule.active is set */
sl = repo_config_get_value_multi(repo, "submodule.active");
- if (sl) {
+ if (sl && sl->nr) {
struct pathspec ps;
struct strvec args = STRVEC_INIT;
const struct string_list_item *item;
@@ -96,7 +96,7 @@ int cmd__config(int argc, const char **argv)
}
} else if (argc == 3 && !strcmp(argv[1], "get_value_multi")) {
strptr = git_config_get_value_multi(argv[2]);
- if (strptr) {
+ if (strptr && strptr->nr) {
for (i = 0; i < strptr->nr; i++) {
v = strptr->items[i].string;
if (!v)
@@ -160,7 +160,7 @@ int cmd__config(int argc, const char **argv)
}
}
strptr = git_configset_get_value_multi(&cs, argv[2]);
- if (strptr) {
+ if (strptr && strptr->nr) {
for (i = 0; i < strptr->nr; i++) {
v = strptr->items[i].string;
if (!v)
@@ -164,14 +164,14 @@ int versioncmp(const char *s1, const char *s2)
initialized = 1;
prereleases = git_config_get_value_multi("versionsort.suffix");
deprecated_prereleases = git_config_get_value_multi("versionsort.prereleasesuffix");
- if (prereleases) {
- if (deprecated_prereleases)
+ if (prereleases && prereleases->nr) {
+ if (deprecated_prereleases && deprecated_prereleases->nr)
warning("ignoring versionsort.prereleasesuffix because versionsort.suffix is set");
} else
prereleases = deprecated_prereleases;
}
- if (prereleases && swap_prereleases(s1, s2, (const char *) p1 - s1 - 1,
- &diff))
+ if (prereleases && prereleases->nr &&
+ swap_prereleases(s1, s2, (const char *) p1 - s1 - 1, &diff))
return diff;
state = result_type[state * 3 + (((c2 == '0') + (isdigit (c2) != 0)))];