зеркало из https://github.com/microsoft/git.git
submodule--helper: add and use *_release() functions
Add release functions for "struct module_list", "struct submodule_update_clone" and "struct update_data". Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Reviewed-by: Glen Choo <chooglen@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Родитель
0a4d31537d
Коммит
87a683482a
|
@ -172,6 +172,11 @@ struct module_list {
|
||||||
};
|
};
|
||||||
#define MODULE_LIST_INIT { 0 }
|
#define MODULE_LIST_INIT { 0 }
|
||||||
|
|
||||||
|
static void module_list_release(struct module_list *ml)
|
||||||
|
{
|
||||||
|
free(ml->entries);
|
||||||
|
}
|
||||||
|
|
||||||
static int module_list_compute(int argc, const char **argv,
|
static int module_list_compute(int argc, const char **argv,
|
||||||
const char *prefix,
|
const char *prefix,
|
||||||
struct pathspec *pathspec,
|
struct pathspec *pathspec,
|
||||||
|
@ -234,7 +239,7 @@ static void module_list_active(struct module_list *list)
|
||||||
active_modules.entries[active_modules.nr++] = ce;
|
active_modules.entries[active_modules.nr++] = ce;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(list->entries);
|
module_list_release(list);
|
||||||
*list = active_modules;
|
*list = active_modules;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -407,6 +412,7 @@ static int module_foreach(int argc, const char **argv, const char *prefix)
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
|
module_list_release(&list);
|
||||||
clear_pathspec(&pathspec);
|
clear_pathspec(&pathspec);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -553,6 +559,7 @@ static int module_init(int argc, const char **argv, const char *prefix)
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
|
module_list_release(&list);
|
||||||
clear_pathspec(&pathspec);
|
clear_pathspec(&pathspec);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -730,6 +737,7 @@ static int module_status(int argc, const char **argv, const char *prefix)
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
|
module_list_release(&list);
|
||||||
clear_pathspec(&pathspec);
|
clear_pathspec(&pathspec);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -1302,6 +1310,7 @@ static int module_sync(int argc, const char **argv, const char *prefix)
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
|
module_list_release(&list);
|
||||||
clear_pathspec(&pathspec);
|
clear_pathspec(&pathspec);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -1454,6 +1463,7 @@ static int module_deinit(int argc, const char **argv, const char *prefix)
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
|
module_list_release(&list);
|
||||||
clear_pathspec(&pathspec);
|
clear_pathspec(&pathspec);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -1831,6 +1841,12 @@ struct submodule_update_clone {
|
||||||
};
|
};
|
||||||
#define SUBMODULE_UPDATE_CLONE_INIT { 0 }
|
#define SUBMODULE_UPDATE_CLONE_INIT { 0 }
|
||||||
|
|
||||||
|
static void submodule_update_clone_release(struct submodule_update_clone *suc)
|
||||||
|
{
|
||||||
|
free(suc->update_clone);
|
||||||
|
free(suc->failed_clones);
|
||||||
|
}
|
||||||
|
|
||||||
struct update_data {
|
struct update_data {
|
||||||
const char *prefix;
|
const char *prefix;
|
||||||
const char *displaypath;
|
const char *displaypath;
|
||||||
|
@ -1869,6 +1885,11 @@ struct update_data {
|
||||||
.max_jobs = 1, \
|
.max_jobs = 1, \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void update_data_release(struct update_data *ud)
|
||||||
|
{
|
||||||
|
module_list_release(&ud->list);
|
||||||
|
}
|
||||||
|
|
||||||
static void next_submodule_warn_missing(struct submodule_update_clone *suc,
|
static void next_submodule_warn_missing(struct submodule_update_clone *suc,
|
||||||
struct strbuf *out, const char *displaypath)
|
struct strbuf *out, const char *displaypath)
|
||||||
{
|
{
|
||||||
|
@ -2554,6 +2575,7 @@ static int update_submodules(struct update_data *update_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
submodule_update_clone_release(&suc);
|
||||||
string_list_clear(&update_data->references, 0);
|
string_list_clear(&update_data->references, 0);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -2651,6 +2673,7 @@ static int module_update(int argc, const char **argv, const char *prefix)
|
||||||
|
|
||||||
if (module_list_compute(argc, argv, opt.prefix,
|
if (module_list_compute(argc, argv, opt.prefix,
|
||||||
&pathspec2, &list) < 0) {
|
&pathspec2, &list) < 0) {
|
||||||
|
module_list_release(&list);
|
||||||
ret = 1;
|
ret = 1;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
@ -2667,10 +2690,12 @@ static int module_update(int argc, const char **argv, const char *prefix)
|
||||||
info.flags |= OPT_QUIET;
|
info.flags |= OPT_QUIET;
|
||||||
|
|
||||||
for_each_listed_submodule(&list, init_submodule_cb, &info);
|
for_each_listed_submodule(&list, init_submodule_cb, &info);
|
||||||
|
module_list_release(&list);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = update_submodules(&opt);
|
ret = update_submodules(&opt);
|
||||||
cleanup:
|
cleanup:
|
||||||
|
update_data_release(&opt);
|
||||||
list_objects_filter_release(&filter_options);
|
list_objects_filter_release(&filter_options);
|
||||||
clear_pathspec(&pathspec);
|
clear_pathspec(&pathspec);
|
||||||
clear_pathspec(&pathspec2);
|
clear_pathspec(&pathspec2);
|
||||||
|
@ -2786,6 +2811,7 @@ static int absorb_git_dirs(int argc, const char **argv, const char *prefix)
|
||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
clear_pathspec(&pathspec);
|
clear_pathspec(&pathspec);
|
||||||
|
module_list_release(&list);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
test_description='test case exclude pathspec'
|
test_description='test case exclude pathspec'
|
||||||
|
|
||||||
|
TEST_PASSES_SANITIZE_LEAK=true
|
||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
|
|
||||||
test_expect_success 'setup a submodule' '
|
test_expect_success 'setup a submodule' '
|
||||||
|
|
Загрузка…
Ссылка в новой задаче