@@ -153,6 +153,9 @@ type HostkeyCertificate struct {
153
153
}
154
154
155
155
type PushOptions struct {
156
+ // Callbacks to use for this push operation
157
+ RemoteCallbacks RemoteCallbacks
158
+
156
159
PbParallelism uint
157
160
}
158
161
@@ -591,6 +594,17 @@ func populateFetchOptions(options *C.git_fetch_options, opts *FetchOptions) {
591
594
options .download_tags = C .git_remote_autotag_option_t (opts .DownloadTags )
592
595
}
593
596
597
+ func populatePushOptions (options * C.git_push_options , opts * PushOptions ) {
598
+ C .git_push_init_options (options , C .GIT_PUSH_OPTIONS_VERSION )
599
+ if opts == nil {
600
+ return
601
+ }
602
+
603
+ options .pb_parallelism = C .uint (opts .PbParallelism )
604
+
605
+ populateRemoteCallbacks (& options .callbacks , & opts .RemoteCallbacks )
606
+ }
607
+
594
608
// Fetch performs a fetch operation. refspecs specifies which refspecs
595
609
// to use for this fetch, use an empty list to use the refspecs from
596
610
// the configuration; msg specifies what to use for the reflog
@@ -689,22 +703,19 @@ func (o *Remote) Ls(filterRefs ...string) ([]RemoteHead, error) {
689
703
}
690
704
691
705
func (o * Remote ) Push (refspecs []string , opts * PushOptions ) error {
692
- var copts C.git_push_options
693
- C .git_push_init_options (& copts , C .GIT_PUSH_OPTIONS_VERSION )
694
- if opts != nil {
695
- copts .pb_parallelism = C .uint (opts .PbParallelism )
696
- }
697
-
698
706
crefspecs := C.git_strarray {}
699
707
crefspecs .count = C .size_t (len (refspecs ))
700
708
crefspecs .strings = makeCStringsFromStrings (refspecs )
701
709
defer freeStrarray (& crefspecs )
702
710
711
+ var coptions C.git_push_options
712
+ populatePushOptions (& coptions , opts )
713
+ defer untrackCalbacksPayload (& coptions .callbacks )
714
+
703
715
runtime .LockOSThread ()
704
716
defer runtime .UnlockOSThread ()
705
- defer untrackCalbacksPayload (& copts .callbacks )
706
717
707
- ret := C .git_remote_push (o .ptr , & crefspecs , & copts )
718
+ ret := C .git_remote_push (o .ptr , & crefspecs , & coptions )
708
719
if ret < 0 {
709
720
return MakeGitError (ret )
710
721
}
0 commit comments