42 git_remote* remote =
nullptr;
44 if( git_remote_lookup( &remote,
m_repo,
"origin" ) != 0 )
47 return PushResult::Error;
50 git_remote_callbacks remoteCallbacks;
51 git_remote_init_callbacks( &remoteCallbacks, GIT_REMOTE_CALLBACKS_VERSION );
57 remoteCallbacks.payload =
this;
62 if( git_remote_connect( remote, GIT_DIRECTION_PUSH, &remoteCallbacks,
nullptr,
nullptr ) )
64 AddErrorString( wxString::Format(
_(
"Could not connect to remote: %s" ),
65 git_error_last()->message ) );
66 git_remote_free( remote );
67 return PushResult::Error;
70 git_push_options pushOptions;
71 git_push_init_options( &pushOptions, GIT_PUSH_OPTIONS_VERSION );
72 pushOptions.callbacks = remoteCallbacks;
75 git_reference* head =
nullptr;
77 if( git_repository_head( &head,
m_repo ) != 0 )
80 git_remote_free( remote );
81 return PushResult::Error;
86 refs[0] = git_reference_name( head );
87 const git_strarray refspecs = { (
char**) refs, 1 };
89 git_reference_free(head);
90 if( git_remote_push( remote, &refspecs, &pushOptions ) )
93 git_error_last()->message ) );
94 git_remote_disconnect( remote );
95 git_remote_free( remote );
96 return PushResult::Error;
99 git_remote_disconnect( remote );
100 git_remote_free( remote );
void ReportProgress(int aCurrent, int aTotal, const wxString &aMessage)
GIT_PUSH_HANDLER(KIGIT_COMMON *aRepo)
void UpdateProgress(int aCurrent, int aTotal, const wxString &aMessage) override
void AddErrorString(const wxString aErrorString)
int update_cb(const char *aRefname, const git_oid *aFirst, const git_oid *aSecond, void *aPayload)
int transfer_progress_cb(const git_transfer_progress *aStats, void *aPayload)
int credentials_cb(git_cred **aOut, const char *aUrl, const char *aUsername, unsigned int aAllowedTypes, void *aPayload)
int push_transfer_progress_cb(unsigned int aCurrent, unsigned int aTotal, size_t aBytes, void *aPayload)
int progress_cb(const char *str, int len, void *data)