Commit 939d8d57 by Nika Layzell

mailmap: Support path fixtures in cl_git_repository_init()

parent b88cbf8c
......@@ -72,6 +72,7 @@ void cl_trace_register(cl_trace_cb *cb, void *payload);
const char *cl_fixture(const char *fixture_name);
void cl_fixture_sandbox(const char *fixture_name);
void cl_fixture_cleanup(const char *fixture_name);
const char *cl_fixture_basename(const char *fixture_name);
#endif
/**
......
......@@ -20,19 +20,6 @@ fixture_path(const char *base, const char *fixture_name)
return _path;
}
static const char *
fixture_basename(const char *fixture_name)
{
const char *p;
for (p = fixture_name; *p; p++) {
if (p[0] == '/' && p[1] && p[1] != '/')
fixture_name = p+1;
}
return fixture_name;
}
#ifdef CLAR_FIXTURE_PATH
const char *cl_fixture(const char *fixture_name)
{
......@@ -44,8 +31,20 @@ void cl_fixture_sandbox(const char *fixture_name)
fs_copy(cl_fixture(fixture_name), _clar_path);
}
const char *cl_fixture_basename(const char *fixture_name)
{
const char *p;
for (p = fixture_name; *p; p++) {
if (p[0] == '/' && p[1] && p[1] != '/')
fixture_name = p+1;
}
return fixture_name;
}
void cl_fixture_cleanup(const char *fixture_name)
{
fs_rm(fixture_path(_clar_path, fixture_basename(fixture_name)));
fs_rm(fixture_path(_clar_path, cl_fixture_basename(fixture_name)));
}
#endif
......@@ -171,13 +171,17 @@ static git_repository *_cl_repo = NULL;
git_repository *cl_git_sandbox_init(const char *sandbox)
{
/* Get the name of the sandbox folder which will be created
*/
const char *basename = cl_fixture_basename(sandbox);
/* Copy the whole sandbox folder from our fixtures to our test sandbox
* area. After this it can be accessed with `./sandbox`
*/
cl_fixture_sandbox(sandbox);
_cl_sandbox = sandbox;
cl_git_pass(p_chdir(sandbox));
cl_git_pass(p_chdir(basename));
/* If this is not a bare repo, then rename `sandbox/.gitted` to
* `sandbox/.git` which must be done since we cannot store a folder
......@@ -200,7 +204,7 @@ git_repository *cl_git_sandbox_init(const char *sandbox)
cl_git_pass(p_chdir(".."));
/* Now open the sandbox repository and make it available for tests */
cl_git_pass(git_repository_open(&_cl_repo, sandbox));
cl_git_pass(git_repository_open(&_cl_repo, basename));
/* Adjust configs after copying to new filesystem */
cl_git_pass(git_repository_reinit_filesystem(_cl_repo, 0));
......@@ -222,7 +226,9 @@ git_repository *cl_git_sandbox_reopen(void)
git_repository_free(_cl_repo);
_cl_repo = NULL;
cl_git_pass(git_repository_open(&_cl_repo, _cl_sandbox));
cl_git_pass(git_repository_open(
&_cl_repo,
cl_fixture_basename(_cl_sandbox)));
}
return _cl_repo;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment