diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/commit/commit.c | 4 | ||||
-rw-r--r-- | tests/object/commit/commitstagedfile.c | 9 |
2 files changed, 13 insertions, 0 deletions
diff --git a/tests/commit/commit.c b/tests/commit/commit.c index 38397d2df..fa181b703 100644 --- a/tests/commit/commit.c +++ b/tests/commit/commit.c @@ -38,6 +38,10 @@ void test_commit_commit__create_unexisting_update_ref(void) cl_git_pass(git_commit_create(&oid, _repo, "refs/heads/foo/bar", s, s, NULL, "some msg", tree, 1, (const git_commit **) &commit)); + /* fail because the parent isn't the tip of the branch anymore */ + cl_git_fail(git_commit_create(&oid, _repo, "refs/heads/foo/bar", s, s, + NULL, "some msg", tree, 1, (const git_commit **) &commit)); + cl_git_pass(git_reference_lookup(&ref, _repo, "refs/heads/foo/bar")); cl_assert(!git_oid_cmp(&oid, git_reference_target(ref))); diff --git a/tests/object/commit/commitstagedfile.c b/tests/object/commit/commitstagedfile.c index 3e7b3c02c..9758ea9a2 100644 --- a/tests/object/commit/commitstagedfile.c +++ b/tests/object/commit/commitstagedfile.c @@ -175,6 +175,10 @@ void test_object_commit_commitstagedfile__amend_commit(void) cl_git_pass(git_commit_amend( &new_oid, old_commit, "HEAD", NULL, NULL, NULL, "Initial commit", NULL)); + /* fail because the commit isn't the tip of the branch anymore */ + cl_git_fail(git_commit_amend( + &new_oid, old_commit, "HEAD", NULL, NULL, NULL, "Initial commit", NULL)); + cl_git_pass(git_commit_lookup(&new_commit, repo, &new_oid)); cl_assert_equal_i(0, git_commit_parentcount(new_commit)); @@ -182,6 +186,7 @@ void test_object_commit_commitstagedfile__amend_commit(void) assert_commit_is_head(new_commit); git_commit_free(old_commit); + old_commit = new_commit; /* let's amend the tree of that last commit */ @@ -192,6 +197,10 @@ void test_object_commit_commitstagedfile__amend_commit(void) cl_git_pass(git_tree_lookup(&tree, repo, &tree_oid)); cl_assert_equal_i(2, git_tree_entrycount(tree)); + /* fail to amend on a ref which does not exist */ + cl_git_fail_with(GIT_ENOTFOUND, git_commit_amend( + &new_oid, old_commit, "refs/heads/nope", NULL, NULL, NULL, "Initial commit", tree)); + cl_git_pass(git_commit_amend( &new_oid, old_commit, "HEAD", NULL, NULL, NULL, "Initial commit", tree)); git_tree_free(tree); |