Push worked!

This commit is contained in:
Twarit Waikar
2021-10-04 01:27:20 +05:30
parent 4a37c872ac
commit df3b519cfc
2 changed files with 2 additions and 47 deletions

View File

@@ -456,29 +456,6 @@ void GitAPI::_pull(String remote, String username, String password) {
String branch_name = _get_current_branch_name(false);
CString ref_name("refs/heads/" + branch_name + ":refs/remotes/" + remote + "/" + branch_name);
// git_buf* upstream_buf;
// Godot::print_warning(branch_name, __FUNCTION__, __FILE__, __LINE__);
// if (git_branch_upstream_name(upstream_buf, repo, CString(branch_name).data) == GIT_ENOTFOUND)
// {
// Godot::print_warning("GitAPI: The current branch " + branch_name + " has no upstream branch. Setting the upstream to " + branch_name, __FUNCTION__, __FILE__, __LINE__);
// git_reference *head;
// git_reference *branch;
// GIT2_CALL(git_repository_head(&head, repo), "Could not find repository HEAD");
// GIT2_CALL(git_reference_resolve(&branch, head), "Could not resolve HEAD reference to " + branch_name + " branch");
// GIT2_CALL(git_branch_set_upstream(branch, CString(branch_name).data), "Could not set " + branch_name + " upstream");
// GIT2_CALL(git_branch_upstream_name(&upstream_buf, repo, CString(branch_name).data), "Could not get upstream for " + branch_name + " branch");
// Godot::print_warning("yo", __FUNCTION__, __FILE__, __LINE__);
// git_reference_free(head);
// git_reference_free(branch);
// }
// else {
// // Redo the operation in case we missed an actual error
// GIT2_CALL(git_branch_upstream_name(&upstream_buf, repo, CString(branch_name).data), "Could not get current branch upstream name");
// }
char *ref[] = { ref_name.data };
git_strarray refspec = { ref, 1 };
@@ -581,31 +558,9 @@ void GitAPI::_push(String remote, String username, String password) {
git_push_options push_opts = GIT_PUSH_OPTIONS_INIT;
push_opts.callbacks = remote_cbs;
String branch_name = _get_current_branch_name(false);
CString full_branch_name(_get_current_branch_name(true));
git_buf upstream_buf;
if (git_branch_upstream_name(&upstream_buf, repo, CString(branch_name).data) == GIT_ENOTFOUND)
{
Godot::print_warning("GitAPI: The current branch " + branch_name + " has no upstream branch. Setting the upstream to " + branch_name, __FUNCTION__, __FILE__, __LINE__);
git_reference *head;
git_reference *branch;
GIT2_CALL(git_repository_head(&head, repo), "Could not find repository HEAD");
GIT2_CALL(git_reference_resolve(&branch, head), "Could not resolve HEAD reference to " + branch_name + " branch");
GIT2_CALL(git_branch_set_upstream(branch, CString(branch_name).data), "Could not set " + branch_name + " upstream");
GIT2_CALL(git_branch_upstream_name(&upstream_buf, repo, CString(branch_name).data), "Could not get upstream for " + branch_name + " branch");
git_reference_free(head);
git_reference_free(branch);
}
else {
// Redo the operation in case we missed an actual error
GIT2_CALL(git_branch_upstream_name(&upstream_buf, repo, CString(branch_name).data), "Could not get current branch upstream name.");
}
char *ref[] = { upstream_buf.ptr };
char *ref[] = { full_branch_name.data };
git_strarray refspecs = { ref, 1 };
GIT2_CALL(git_remote_upload(remote_object, &refspecs, &push_opts), "Failed to push");