From eea6826d5e1981db917ef14685d64cb8d29f0164 Mon Sep 17 00:00:00 2001 From: Twarit Waikar Date: Thu, 7 Oct 2021 01:19:32 +0530 Subject: [PATCH] Add missing error check on git upstream check during push --- godot-git-plugin/src/git_api.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/godot-git-plugin/src/git_api.cpp b/godot-git-plugin/src/git_api.cpp index d4634da..5b722e3 100644 --- a/godot-git-plugin/src/git_api.cpp +++ b/godot-git-plugin/src/git_api.cpp @@ -623,6 +623,8 @@ void GitAPI::_push(String remote, String username, String password) { git_buf ref_name = {}; int error = git_branch_upstream_name(&ref_name, repo.get(), CString(branch_name).data); + + // Set the upstream for the user's convenience if (error == GIT_ENOTFOUND) { String push_ref_spec(branch_name + ":" + branch_name); @@ -635,10 +637,13 @@ void GitAPI::_push(String remote, String username, String password) { GIT2_CALL("Could not set branch upstream for " + branch_name, git_branch_set_upstream, branch_object.get(), CString(remote + "/" + branch_name_short).data); } - - ref_name = {}; - GIT2_CALL("Could not get upstream branch", - git_branch_upstream_name, &ref_name, repo.get(), CString(branch_name).data); + else + { + if (check_errors(error, "Could not get branch upstream", __FUNCTION__, __FILE__, __LINE__)) + { + return; + } + } CString pushspec(String() + branch_name);