Commit 0532e7bb by nulltoken

branch: allow deletion of branch when HEAD's missing

parent 8dd0bef9
......@@ -265,13 +265,19 @@ int git_branch_is_head(
{
git_reference *head;
bool is_same = false;
int error;
assert(branch);
if (!git_reference_is_branch(branch))
return false;
if (git_repository_head(&head, git_reference_owner(branch)) < 0)
error = git_repository_head(&head, git_reference_owner(branch));
if (error == GIT_ENOTFOUND)
return false;
if (error < 0)
return -1;
is_same = strcmp(
......
......@@ -38,17 +38,16 @@ void test_refs_branches_delete__can_not_delete_a_branch_pointed_at_by_HEAD(void)
git_reference_free(branch);
}
void test_refs_branches_delete__can_not_delete_a_branch_if_HEAD_is_missing(void)
void test_refs_branches_delete__can_delete_a_branch_even_if_HEAD_is_missing(void)
{
git_reference *head;
git_reference *branch = NULL;
git_reference *branch;
cl_git_pass(git_reference_lookup(&head, repo, GIT_HEAD_FILE));
git_reference_delete(head);
cl_git_pass(git_branch_lookup(&branch, repo, "br2", GIT_BRANCH_LOCAL));
cl_git_fail(git_branch_delete(branch));
git_reference_free(branch);
cl_git_pass(git_branch_delete(branch));
}
void test_refs_branches_delete__can_delete_a_branch_pointed_at_by_detached_HEAD(void)
......
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