From c9e9a4e07356dbb7916a6cbff65e7e17273a00ec Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Sat, 2 Aug 2025 16:38:01 -0700 Subject: [PATCH] Allow git init to succeed without remote --- common/dialogs/git/dialog_git_repository.h | 9 +++++++++ common/git/git_init_handler.cpp | 4 ++++ kicad/project_tree_pane.cpp | 15 ++++++++------- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/common/dialogs/git/dialog_git_repository.h b/common/dialogs/git/dialog_git_repository.h index d2aab6b7ce..fbda72ee5b 100644 --- a/common/dialogs/git/dialog_git_repository.h +++ b/common/dialogs/git/dialog_git_repository.h @@ -85,6 +85,15 @@ public: void SetEncrypted( bool aEncrypted = true ); + void SetSkipButtonLabel( const wxString& aLabel ) + { + if( m_sdbSizerCancel ) + { + m_sdbSizerCancel->SetLabel( aLabel ); + m_sdbSizerCancel->Layout(); + } + } + private: void OnUpdateUI( wxUpdateUIEvent& event ) override; void OnLocationExit( wxFocusEvent& event ) override; diff --git a/common/git/git_init_handler.cpp b/common/git/git_init_handler.cpp index 0cbe6e4089..f2d902128a 100644 --- a/common/git/git_init_handler.cpp +++ b/common/git/git_init_handler.cpp @@ -76,6 +76,10 @@ InitResult GIT_INIT_HANDLER::InitializeRepository( const wxString& aPath ) bool GIT_INIT_HANDLER::SetupRemote( const RemoteConfig& aConfig ) { + // This is an optional step + if( aConfig.url.IsEmpty() ) + return true; + git_repository* repo = GetRepo(); if( !repo ) diff --git a/kicad/project_tree_pane.cpp b/kicad/project_tree_pane.cpp index 0822f62789..04dc2ce037 100644 --- a/kicad/project_tree_pane.cpp +++ b/kicad/project_tree_pane.cpp @@ -1663,21 +1663,15 @@ void PROJECT_TREE_PANE::onGitInitializeProject( wxCommandEvent& aEvent ) } GIT_INIT_HANDLER initHandler( m_TreeProject->GitCommon() ); + wxWindow* topLevelParent = wxGetTopLevelParent( this ); if( initHandler.IsRepository( dir ) ) { - wxWindow* topLevelParent = wxGetTopLevelParent( this ); DisplayInfoMessage( topLevelParent, _( "The selected directory is already a Git project." ) ); return; } - DIALOG_GIT_REPOSITORY dlg( wxGetTopLevelParent( this ), nullptr ); - dlg.SetTitle( _( "Set default remote" ) ); - - if( dlg.ShowModal() != wxID_OK ) - return; - InitResult result = initHandler.InitializeRepository( dir ); if( result != InitResult::Success ) { @@ -1688,6 +1682,13 @@ void PROJECT_TREE_PANE::onGitInitializeProject( wxCommandEvent& aEvent ) m_gitLastError = GIT_ERROR_NONE; + DIALOG_GIT_REPOSITORY dlg( topLevelParent, initHandler.GetRepo() ); + dlg.SetTitle( _( "Set default remote" ) ); + dlg.SetSkipButtonLabel( _( "Skip" ) ); + + if( dlg.ShowModal() != wxID_OK ) + return; + // Set up the remote RemoteConfig remoteConfig; remoteConfig.url = dlg.GetRepoURL();