Coverity fixes
This commit is contained in:
parent
b97d8ddef4
commit
91a151deb1
|
@ -111,6 +111,7 @@ bool PANEL_GIT_REPOS::TransferDataFromWindow()
|
|||
|
||||
KIPLATFORM::SECRETS::StoreSecret( repo.path, repo.username, m_grid->GetCellValue( row, COL_PASSWORD ) );
|
||||
repo.ssh_path = m_grid->GetCellValue( row, COL_SSH_PATH );
|
||||
repo.checkValid = m_grid->GetCellValue( row, COL_STATUS ) == "1";
|
||||
repos.push_back( repo );
|
||||
}
|
||||
|
||||
|
@ -165,11 +166,19 @@ static bool testRepositoryConnection( COMMON_SETTINGS::GIT_REPOSITORY& repositor
|
|||
|
||||
// Create a temporary directory to initialize the Git repository
|
||||
wxString tempDirPath = wxFileName::CreateTempFileName(wxT("kigit_temp"));
|
||||
wxMkDir(tempDirPath, wxS_DIR_DEFAULT );
|
||||
|
||||
if( !wxMkDir(tempDirPath, wxS_DIR_DEFAULT ) )
|
||||
{
|
||||
git_libgit2_shutdown();
|
||||
wxLogError( "Failed to create temporary directory for Git repository (%s): %s", tempDirPath,
|
||||
wxSysErrorMsg() );
|
||||
return false;
|
||||
}
|
||||
|
||||
// Initialize the Git repository
|
||||
git_repository* repo = nullptr;
|
||||
int result = git_repository_init(&repo, tempDirPath.mb_str(wxConvUTF8), 0);
|
||||
|
||||
if (result != 0) {
|
||||
git_repository_free(repo);
|
||||
git_libgit2_shutdown();
|
||||
|
|
|
@ -51,9 +51,7 @@ bool GIT_ADD_TO_INDEX_HANDLER::AddToIndex( const wxString& aFilePath )
|
|||
return false;
|
||||
}
|
||||
|
||||
git_index_find( &at_pos, index, aFilePath.ToUTF8().data() );
|
||||
|
||||
if( at_pos >= 0)
|
||||
if( git_index_find( &at_pos, index, aFilePath.ToUTF8().data() ) == GIT_OK )
|
||||
{
|
||||
git_index_free( index );
|
||||
wxLogError( "%s already in index", aFilePath );
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
#include "git_pull_handler.h"
|
||||
#include <git/kicad_git_common.h>
|
||||
|
||||
#include <wx/log.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <time.h>
|
||||
|
||||
|
@ -249,7 +251,7 @@ PullResult GIT_PULL_HANDLER::handleMerge( const git_annotated_commit** aMergeHea
|
|||
}
|
||||
|
||||
// Get the repository index
|
||||
git_index* index;
|
||||
git_index* index = nullptr;
|
||||
if( git_repository_index( &index, m_repo ) )
|
||||
{
|
||||
AddErrorString( _( "Could not get repository index" ) );
|
||||
|
@ -257,16 +259,16 @@ PullResult GIT_PULL_HANDLER::handleMerge( const git_annotated_commit** aMergeHea
|
|||
}
|
||||
|
||||
// Check for conflicts
|
||||
git_index_conflict_iterator* conflicts;
|
||||
git_index_conflict_iterator* conflicts = nullptr;
|
||||
if( git_index_conflict_iterator_new( &conflicts, index ) )
|
||||
{
|
||||
AddErrorString( _( "Could not get conflict iterator" ) );
|
||||
return PullResult::Error;
|
||||
}
|
||||
|
||||
const git_index_entry* ancestor;
|
||||
const git_index_entry* our;
|
||||
const git_index_entry* their;
|
||||
const git_index_entry* ancestor = nullptr;
|
||||
const git_index_entry* our = nullptr;
|
||||
const git_index_entry* their = nullptr;
|
||||
std::vector<ConflictData> conflict_data;
|
||||
|
||||
while( git_index_conflict_next( &ancestor, &our, &their, conflicts ) == 0 )
|
||||
|
@ -282,6 +284,7 @@ PullResult GIT_PULL_HANDLER::handleMerge( const git_annotated_commit** aMergeHea
|
|||
conflict_datum.their_commit_time = their->mtime.seconds;
|
||||
conflict_datum.our_status = _( "Changed" );
|
||||
conflict_datum.their_status = _( "Changed" );
|
||||
conflict_datum.use_ours = true;
|
||||
|
||||
conflict_data.push_back( conflict_datum );
|
||||
}
|
||||
|
@ -296,6 +299,7 @@ PullResult GIT_PULL_HANDLER::handleMerge( const git_annotated_commit** aMergeHea
|
|||
conflict_datum.their_commit_time = their->mtime.seconds;
|
||||
conflict_datum.our_status = _( "Added" );
|
||||
conflict_datum.their_status = _( "Added" );
|
||||
conflict_datum.use_ours = true;
|
||||
|
||||
conflict_data.push_back( conflict_datum );
|
||||
}
|
||||
|
@ -313,16 +317,7 @@ PullResult GIT_PULL_HANDLER::handleMerge( const git_annotated_commit** aMergeHea
|
|||
}
|
||||
else
|
||||
{
|
||||
ConflictData conflict_datum;
|
||||
conflict_datum.filename = our->path;
|
||||
conflict_datum.our_oid = our->id;
|
||||
conflict_datum.their_oid = their->id;
|
||||
conflict_datum.our_commit_time = our->mtime.seconds;
|
||||
conflict_datum.their_commit_time = their->mtime.seconds;
|
||||
conflict_datum.our_status = _( "Other" );
|
||||
conflict_datum.their_status = _( "Other" );
|
||||
|
||||
conflict_data.push_back( conflict_datum );
|
||||
wxLogError( wxS( "Unexpected conflict state" ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,8 @@
|
|||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
KIGIT_COMMON::KIGIT_COMMON( git_repository* aRepo ) : m_repo( aRepo )
|
||||
KIGIT_COMMON::KIGIT_COMMON( git_repository* aRepo ) :
|
||||
m_repo( aRepo ), m_connType( GIT_CONN_TYPE::GIT_CONN_LOCAL ), m_testedTypes( 0 )
|
||||
{}
|
||||
|
||||
KIGIT_COMMON::~KIGIT_COMMON()
|
||||
|
|
|
@ -385,6 +385,7 @@ COMMON_SETTINGS::COMMON_SETTINGS() :
|
|||
repo.username = repoJson["username"].get<wxString>();
|
||||
repo.ssh_path = repoJson["ssh_path"].get<wxString>();
|
||||
repo.active = repoJson["active"].get<bool>();
|
||||
repo.checkValid = true;
|
||||
|
||||
m_Git.repositories.push_back( repo );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue