void test_network_remote_defaultbranch__detached_sharing_nonbranch_id(void) { git_oid id, id_cloned; git_reference *ref; git_buf buf = GIT_BUF_INIT; git_repository *cloned_repo; cl_git_pass(git_reference_name_to_id(&id, g_repo_a, "HEAD")); cl_git_pass(git_repository_detach_head(g_repo_a, NULL, NULL)); cl_git_pass(git_reference_remove(g_repo_a, "refs/heads/master")); cl_git_pass(git_reference_remove(g_repo_a, "refs/heads/not-good")); cl_git_pass(git_reference_create(&ref, g_repo_a, "refs/foo/bar", &id, 1, NULL, NULL)); git_reference_free(ref); cl_git_pass(git_remote_connect(g_remote, GIT_DIRECTION_FETCH)); cl_git_fail_with(GIT_ENOTFOUND, git_remote_default_branch(&buf, g_remote)); cl_git_pass(git_clone(&cloned_repo, git_repository_path(g_repo_a), "./local-detached", NULL)); cl_assert(git_repository_head_detached(cloned_repo)); cl_git_pass(git_reference_name_to_id(&id_cloned, g_repo_a, "HEAD")); cl_assert(git_oid_equal(&id, &id_cloned)); git_repository_free(cloned_repo); }
int luagi_reference_remove( lua_State *L ) { git_repository **repo = checkrepo( L, 1 ); const char *name = luaL_checkstring( L, 2 ); if( git_reference_remove( *repo, name ) ) { ltk_error_abort( L ); } return 0; }
void test_refs_delete__remove(void) { git_reference *ref; /* Check that passing no old values lets us delete */ cl_git_pass(git_reference_lookup(&ref, g_repo, packed_test_head_name)); git_reference_free(ref); cl_git_pass(git_reference_remove(g_repo, packed_test_head_name)); cl_git_fail(git_reference_lookup(&ref, g_repo, packed_test_head_name)); }
void test_refs_branches_create__default_reflog_message(void) { git_reflog *log; git_buf buf = GIT_BUF_INIT; const git_reflog_entry *entry; git_annotated_commit *annotated; git_signature *sig; git_config *cfg; cl_git_pass(git_repository_config(&cfg, repo)); cl_git_pass(git_config_set_string(cfg, "user.name", "Foo Bar")); cl_git_pass(git_config_set_string(cfg, "user.email", "*****@*****.**")); git_config_free(cfg); cl_git_pass(git_signature_default(&sig, repo)); retrieve_known_commit(&target, repo); cl_git_pass(git_branch_create(&branch, repo, NEW_BRANCH_NAME, target, false)); cl_git_pass(git_reflog_read(&log, repo, "refs/heads/" NEW_BRANCH_NAME)); entry = git_reflog_entry_byindex(log, 0); cl_git_pass(git_buf_printf(&buf, "branch: Created from %s", git_oid_tostr_s(git_commit_id(target)))); cl_assert_equal_s(git_buf_cstr(&buf), git_reflog_entry_message(entry)); cl_assert_equal_s(sig->email, git_reflog_entry_committer(entry)->email); cl_git_pass(git_reference_remove(repo, "refs/heads/" NEW_BRANCH_NAME)); git_reference_free(branch); git_reflog_free(log); git_buf_clear(&buf); cl_git_pass(git_annotated_commit_from_revspec(&annotated, repo, "e90810b8df3")); cl_git_pass(git_branch_create_from_annotated(&branch, repo, NEW_BRANCH_NAME, annotated, true)); cl_git_pass(git_reflog_read(&log, repo, "refs/heads/" NEW_BRANCH_NAME)); entry = git_reflog_entry_byindex(log, 0); cl_git_pass(git_buf_printf(&buf, "branch: Created from e90810b8df3")); cl_assert_equal_s(git_buf_cstr(&buf), git_reflog_entry_message(entry)); cl_assert_equal_s(sig->email, git_reflog_entry_committer(entry)->email); git_annotated_commit_free(annotated); git_buf_free(&buf); git_reflog_free(log); git_signature_free(sig); }
void test_refs_reflog_messages__creating_branches_default_messages(void) { git_buf buf = GIT_BUF_INIT; git_annotated_commit *annotated; git_object *obj; git_commit *target; git_reference *branch1, *branch2; cl_git_pass(git_revparse_single(&obj, g_repo, "e90810b8df3")); cl_git_pass(git_commit_lookup(&target, g_repo, git_object_id(obj))); git_object_free(obj); cl_git_pass(git_branch_create(&branch1, g_repo, NEW_BRANCH_NAME, target, false)); cl_git_pass(git_buf_printf(&buf, "branch: Created from %s", git_oid_tostr_s(git_commit_id(target)))); cl_reflog_check_entry(g_repo, "refs/heads/" NEW_BRANCH_NAME, 0, GIT_OID_HEX_ZERO, git_oid_tostr_s(git_commit_id(target)), g_email, git_buf_cstr(&buf)); cl_git_pass(git_reference_remove(g_repo, "refs/heads/" NEW_BRANCH_NAME)); cl_git_pass(git_annotated_commit_from_revspec(&annotated, g_repo, "e90810b8df3")); cl_git_pass(git_branch_create_from_annotated(&branch2, g_repo, NEW_BRANCH_NAME, annotated, true)); cl_reflog_check_entry(g_repo, "refs/heads/" NEW_BRANCH_NAME, 0, GIT_OID_HEX_ZERO, git_oid_tostr_s(git_commit_id(target)), g_email, "branch: Created from e90810b8df3"); git_annotated_commit_free(annotated); git_buf_free(&buf); git_commit_free(target); git_reference_free(branch1); git_reference_free(branch2); }