Blame tests/submodule/repository_init.c

Packit Service 20376f
#include "clar_libgit2.h"
Packit Service 20376f
#include "posix.h"
Packit Service 20376f
#include "path.h"
Packit Service 20376f
#include "submodule_helpers.h"
Packit Service 20376f
#include "config/config_helpers.h"
Packit Service 20376f
#include "fileops.h"
Packit Service 20376f
Packit Service 20376f
static git_repository *g_repo = NULL;
Packit Service 20376f
Packit Service 20376f
void test_submodule_repository_init__basic(void)
Packit Service 20376f
{
Packit Service 20376f
	git_submodule *sm;
Packit Service 20376f
	git_repository *repo;
Packit Service 20376f
	git_buf dot_git_content = GIT_BUF_INIT;
Packit Service 20376f
Packit Service 20376f
	g_repo = setup_fixture_submod2();
Packit Service 20376f
Packit Service 20376f
	cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_gitmodules_only"));
Packit Service 20376f
	cl_git_pass(git_submodule_init(sm, 0));
Packit Service 20376f
	cl_git_pass(git_submodule_repo_init(&repo, sm, 1));
Packit Service 20376f
Packit Service 20376f
	/* Verify worktree */
Packit Service 20376f
	assert_config_entry_value(repo, "core.worktree", "../../../sm_gitmodules_only/");
Packit Service 20376f
Packit Service 20376f
	/* Verify gitlink */
Packit Service 20376f
	cl_git_pass(git_futils_readbuffer(&dot_git_content, "submod2/" "sm_gitmodules_only" "/.git"));
Packit Service 20376f
	cl_assert_equal_s("gitdir: ../.git/modules/sm_gitmodules_only/", dot_git_content.ptr);
Packit Service 20376f
Packit Service 20376f
	cl_assert(git_path_isfile("submod2/" "sm_gitmodules_only" "/.git"));
Packit Service 20376f
Packit Service 20376f
	cl_assert(git_path_isdir("submod2/.git/modules"));
Packit Service 20376f
	cl_assert(git_path_isdir("submod2/.git/modules/" "sm_gitmodules_only"));
Packit Service 20376f
	cl_assert(git_path_isfile("submod2/.git/modules/" "sm_gitmodules_only" "/HEAD"));
Packit Service 20376f
Packit Service 20376f
	git_submodule_free(sm);
Packit Service 20376f
	git_repository_free(repo);
Packit Service 20376f
	git_buf_free(&dot_git_content);
Packit Service 20376f
}