]> git.proxmox.com Git - libgit2.git/blobdiff - tests/refs/races.c
New upstream version 1.4.3+dfsg.1
[libgit2.git] / tests / refs / races.c
index 02d57eff18071ac62082ad09828452ef78d4bf12..476789358d698d9c1075143eb4c7e808cb1c6ad7 100644 (file)
@@ -22,6 +22,24 @@ void test_refs_races__cleanup(void)
    cl_git_sandbox_cleanup();
 }
 
+void test_refs_races__create_matching_zero_old(void)
+{
+       git_reference *ref;
+       git_oid id, zero_id;
+
+       git_oid_fromstr(&id, commit_id);
+       git_oid_fromstr(&zero_id, "0000000000000000000000000000000000000000");
+
+       cl_git_fail(git_reference_create_matching(&ref, g_repo, refname, &id, 1, &zero_id, NULL));
+       git_reference_free(ref);
+
+       cl_git_pass(git_reference_create_matching(&ref, g_repo, other_refname, &id, 1, &zero_id, NULL));
+       git_reference_free(ref);
+
+       cl_git_fail(git_reference_create_matching(&ref, g_repo, other_refname, &id, 1, &zero_id, NULL));
+       git_reference_free(ref);
+}
+
 void test_refs_races__create_matching(void)
 {
        git_reference *ref, *ref2, *ref3;
@@ -30,11 +48,11 @@ void test_refs_races__create_matching(void)
        git_oid_fromstr(&id, commit_id);
        git_oid_fromstr(&other_id, other_commit_id);
 
-       cl_git_fail_with(GIT_EMODIFIED, git_reference_create_matching(&ref, g_repo, refname, &other_id, 1, NULL, NULL, &other_id));
+       cl_git_fail_with(GIT_EMODIFIED, git_reference_create_matching(&ref, g_repo, refname, &other_id, 1, &other_id, NULL));
 
        cl_git_pass(git_reference_lookup(&ref, g_repo, refname));
-       cl_git_pass(git_reference_create_matching(&ref2, g_repo, refname, &other_id, 1, NULL, NULL, &id));
-       cl_git_fail_with(GIT_EMODIFIED, git_reference_set_target(&ref3, ref, &other_id, NULL, NULL));
+       cl_git_pass(git_reference_create_matching(&ref2, g_repo, refname, &other_id, 1, &id, NULL));
+       cl_git_fail_with(GIT_EMODIFIED, git_reference_set_target(&ref3, ref, &other_id, NULL));
 
        git_reference_free(ref);
        git_reference_free(ref2);
@@ -49,11 +67,11 @@ void test_refs_races__symbolic_create_matching(void)
        git_oid_fromstr(&id, commit_id);
        git_oid_fromstr(&other_id, other_commit_id);
 
-       cl_git_fail_with(GIT_EMODIFIED, git_reference_symbolic_create_matching(&ref, g_repo, "HEAD", other_refname, 1, NULL, NULL, other_refname));
+       cl_git_fail_with(GIT_EMODIFIED, git_reference_symbolic_create_matching(&ref, g_repo, "HEAD", other_refname, 1, other_refname, NULL));
 
        cl_git_pass(git_reference_lookup(&ref, g_repo, "HEAD"));
-       cl_git_pass(git_reference_symbolic_create_matching(&ref2, g_repo, "HEAD", other_refname, 1, NULL, NULL, refname));
-       cl_git_fail_with(GIT_EMODIFIED, git_reference_symbolic_set_target(&ref3, ref, other_refname, NULL, NULL));
+       cl_git_pass(git_reference_symbolic_create_matching(&ref2, g_repo, "HEAD", other_refname, 1, NULL, refname));
+       cl_git_fail_with(GIT_EMODIFIED, git_reference_symbolic_set_target(&ref3, ref, other_refname, NULL));
 
        git_reference_free(ref);
        git_reference_free(ref2);
@@ -74,19 +92,19 @@ void test_refs_races__delete(void)
        git_reference_free(ref);
 
        /* We cannot delete a symbolic value that doesn't match */
-       cl_git_pass(git_reference_lookup(&ref, g_repo, "HEAD"));
-       cl_git_pass(git_reference_symbolic_create_matching(&ref2, g_repo, "HEAD", other_refname, 1, NULL, NULL, refname));
+       cl_git_pass(git_reference_lookup(&ref, g_repo, "refs/symref"));
+       cl_git_pass(git_reference_symbolic_create_matching(&ref2, g_repo, "refs/symref", other_refname, 1, NULL, refname));
        cl_git_fail_with(GIT_EMODIFIED, git_reference_delete(ref));
 
        git_reference_free(ref);
        git_reference_free(ref2);
 
-       cl_git_pass(git_reference_create(&ref, g_repo, refname, &id, 1, NULL, NULL));
+       cl_git_pass(git_reference_create(&ref, g_repo, refname, &id, 1, NULL));
        git_reference_free(ref);
 
        /* We cannot delete an oid value that doesn't match */
        cl_git_pass(git_reference_lookup(&ref, g_repo, refname));
-       cl_git_pass(git_reference_create_matching(&ref2, g_repo, refname, &other_id, 1, NULL, NULL, &id));
+       cl_git_pass(git_reference_create_matching(&ref2, g_repo, refname, &other_id, 1, &id, NULL));
        cl_git_fail_with(GIT_EMODIFIED, git_reference_delete(ref));
 
        git_reference_free(ref);
@@ -103,19 +121,19 @@ void test_refs_races__switch_oid_to_symbolic(void)
 
        /* Removing a direct ref when it's currently symbolic should fail */
        cl_git_pass(git_reference_lookup(&ref, g_repo, refname));
-       cl_git_pass(git_reference_symbolic_create(&ref2, g_repo, refname, other_refname, 1, NULL, NULL));
+       cl_git_pass(git_reference_symbolic_create(&ref2, g_repo, refname, other_refname, 1, NULL));
        cl_git_fail_with(GIT_EMODIFIED, git_reference_delete(ref));
 
        git_reference_free(ref);
        git_reference_free(ref2);
 
-       cl_git_pass(git_reference_create(&ref, g_repo, refname, &id, 1, NULL, NULL));
+       cl_git_pass(git_reference_create(&ref, g_repo, refname, &id, 1, NULL));
        git_reference_free(ref);
 
        /* Updating a direct ref when it's currently symbolic should fail */
        cl_git_pass(git_reference_lookup(&ref, g_repo, refname));
-       cl_git_pass(git_reference_symbolic_create(&ref2, g_repo, refname, other_refname, 1, NULL, NULL));
-       cl_git_fail_with(GIT_EMODIFIED, git_reference_set_target(&ref3, ref, &other_id, NULL, NULL));
+       cl_git_pass(git_reference_symbolic_create(&ref2, g_repo, refname, other_refname, 1, NULL));
+       cl_git_fail_with(GIT_EMODIFIED, git_reference_set_target(&ref3, ref, &other_id, NULL));
 
        git_reference_free(ref);
        git_reference_free(ref2);
@@ -131,20 +149,20 @@ void test_refs_races__switch_symbolic_to_oid(void)
        git_oid_fromstr(&other_id, other_commit_id);
 
        /* Removing a symbolic ref when it's currently direct should fail */
-       cl_git_pass(git_reference_lookup(&ref, g_repo, "HEAD"));
-       cl_git_pass(git_reference_create(&ref2, g_repo, "HEAD", &id, 1, NULL, NULL));
+       cl_git_pass(git_reference_lookup(&ref, g_repo, "refs/symref"));
+       cl_git_pass(git_reference_create(&ref2, g_repo, "refs/symref", &id, 1, NULL));
        cl_git_fail_with(GIT_EMODIFIED, git_reference_delete(ref));
 
        git_reference_free(ref);
        git_reference_free(ref2);
 
-       cl_git_pass(git_reference_symbolic_create(&ref, g_repo, "HEAD", refname, 1, NULL, NULL));
+       cl_git_pass(git_reference_symbolic_create(&ref, g_repo, "refs/symref", refname, 1, NULL));
        git_reference_free(ref);
 
        /* Updating a symbolic ref when it's currently direct should fail */
-       cl_git_pass(git_reference_lookup(&ref, g_repo, "HEAD"));
-       cl_git_pass(git_reference_create(&ref2, g_repo, "HEAD", &id, 1, NULL, NULL));
-       cl_git_fail_with(GIT_EMODIFIED, git_reference_symbolic_set_target(&ref3, ref, other_refname, NULL, NULL));
+       cl_git_pass(git_reference_lookup(&ref, g_repo, "refs/symref"));
+       cl_git_pass(git_reference_create(&ref2, g_repo, "refs/symref", &id, 1, NULL));
+       cl_git_fail_with(GIT_EMODIFIED, git_reference_symbolic_set_target(&ref3, ref, other_refname, NULL));
 
        git_reference_free(ref);
        git_reference_free(ref2);