mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-29 10:03:43 +00:00
Add unit test to show git_branch_create() fails if attempt to force create current branch
This commit is contained in:
parent
59b1dbcd7a
commit
1d08b72e4f
@ -66,6 +66,25 @@ void test_refs_branches_create__can_force_create_over_an_existing_branch(void)
|
|||||||
cl_assert_equal_s("refs/heads/br2", git_reference_name(branch));
|
cl_assert_equal_s("refs/heads/br2", git_reference_name(branch));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test_refs_branches_create__cannot_force_create_over_current_branch(void)
|
||||||
|
{
|
||||||
|
const git_oid *oid;
|
||||||
|
git_reference *branch2;
|
||||||
|
retrieve_known_commit(&target, repo);
|
||||||
|
|
||||||
|
cl_git_pass(git_branch_lookup(&branch2, repo, "master", GIT_BRANCH_LOCAL));
|
||||||
|
cl_assert_equal_s("refs/heads/master", git_reference_name(branch2));
|
||||||
|
cl_assert_equal_i(true, git_branch_is_head(branch2));
|
||||||
|
oid = git_reference_target(branch2);
|
||||||
|
|
||||||
|
cl_git_fail_with(-1, git_branch_create(&branch, repo, "master", target, 1, NULL, NULL));
|
||||||
|
branch = NULL;
|
||||||
|
cl_git_pass(git_branch_lookup(&branch, repo, "master", GIT_BRANCH_LOCAL));
|
||||||
|
cl_assert_equal_s("refs/heads/master", git_reference_name(branch));
|
||||||
|
cl_git_pass(git_oid_cmp(git_reference_target(branch), oid));
|
||||||
|
git_reference_free(branch2);
|
||||||
|
}
|
||||||
|
|
||||||
void test_refs_branches_create__creating_a_branch_with_an_invalid_name_returns_EINVALIDSPEC(void)
|
void test_refs_branches_create__creating_a_branch_with_an_invalid_name_returns_EINVALIDSPEC(void)
|
||||||
{
|
{
|
||||||
retrieve_known_commit(&target, repo);
|
retrieve_known_commit(&target, repo);
|
||||||
|
Loading…
Reference in New Issue
Block a user