Пример #1
0
void test_repo_head__head_detached(void)
{
    git_reference *ref;

    cl_assert_equal_i(false, git_repository_head_detached(repo));

    cl_git_pass(git_repository_detach_head(repo));
    check_last_reflog_entry(g_email, "checkout: moving from master to a65fedf39aefe402d3bb6e24df4d4f5fe4547750");
    cl_assert_equal_i(true, git_repository_head_detached(repo));

    /* take the repo back to it's original state */
    cl_git_pass(git_reference_symbolic_create(&ref, repo, "HEAD", "refs/heads/master",
                true, "REATTACH"));
    git_reference_free(ref);

    check_last_reflog_entry(g_email, "REATTACH");
    cl_assert_equal_i(false, git_repository_head_detached(repo));
}
Пример #2
0
void test_repo_head__head_detached(void)
{
    git_reference *ref;
    git_signature *sig;

    cl_git_pass(git_signature_now(&sig, "Foo Bar", "*****@*****.**"));

    cl_assert_equal_i(false, git_repository_head_detached(repo));

    cl_git_pass(git_repository_detach_head(repo, sig, "CABLE DETACHED"));
    check_last_reflog_entry(sig->email, "CABLE DETACHED");
    cl_assert_equal_i(true, git_repository_head_detached(repo));

    /* take the repo back to it's original state */
    cl_git_pass(git_reference_symbolic_create(&ref, repo, "HEAD", "refs/heads/master",
                true, sig, "REATTACH"));
    git_reference_free(ref);

    check_last_reflog_entry(sig->email, "REATTACH");
    cl_assert_equal_i(false, git_repository_head_detached(repo));
    git_signature_free(sig);
}