mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-29 20:42:23 +00:00
Fix initial commit test
`test_commit_commit__create_initial_commit_parent_not_current` was not correctly testing that `HEAD` was not changed. Now we grab the oid that it was pointing to before the call to `git_commit_create` and the oid that it's pointing to afterwards and compare those.
This commit is contained in:
parent
4f22ccb979
commit
5785ae9b5e
@ -84,13 +84,10 @@ void test_commit_commit__create_initial_commit(void)
|
|||||||
void test_commit_commit__create_initial_commit_parent_not_current(void)
|
void test_commit_commit__create_initial_commit_parent_not_current(void)
|
||||||
{
|
{
|
||||||
git_oid oid;
|
git_oid oid;
|
||||||
|
git_oid original_oid;
|
||||||
git_tree *tree;
|
git_tree *tree;
|
||||||
git_commit *commit;
|
git_commit *commit;
|
||||||
git_signature *s;
|
git_signature *s;
|
||||||
git_reference *origRef;
|
|
||||||
git_reference *origRefTarget;
|
|
||||||
git_reference *ref;
|
|
||||||
git_reference *refTarget;
|
|
||||||
|
|
||||||
git_oid_fromstr(&oid, "a65fedf39aefe402d3bb6e24df4d4f5fe4547750");
|
git_oid_fromstr(&oid, "a65fedf39aefe402d3bb6e24df4d4f5fe4547750");
|
||||||
cl_git_pass(git_commit_lookup(&commit, _repo, &oid));
|
cl_git_pass(git_commit_lookup(&commit, _repo, &oid));
|
||||||
@ -100,40 +97,18 @@ void test_commit_commit__create_initial_commit_parent_not_current(void)
|
|||||||
|
|
||||||
cl_git_pass(git_signature_now(&s, "alice", "alice@example.com"));
|
cl_git_pass(git_signature_now(&s, "alice", "alice@example.com"));
|
||||||
|
|
||||||
cl_git_pass(git_reference_lookup(&origRef, _repo, "HEAD"));
|
cl_git_pass(git_reference_name_to_id(&original_oid, _repo, "HEAD"));
|
||||||
|
|
||||||
cl_git_fail(git_commit_create(&oid, _repo, "HEAD", s, s,
|
cl_git_fail(git_commit_create(&oid, _repo, "HEAD", s, s,
|
||||||
NULL, "initial commit", tree, 0, NULL));
|
NULL, "initial commit", tree, 0, NULL));
|
||||||
|
|
||||||
cl_git_pass(git_reference_lookup(&ref, _repo, "HEAD"));
|
cl_git_pass(git_reference_name_to_id(&oid, _repo, "HEAD"));
|
||||||
|
|
||||||
cl_git_pass(
|
cl_assert_equal_oid(&oid, &original_oid);
|
||||||
git_reference_lookup(
|
|
||||||
&origRefTarget,
|
|
||||||
_repo,
|
|
||||||
git_reference_symbolic_target(origRef)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
cl_git_pass(
|
|
||||||
git_reference_lookup(
|
|
||||||
&refTarget,
|
|
||||||
_repo,
|
|
||||||
git_reference_symbolic_target(ref)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
cl_assert_equal_oid(
|
|
||||||
git_reference_target(origRefTarget),
|
|
||||||
git_reference_target(refTarget)
|
|
||||||
);
|
|
||||||
|
|
||||||
git_tree_free(tree);
|
git_tree_free(tree);
|
||||||
git_commit_free(commit);
|
git_commit_free(commit);
|
||||||
git_signature_free(s);
|
git_signature_free(s);
|
||||||
git_reference_free(origRef);
|
|
||||||
git_reference_free(origRefTarget);
|
|
||||||
git_reference_free(ref);
|
|
||||||
git_reference_free(refTarget);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void assert_commit_summary(const char *expected, const char *given)
|
void assert_commit_summary(const char *expected, const char *given)
|
||||||
|
Loading…
Reference in New Issue
Block a user