repo_helpers.c 538 Bytes
Newer Older
1 2 3
#include "clar_libgit2.h"
#include "refs.h"
#include "repo_helpers.h"
4
#include "posix.h"
5 6 7 8 9

void make_head_orphaned(git_repository* repo, const char *target)
{
	git_reference *head;

10
	cl_git_pass(git_reference_symbolic_create(&head, repo, GIT_HEAD_FILE, target, 1));
11 12
	git_reference_free(head);
}
13 14 15 16 17 18 19 20 21 22

void delete_head(git_repository* repo)
{
	git_buf head_path = GIT_BUF_INIT;

	cl_git_pass(git_buf_joinpath(&head_path, git_repository_path(repo), GIT_HEAD_FILE));
	cl_git_pass(p_unlink(git_buf_cstr(&head_path)));

	git_buf_free(&head_path);
}