{
int i;
struct strategy *ret;
- static struct cmdnames main_cmds, other_cmds;
+ static struct cmdnames main_cmds = {0}, other_cmds = {0};
static int loaded;
char *default_strategy = getenv("GIT_TEST_MERGE_ALGORITHM");
return &all_strategy[i];
if (!loaded) {
- struct cmdnames not_strategies;
+ struct cmdnames not_strategies = {0};
loaded = 1;
- memset(¬_strategies, 0, sizeof(struct cmdnames));
load_command_list("git-merge-", &main_cmds, &other_cmds);
for (i = 0; i < main_cmds.cnt; i++) {
int j, found = 0;
add_cmdname(¬_strategies, ent->name, ent->len);
}
exclude_cmds(&main_cmds, ¬_strategies);
+
+ cmdnames_release(¬_strategies);
}
if (!is_in_cmdlist(&main_cmds, name) && !is_in_cmdlist(&other_cmds, name)) {
fprintf(stderr, _("Could not find merge strategy '%s'.\n"), name);
CALLOC_ARRAY(ret, 1);
ret->name = xstrdup(name);
ret->attr = NO_TRIVIAL;
+
+ cmdnames_release(&main_cmds);
+ cmdnames_release(&other_cmds);
return ret;
}
cmds->names[cmds->cnt++] = ent;
}
-static void clean_cmdnames(struct cmdnames *cmds)
+void cmdnames_release(struct cmdnames *cmds)
{
int i;
for (i = 0; i < cmds->cnt; ++i)
for (i = 0; i < main_cmds.cnt; i++)
string_list_append(list, main_cmds.names[i]->name);
- clean_cmdnames(&main_cmds);
- clean_cmdnames(&other_cmds);
+ cmdnames_release(&main_cmds);
+ cmdnames_release(&other_cmds);
}
void list_all_other_cmds(struct string_list *list)
for (i = 0; i < other_cmds.cnt; i++)
string_list_append(list, other_cmds.names[i]->name);
- clean_cmdnames(&main_cmds);
- clean_cmdnames(&other_cmds);
+ cmdnames_release(&main_cmds);
+ cmdnames_release(&other_cmds);
}
void list_cmds_by_category(struct string_list *list,
if (autocorrect && n == 1 && SIMILAR_ENOUGH(best_similarity)) {
const char *assumed = main_cmds.names[0]->name;
main_cmds.names[0] = NULL;
- clean_cmdnames(&main_cmds);
+ cmdnames_release(&main_cmds);
fprintf_ln(stderr,
_("WARNING: You called a Git command named '%s', "
"which does not exist."),