mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-03 02:40:09 +00:00
tests: implement worktree helpers
This commit is contained in:
parent
8acc3b16ef
commit
807d57e7df
30
tests/worktree/worktree_helpers.c
Normal file
30
tests/worktree/worktree_helpers.c
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#include "clar_libgit2.h"
|
||||||
|
#include "worktree_helpers.h"
|
||||||
|
|
||||||
|
void cleanup_fixture_worktree(worktree_fixture *fixture)
|
||||||
|
{
|
||||||
|
if (!fixture)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (fixture->repo) {
|
||||||
|
git_repository_free(fixture->repo);
|
||||||
|
fixture->repo = NULL;
|
||||||
|
}
|
||||||
|
if (fixture->worktree) {
|
||||||
|
git_repository_free(fixture->worktree);
|
||||||
|
fixture->worktree = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fixture->reponame)
|
||||||
|
cl_fixture_cleanup(fixture->reponame);
|
||||||
|
if (fixture->worktreename)
|
||||||
|
cl_fixture_cleanup(fixture->worktreename);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setup_fixture_worktree(worktree_fixture *fixture)
|
||||||
|
{
|
||||||
|
if (fixture->reponame)
|
||||||
|
fixture->repo = cl_git_sandbox_init(fixture->reponame);
|
||||||
|
if (fixture->worktreename)
|
||||||
|
fixture->worktree = cl_git_sandbox_init(fixture->worktreename);
|
||||||
|
}
|
11
tests/worktree/worktree_helpers.h
Normal file
11
tests/worktree/worktree_helpers.h
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
typedef struct {
|
||||||
|
const char *reponame;
|
||||||
|
const char *worktreename;
|
||||||
|
git_repository *repo;
|
||||||
|
git_repository *worktree;
|
||||||
|
} worktree_fixture;
|
||||||
|
|
||||||
|
#define WORKTREE_FIXTURE_INIT(repo, worktree) { (repo), (worktree), NULL, NULL }
|
||||||
|
|
||||||
|
void cleanup_fixture_worktree(worktree_fixture *fixture);
|
||||||
|
void setup_fixture_worktree(worktree_fixture *fixture);
|
Loading…
Reference in New Issue
Block a user