Commit 2b9b99b6 by nulltoken

Add test ensuring one can not create an oid reference which targets at an unknown id

parent 4d00dfd4
......@@ -292,6 +292,26 @@ BEGIN_TEST(create2, "create a new OID reference")
git_repository_free(repo);
END_TEST
BEGIN_TEST(create3, "Can not create a new OID reference which targets at an unknown id")
git_reference *new_reference, *looked_up_ref;
git_repository *repo;
git_oid id;
const char *new_head = "refs/heads/new-head";
git_oid_mkstr(&id, "deadbeef3f795b2b4353bcce3a527ad0a4f7f644");
must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
/* Create and write the new object id reference */
must_fail(git_reference_create_oid(&new_reference, repo, new_head, &id));
/* Ensure the reference can't be looked-up... */
must_fail(git_reference_lookup(&looked_up_ref, repo, new_head));
git_repository_free(repo);
END_TEST
static const char *ref_name = "refs/heads/other";
static const char *ref_master_name = "refs/heads/master";
static const char *ref_branch_name = "refs/heads/branch";
......@@ -889,6 +909,7 @@ BEGIN_SUITE(refs)
ADD_TEST(create0);
ADD_TEST(create1);
ADD_TEST(create2);
ADD_TEST(create3);
ADD_TEST(overwrite0);
ADD_TEST(overwrite1);
......
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