mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-05 17:12:51 +00:00

The refdb_fs_backend is not aware of the git commondir, which stores common objects like the o bject database and packed/loose refereensces when worktrees are used. Make refdb_fs_backend aware of the common directory by introducing a new commonpath variable that points to the actual common path of the database and using it instead of the gitdir for the mentioned objects.
69 lines
1.1 KiB
C
69 lines
1.1 KiB
C
#include "clar_libgit2.h"
|
|
#include "worktree_helpers.h"
|
|
|
|
#define COMMON_REPO "testrepo"
|
|
#define WORKTREE_REPO "testrepo-worktree"
|
|
|
|
static worktree_fixture fixture =
|
|
WORKTREE_FIXTURE_INIT(COMMON_REPO, WORKTREE_REPO);
|
|
|
|
void test_worktree_refs__initialize(void)
|
|
{
|
|
setup_fixture_worktree(&fixture);
|
|
}
|
|
|
|
void test_worktree_refs__cleanup(void)
|
|
{
|
|
cleanup_fixture_worktree(&fixture);
|
|
}
|
|
|
|
void test_worktree_refs__list(void)
|
|
{
|
|
git_strarray refs, wtrefs;
|
|
unsigned i, j;
|
|
int error = 0;
|
|
|
|
cl_git_pass(git_reference_list(&refs, fixture.repo));
|
|
cl_git_pass(git_reference_list(&wtrefs, fixture.worktree));
|
|
|
|
if (refs.count != wtrefs.count)
|
|
{
|
|
error = GIT_ERROR;
|
|
goto exit;
|
|
}
|
|
|
|
for (i = 0; i < refs.count; i++)
|
|
{
|
|
int found = 0;
|
|
|
|
for (j = 0; j < wtrefs.count; j++)
|
|
{
|
|
if (!strcmp(refs.strings[i], wtrefs.strings[j]))
|
|
{
|
|
found = 1;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!found)
|
|
{
|
|
error = GIT_ERROR;
|
|
goto exit;
|
|
}
|
|
}
|
|
|
|
exit:
|
|
git_strarray_free(&refs);
|
|
git_strarray_free(&wtrefs);
|
|
cl_git_pass(error);
|
|
}
|
|
|
|
void test_worktree_refs__read_head(void)
|
|
{
|
|
git_reference *head;
|
|
|
|
cl_git_pass(git_repository_head(&head, fixture.worktree));
|
|
|
|
git_reference_free(head);
|
|
}
|