7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-07 18:25:31 +00:00

Don't create a repository before the dialog

The user might cancel a dialog, leaving a broken repo.  We use a temp
repo to test the connection

Fixes https://gitlab.com/kicad/code/kicad/-/issues/16263
This commit is contained in:
Seth Hillbrand 2025-01-22 14:16:44 -08:00
parent f871255005
commit 1641878af7

View File

@ -1596,38 +1596,36 @@ void PROJECT_TREE_PANE::onGitInitializeProject( wxCommandEvent& aEvent )
git_repository_free( repo );
return;
}
else
{
// Directory is not a git repository
error = git_repository_init( &repo, dir.mb_str(), 0 );
if( error != 0 )
{
git_repository_free( repo );
if( m_gitLastError != git_error_last()->klass )
{
m_gitLastError = git_error_last()->klass;
DisplayErrorMessage( m_parent, _( "Failed to initialize git project." ),
git_error_last()->message );
}
return;
}
else
{
m_TreeProject->SetGitRepo( repo );
m_gitLastError = GIT_ERROR_NONE;
}
}
DIALOG_GIT_REPOSITORY dlg( wxGetTopLevelParent( this ), repo );
DIALOG_GIT_REPOSITORY dlg( wxGetTopLevelParent( this ), nullptr );
dlg.SetTitle( _( "Set default remote" ) );
if( dlg.ShowModal() != wxID_OK )
return;
// Directory is not a git repository
error = git_repository_init( &repo, dir.mb_str(), 0 );
if( error != 0 )
{
git_repository_free( repo );
if( m_gitLastError != git_error_last()->klass )
{
m_gitLastError = git_error_last()->klass;
DisplayErrorMessage( m_parent, _( "Failed to initialize git project." ),
git_error_last()->message );
}
return;
}
else
{
m_TreeProject->SetGitRepo( repo );
m_gitLastError = GIT_ERROR_NONE;
}
//Set up the git remote
m_TreeProject->GitCommon()->SetConnType( dlg.GetRepoType() );