Skip to content

Commit b49d8b7

Browse files
committed
Add new field for push-options
To fix a segfault at [1], adjust to upstream development[2,3] that changed the shape of this struct. This new field is added in the same style as `custom_headers`. [1]: libgit2.git:39669956fb510fb7b13289f6ce959884969dbebd:src/libgit2/remote.c:2987 [2]: libgit2.git:ecc6f2fb8399d84e5b2bf043376dfc51f43f3e90 [3]: libgit2.git:39669956fb510fb7b13289f6ce959884969dbebd
1 parent 5cc70d2 commit b49d8b7

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

libgit2-sys/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,7 @@ pub struct git_push_options {
981981
pub proxy_opts: git_proxy_options,
982982
pub follow_redirects: git_remote_redirect_t,
983983
pub custom_headers: git_strarray,
984+
pub remote_push_options: git_strarray,
984985
}
985986

986987
pub type git_tag_foreach_cb =

src/remote.rs

+18
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ pub struct PushOptions<'cb> {
5858
follow_redirects: RemoteRedirect,
5959
custom_headers: Vec<CString>,
6060
custom_headers_ptrs: Vec<*const c_char>,
61+
remote_push_options: Vec<CString>,
62+
remote_push_options_ptrs: Vec<*const c_char>,
6163
}
6264

6365
/// Holds callbacks for a connection to a `Remote`. Disconnects when dropped
@@ -628,6 +630,8 @@ impl<'cb> PushOptions<'cb> {
628630
follow_redirects: RemoteRedirect::Initial,
629631
custom_headers: Vec::new(),
630632
custom_headers_ptrs: Vec::new(),
633+
remote_push_options: Vec::new(),
634+
remote_push_options_ptrs: Vec::new(),
631635
}
632636
}
633637

@@ -673,6 +677,16 @@ impl<'cb> PushOptions<'cb> {
673677
self.custom_headers_ptrs = self.custom_headers.iter().map(|s| s.as_ptr()).collect();
674678
self
675679
}
680+
681+
/// Set server-side options for this push operation.
682+
pub fn remote_push_options(&mut self, remote_push_options: &[&str]) -> &mut Self {
683+
self.remote_push_options = remote_push_options
684+
.iter()
685+
.map(|&s| CString::new(s).unwrap())
686+
.collect();
687+
self.remote_push_options_ptrs = self.remote_push_options.iter().map(|s| s.as_ptr()).collect();
688+
self
689+
}
676690
}
677691

678692
impl<'cb> Binding for PushOptions<'cb> {
@@ -700,6 +714,10 @@ impl<'cb> Binding for PushOptions<'cb> {
700714
count: self.custom_headers_ptrs.len(),
701715
strings: self.custom_headers_ptrs.as_ptr() as *mut _,
702716
},
717+
remote_push_options: git_strarray {
718+
count: self.remote_push_options_ptrs.len(),
719+
strings: self.remote_push_options_ptrs.as_ptr() as *mut _,
720+
},
703721
}
704722
}
705723
}

0 commit comments

Comments
 (0)