@@ -44,14 +44,6 @@ int cmd_for_each_repo(int argc, const char **argv, const char *prefix)
values = repo_config_get_value_multi(the_repository,
config_key);
-
- /*
- * Do nothing on an empty list, which is equivalent to the case
- * where the config variable does not exist at all.
- */
- if (!values)
- return 0;
-
for (i = 0; !result && i < values->nr; i++)
result = run_command_on_repo(values->items[i].string, argc, argv);
@@ -1493,12 +1493,10 @@ static int maintenance_register(int argc, const char **argv, const char *prefix)
git_config_set("maintenance.strategy", "incremental");
list = git_config_get_value_multi(key);
- if (list) {
- for_each_string_list_item(item, list) {
- if (!strcmp(maintpath, item->string)) {
- found = 1;
- break;
- }
+ for_each_string_list_item(item, list) {
+ if (!strcmp(maintpath, item->string)) {
+ found = 1;
+ break;
}
}
@@ -1550,12 +1548,10 @@ static int maintenance_unregister(int argc, const char **argv, const char *prefi
options);
list = git_config_get_value_multi(key);
- if (list) {
- for_each_string_list_item(item, list) {
- if (!strcmp(maintpath, item->string)) {
- found = 1;
- break;
- }
+ for_each_string_list_item(item, list) {
+ if (!strcmp(maintpath, item->string)) {
+ found = 1;
+ break;
}
}
@@ -182,15 +182,13 @@ static void set_default_decoration_filter(struct decoration_filter *decoration_f
int i;
char *value = NULL;
struct string_list *include = decoration_filter->include_ref_pattern;
+ struct string_list_item *item;
const struct string_list *config_exclude =
git_config_get_value_multi("log.excludeDecoration");
- if (config_exclude) {
- struct string_list_item *item;
- for_each_string_list_item(item, config_exclude)
- string_list_append(decoration_filter->exclude_ref_config_pattern,
- item->string);
- }
+ for_each_string_list_item(item, config_exclude)
+ string_list_append(decoration_filter->exclude_ref_config_pattern,
+ item->string);
/*
* By default, decorate_all is disabled. Enable it if
@@ -3982,9 +3982,6 @@ static void mark_bitmap_preferred_tips(void)
const struct string_list *preferred_tips;
preferred_tips = bitmap_preferred_tips(the_repository);
- if (!preferred_tips)
- return;
-
for_each_string_list_item(item, preferred_tips) {
for_each_ref_in(item->string, mark_bitmap_preferred_tip, NULL);
}
@@ -539,6 +539,7 @@ static int midx_snapshot_ref_one(const char *refname UNUSED,
static void midx_snapshot_refs(struct tempfile *f)
{
struct midx_snapshot_ref_data data;
+ struct string_list_item *item;
const struct string_list *preferred = bitmap_preferred_tips(the_repository);
data.f = f;
@@ -549,14 +550,10 @@ static void midx_snapshot_refs(struct tempfile *f)
die(_("could not open tempfile %s for writing"),
get_tempfile_path(f));
- if (preferred) {
- struct string_list_item *item;
-
- data.preferred = 1;
- for_each_string_list_item(item, preferred)
- for_each_ref_in(item->string, midx_snapshot_ref_one, &data);
- data.preferred = 0;
- }
+ data.preferred = 1;
+ for_each_string_list_item(item, preferred)
+ for_each_ref_in(item->string, midx_snapshot_ref_one, &data);
+ data.preferred = 0;
for_each_ref(midx_snapshot_ref_one, &data);
@@ -531,7 +531,6 @@ 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")),
@@ -553,9 +552,7 @@ 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 &&
- (active_modules = git_config_get_value_multi("submodule.active")) &&
- active_modules->nr)
+ if (!argc && git_config_get_value_multi("submodule.active")->nr)
module_list_active(&list);
info.prefix = prefix;
@@ -2709,7 +2706,6 @@ 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;
@@ -2724,9 +2720,7 @@ 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 &&
- (active_modules = git_config_get_value_multi("submodule.active")) &&
- active_modules->nr)
+ if (!argc && git_config_get_value_multi("submodule.active")->nr)
module_list_active(&list);
info.prefix = opt.prefix;
@@ -2407,7 +2407,7 @@ int git_configset_get_value(struct config_set *cs, const char *key, const char *
*/
values = git_configset_get_value_multi(cs, key);
- if (!values || !values->nr)
+ if (!values->nr)
return 1;
*value = values->items[values->nr - 1].string;
return 0;
@@ -2310,9 +2310,6 @@ int bitmap_is_preferred_refname(struct repository *r, const char *refname)
const struct string_list *preferred_tips = bitmap_preferred_tips(r);
struct string_list_item *item;
- if (!preferred_tips)
- return 0;
-
for_each_string_list_item(item, preferred_tips) {
if (starts_with(refname, item->string))
return 1;
@@ -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 && strptr->nr) {
+ if (strptr->nr) {
for (i = 0; i < strptr->nr; i++) {
v = strptr->items[i].string;
if (!v)