Hash :
b6ed67c2
Author :
Date :
2017-05-10T12:54:14
tests: refs::crashes: create sandbox for creating symref The test `refs::crashes::double_free` operates on our in-source "testrepo.git" repository without creating a copy first. As the test will try to create a new symbolic reference, this will fail when we want to do a pure out-of-tree build with a read-only source tree. Fix the issue by creating a sandbox first.
#include "clar_libgit2.h"
void test_refs_crashes__double_free(void)
{
git_repository *repo;
git_reference *ref, *ref2;
const char *REFNAME = "refs/heads/xxx";
repo = cl_git_sandbox_init("testrepo.git");
cl_git_pass(git_reference_symbolic_create(&ref, repo, REFNAME, "refs/heads/master", 0, NULL));
cl_git_pass(git_reference_lookup(&ref2, repo, REFNAME));
cl_git_pass(git_reference_delete(ref));
git_reference_free(ref);
git_reference_free(ref2);
/* reference is gone from disk, so reloading it will fail */
cl_git_fail(git_reference_lookup(&ref2, repo, REFNAME));
cl_git_sandbox_cleanup();
}