diff options
author | Linquize <linquize@yahoo.com.hk> | 2014-03-02 19:14:20 +0800 |
---|---|---|
committer | Linquize <linquize@yahoo.com.hk> | 2014-03-02 19:14:20 +0800 |
commit | 1d08b72e4fbc474719baec127d7911cc116dec48 (patch) | |
tree | 86898a709cc64852ff8b1029f648a83d7a6bcdc0 /tests/refs | |
parent | 59b1dbcd7acf6aa7dd6d81d0386ab15f46ce6ac7 (diff) | |
download | libgit2-1d08b72e4fbc474719baec127d7911cc116dec48.tar.gz |
Add unit test to show git_branch_create() fails if attempt to force create current branch
Diffstat (limited to 'tests/refs')
-rw-r--r-- | tests/refs/branches/create.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/refs/branches/create.c b/tests/refs/branches/create.c index abe5f5940..d4b0763da 100644 --- a/tests/refs/branches/create.c +++ b/tests/refs/branches/create.c @@ -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)); } +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) { retrieve_known_commit(&target, repo); |