Cleanup libgit init calls

This commit is contained in:
Seth Hillbrand 2024-05-06 10:18:38 -07:00
parent ba5ad70b68
commit 8a306eecb6
8 changed files with 31 additions and 17 deletions

View File

@ -56,7 +56,8 @@ DIALOG_GIT_REPOSITORY::DIALOG_GIT_REPOSITORY( wxWindow* aParent, git_repository*
m_tempRepo = true;
m_tempPath = wxFileName::CreateTempFileName( "kicadtestrepo" );
git_repository_init_options options = GIT_REPOSITORY_INIT_OPTIONS_INIT;
git_repository_init_options options;
git_repository_init_init_options( &options, GIT_REPOSITORY_INIT_OPTIONS_VERSION );
options.flags = GIT_REPOSITORY_INIT_MKPATH | GIT_REPOSITORY_INIT_NO_REINIT;
git_repository_init_ext( &m_repository, m_tempPath.ToStdString().c_str(), &options );
}
@ -260,7 +261,8 @@ void DIALOG_GIT_REPOSITORY::updateURLData()
void DIALOG_GIT_REPOSITORY::OnTestClick( wxCommandEvent& event )
{
git_remote* remote = nullptr;
git_remote_callbacks callbacks = GIT_REMOTE_CALLBACKS_INIT;
git_remote_callbacks callbacks;
git_remote_init_callbacks( &callbacks, GIT_REMOTE_CALLBACKS_VERSION );
// We track if we have already tried to connect.
// If we have, the server may come back to offer another connection

View File

@ -121,8 +121,6 @@ private:
bool m_tempRepo;
wxString m_tempPath;
KIGIT_COMMON::GIT_CONN_TYPE m_repoType;
};
#endif /* DIALOG_GIT_REPOSITORY_H_ */

View File

@ -51,7 +51,8 @@ bool GIT_CLONE_HANDLER::PerformClone()
}
}
git_clone_options cloneOptions = GIT_CLONE_OPTIONS_INIT;
git_clone_options cloneOptions;
git_clone_init_options( &cloneOptions, GIT_CLONE_OPTIONS_VERSION );
cloneOptions.checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE;
cloneOptions.checkout_opts.progress_cb = clone_progress_cb;
cloneOptions.checkout_opts.progress_payload = this;

View File

@ -47,7 +47,8 @@ bool GIT_PULL_HANDLER::PerformFetch()
return false;
}
git_remote_callbacks remoteCallbacks = GIT_REMOTE_CALLBACKS_INIT;
git_remote_callbacks remoteCallbacks;
git_remote_init_callbacks( &remoteCallbacks, GIT_REMOTE_CALLBACKS_VERSION );
remoteCallbacks.sideband_progress = progress_cb;
remoteCallbacks.transfer_progress = transfer_progress_cb;
remoteCallbacks.credentials = credentials_cb;
@ -60,7 +61,8 @@ bool GIT_PULL_HANDLER::PerformFetch()
return false;
}
git_fetch_options fetchOptions = GIT_FETCH_OPTIONS_INIT;
git_fetch_options fetchOptions;
git_fetch_init_options( &fetchOptions, GIT_FETCH_OPTIONS_VERSION );
fetchOptions.callbacks = remoteCallbacks;
if( git_remote_fetch( remote, nullptr, &fetchOptions, nullptr ) )
@ -188,7 +190,8 @@ PullResult GIT_PULL_HANDLER::handleFastForward()
return PullResult::Error;
}
git_checkout_options checkoutOptions = GIT_CHECKOUT_OPTIONS_INIT;
git_checkout_options checkoutOptions;
git_checkout_init_options( &checkoutOptions, GIT_CHECKOUT_OPTIONS_VERSION );
checkoutOptions.checkout_strategy = GIT_CHECKOUT_SAFE;
if( git_checkout_head( m_repo, &checkoutOptions ) )
{
@ -239,8 +242,11 @@ PullResult GIT_PULL_HANDLER::handleFastForward()
PullResult GIT_PULL_HANDLER::handleMerge( const git_annotated_commit** aMergeHeads,
size_t aMergeHeadsCount )
{
git_merge_options merge_opts = GIT_MERGE_OPTIONS_INIT;
git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
git_merge_options merge_opts;
git_merge_options_init( &merge_opts, GIT_MERGE_OPTIONS_VERSION );
git_checkout_options checkout_opts;
git_checkout_init_options( &checkout_opts, GIT_CHECKOUT_OPTIONS_VERSION );
checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE;

View File

@ -45,7 +45,8 @@ PushResult GIT_PUSH_HANDLER::PerformPush()
return PushResult::Error;
}
git_remote_callbacks remoteCallbacks = GIT_REMOTE_CALLBACKS_INIT;
git_remote_callbacks remoteCallbacks;
git_remote_init_callbacks( &remoteCallbacks, GIT_REMOTE_CALLBACKS_VERSION );
remoteCallbacks.sideband_progress = progress_cb;
remoteCallbacks.transfer_progress = transfer_progress_cb;
remoteCallbacks.update_tips = update_cb;
@ -59,7 +60,8 @@ PushResult GIT_PUSH_HANDLER::PerformPush()
return PushResult::Error;
}
git_push_options pushOptions = GIT_PUSH_OPTIONS_INIT;
git_push_options pushOptions;
git_push_init_options( &pushOptions, GIT_PUSH_OPTIONS_VERSION );
pushOptions.callbacks = remoteCallbacks;
if( git_remote_push( remote, nullptr, &pushOptions ) )

View File

@ -63,7 +63,8 @@ static int checkout_notify_cb(git_checkout_notify_t why, const char *path,
void GIT_REVERT_HANDLER::PerformRevert()
{
git_object* head_commit = NULL;
git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
git_checkout_options opts;
git_checkout_init_options(&opts, GIT_CHECKOUT_OPTIONS_VERSION);
// Get the HEAD commit
if (git_revparse_single(&head_commit, m_repository, "HEAD") != 0) {

View File

@ -252,7 +252,8 @@ std::pair<std::set<wxString>,std::set<wxString>> KIGIT_COMMON::GetDifferentFiles
git_diff* diff;
git_diff_options diff_opts = GIT_DIFF_OPTIONS_INIT;
git_diff_options diff_opts;
git_diff_init_options( &diff_opts, GIT_DIFF_OPTIONS_VERSION );
if( git_diff_tree_to_tree( &diff, m_repo, parent_tree, tree, &diff_opts ) == GIT_OK )
{

View File

@ -712,7 +712,8 @@ bool PROJECT_TREE_PANE::hasChangedFiles()
if( !repo )
return false;
git_status_options opts = GIT_STATUS_OPTIONS_INIT;
git_status_options opts;
git_status_init_options( &opts, GIT_STATUS_OPTIONS_VERSION );
opts.show = GIT_STATUS_SHOW_INDEX_AND_WORKDIR;
opts.flags = GIT_STATUS_OPT_INCLUDE_UNTRACKED | GIT_STATUS_OPT_RENAMES_HEAD_TO_INDEX
@ -1947,7 +1948,8 @@ void PROJECT_TREE_PANE::updateGitStatusIcons()
}
}
git_status_options status_options = GIT_STATUS_OPTIONS_INIT;
git_status_options status_options;
git_status_init_options( &status_options, GIT_STATUS_OPTIONS_VERSION );
status_options.show = GIT_STATUS_SHOW_INDEX_AND_WORKDIR;
status_options.flags = GIT_STATUS_OPT_INCLUDE_UNTRACKED | GIT_STATUS_OPT_INCLUDE_UNMODIFIED;
@ -2097,7 +2099,8 @@ void PROJECT_TREE_PANE::onGitCommit( wxCommandEvent& aEvent )
git_config_free( config );
// Collect modified files in the repository
git_status_options status_options = GIT_STATUS_OPTIONS_INIT;
git_status_options status_options;
git_status_init_options( &status_options, GIT_STATUS_OPTIONS_VERSION );
status_options.show = GIT_STATUS_SHOW_INDEX_AND_WORKDIR;
status_options.flags = GIT_STATUS_OPT_INCLUDE_UNTRACKED;