Skip to content

Commit

Permalink
struct defs changes for supporting shallow clone
Browse files Browse the repository at this point in the history
* New struct `git_fetch_negotiation`
* New field `depth` for `git_fetch_options`
* New callback `git_transport->shallow_roots`.
* Updated `git_transport->negotiate_fetch` param with `git_fetch_negotiation`.
*
  • Loading branch information
weihanglo committed Jul 25, 2023
1 parent f8ef6b0 commit f5d96ab
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
15 changes: 13 additions & 2 deletions libgit2-sys/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,10 +394,20 @@ pub struct git_fetch_options {
pub update_fetchhead: c_int,
pub download_tags: git_remote_autotag_option_t,
pub proxy_opts: git_proxy_options,
pub depth: c_int,
pub follow_redirects: git_remote_redirect_t,
pub custom_headers: git_strarray,
}

#[repr(C)]
pub struct git_fetch_negotiation {
refs: *const *const git_remote_head,
refs_len: size_t,
shallow_roots: *mut git_oid,
shallow_roots_len: size_t,
depth: c_int,
}

git_enum! {
pub enum git_remote_autotag_option_t {
GIT_REMOTE_DOWNLOAD_TAGS_UNSPECIFIED,
Expand Down Expand Up @@ -1406,10 +1416,11 @@ pub struct git_transport {
extern "C" fn(
transport: *mut git_transport,
repo: *mut git_repository,
refs: *const *const git_remote_head,
count: size_t,
fetch_data: *const git_fetch_negotiation,
) -> c_int,
>,
pub shallow_roots:
Option<extern "C" fn(out: *mut git_oidarray, transport: *mut git_transport) -> c_int>,
pub download_pack: Option<
extern "C" fn(
transport: *mut git_transport,
Expand Down
1 change: 1 addition & 0 deletions src/remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,7 @@ impl<'cb> Binding for FetchOptions<'cb> {
prune: crate::call::convert(&self.prune),
update_fetchhead: crate::call::convert(&self.update_fetchhead),
download_tags: crate::call::convert(&self.download_tags),
depth: 0, // GIT_FETCH_DEPTH_FULL.
follow_redirects: self.follow_redirects.raw(),
custom_headers: git_strarray {
count: self.custom_headers_ptrs.len(),
Expand Down

0 comments on commit f5d96ab

Please sign in to comment.