From 7af404af43b4ccd1600266c7a3d3005e6afe753a Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Wed, 30 Jul 2025 19:01:01 -0700 Subject: [PATCH] Fix improper boolean check This was assigning a boolean 1 or 0 to the error instead of the git error code --- common/git/project_git_utils.cpp | 29 ++++++++++++++++++++++++++--- common/git/project_git_utils.h | 23 +++++++++++++++++++++++ 2 files changed, 49 insertions(+), 3 deletions(-) diff --git a/common/git/project_git_utils.cpp b/common/git/project_git_utils.cpp index 40a83fd61a..b835dced92 100644 --- a/common/git/project_git_utils.cpp +++ b/common/git/project_git_utils.cpp @@ -1,3 +1,26 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright The KiCad Developers, see AUTHORS.TXT for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/gpl-3.0.html + * or you may search the http://www.gnu.org website for the version 3 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + #include "project_git_utils.h" #include "kicad_git_common.h" #include "kicad_git_memory.h" @@ -35,7 +58,7 @@ int PROJECT_GIT_UTILS::CreateBranch( git_repository* aRepo, const wxString& aBra { git_oid head_oid; - if( int error = git_reference_name_to_id( &head_oid, aRepo, "HEAD" ) != GIT_OK ) + if( int error = git_reference_name_to_id( &head_oid, aRepo, "HEAD" ); error != GIT_OK ) { wxLogTrace( traceGit, "Failed to lookup HEAD reference: %s", KIGIT_COMMON::GetLastGitError() ); @@ -44,7 +67,7 @@ int PROJECT_GIT_UTILS::CreateBranch( git_repository* aRepo, const wxString& aBra git_commit* commit = nullptr; - if( int error = git_commit_lookup( &commit, aRepo, &head_oid ) != GIT_OK ) + if( int error = git_commit_lookup( &commit, aRepo, &head_oid ); error != GIT_OK ) { wxLogTrace( traceGit, "Failed to lookup commit: %s", KIGIT_COMMON::GetLastGitError() ); @@ -54,7 +77,7 @@ int PROJECT_GIT_UTILS::CreateBranch( git_repository* aRepo, const wxString& aBra KIGIT::GitCommitPtr commitPtr( commit ); git_reference* branchRef = nullptr; - if( int error = git_branch_create( &branchRef, aRepo, aBranchName.mb_str(), commit, 0 ) != GIT_OK ) + if( int error = git_branch_create( &branchRef, aRepo, aBranchName.mb_str(), commit, 0 ); error != GIT_OK ) { wxLogTrace( traceGit, "Failed to create branch: %s", KIGIT_COMMON::GetLastGitError() ); diff --git a/common/git/project_git_utils.h b/common/git/project_git_utils.h index ac9fdbdc2c..bdf81816c4 100644 --- a/common/git/project_git_utils.h +++ b/common/git/project_git_utils.h @@ -1,3 +1,26 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright The KiCad Developers, see AUTHORS.TXT for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/gpl-3.0.html + * or you may search the http://www.gnu.org website for the version 3 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + #ifndef PROJECT_GIT_UTILS_H #define PROJECT_GIT_UTILS_H