mirror of
https://git.proxmox.com/git/libgit2
synced 2025-08-05 05:48:29 +00:00
Rearrange clar submodule cleanup code
This commit is contained in:
parent
b47349b8dc
commit
d5b1866cc3
@ -11,7 +11,6 @@ void test_diff_submodules__initialize(void)
|
|||||||
|
|
||||||
void test_diff_submodules__cleanup(void)
|
void test_diff_submodules__cleanup(void)
|
||||||
{
|
{
|
||||||
cleanup_fixture_submodules();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void check_diff_patches_at_line(
|
static void check_diff_patches_at_line(
|
||||||
|
@ -13,7 +13,6 @@ void test_status_submodules__initialize(void)
|
|||||||
|
|
||||||
void test_status_submodules__cleanup(void)
|
void test_status_submodules__cleanup(void)
|
||||||
{
|
{
|
||||||
cleanup_fixture_submodules();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_status_submodules__api(void)
|
void test_status_submodules__api(void)
|
||||||
|
@ -14,7 +14,6 @@ void test_submodule_status__initialize(void)
|
|||||||
|
|
||||||
void test_submodule_status__cleanup(void)
|
void test_submodule_status__cleanup(void)
|
||||||
{
|
{
|
||||||
cleanup_fixture_submodules();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_submodule_status__unchanged(void)
|
void test_submodule_status__unchanged(void)
|
||||||
|
@ -83,6 +83,14 @@ void rewrite_gitmodules(const char *workdir)
|
|||||||
git_buf_free(&path);
|
git_buf_free(&path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void cleanup_fixture_submodules(void *payload)
|
||||||
|
{
|
||||||
|
cl_git_sandbox_cleanup(); /* either "submodules" or "submod2" */
|
||||||
|
|
||||||
|
if (payload)
|
||||||
|
cl_fixture_cleanup(payload);
|
||||||
|
}
|
||||||
|
|
||||||
git_repository *setup_fixture_submodules(void)
|
git_repository *setup_fixture_submodules(void)
|
||||||
{
|
{
|
||||||
git_repository *repo = cl_git_sandbox_init("submodules");
|
git_repository *repo = cl_git_sandbox_init("submodules");
|
||||||
@ -92,6 +100,8 @@ git_repository *setup_fixture_submodules(void)
|
|||||||
rewrite_gitmodules(git_repository_workdir(repo));
|
rewrite_gitmodules(git_repository_workdir(repo));
|
||||||
p_rename("submodules/testrepo/.gitted", "submodules/testrepo/.git");
|
p_rename("submodules/testrepo/.gitted", "submodules/testrepo/.git");
|
||||||
|
|
||||||
|
cl_set_cleanup(cleanup_fixture_submodules, "testrepo.git");
|
||||||
|
|
||||||
return repo;
|
return repo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,14 +116,7 @@ git_repository *setup_fixture_submod2(void)
|
|||||||
p_rename("submod2/not-submodule/.gitted", "submod2/not-submodule/.git");
|
p_rename("submod2/not-submodule/.gitted", "submod2/not-submodule/.git");
|
||||||
p_rename("submod2/not/.gitted", "submod2/not/.git");
|
p_rename("submod2/not/.gitted", "submod2/not/.git");
|
||||||
|
|
||||||
|
cl_set_cleanup(cleanup_fixture_submodules, "submod2_target");
|
||||||
|
|
||||||
return repo;
|
return repo;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cleanup_fixture_submodules(void)
|
|
||||||
{
|
|
||||||
cl_git_sandbox_cleanup();
|
|
||||||
|
|
||||||
/* just try to clean up both possible extras */
|
|
||||||
cl_fixture_cleanup("testrepo.git");
|
|
||||||
cl_fixture_cleanup("submod2_target");
|
|
||||||
}
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
extern void rewrite_gitmodules(const char *workdir);
|
extern void rewrite_gitmodules(const char *workdir);
|
||||||
|
|
||||||
|
/* these will automatically set a cleanup callback */
|
||||||
extern git_repository *setup_fixture_submodules(void);
|
extern git_repository *setup_fixture_submodules(void);
|
||||||
extern git_repository *setup_fixture_submod2(void);
|
extern git_repository *setup_fixture_submod2(void);
|
||||||
extern void cleanup_fixture_submodules(void);
|
|
||||||
|
Loading…
Reference in New Issue
Block a user