diff --git a/remote.go b/remote.go index a294ca23..e6694981 100644 --- a/remote.go +++ b/remote.go @@ -144,6 +144,11 @@ type FetchOptions struct { // Proxy options to use for this fetch operation ProxyOptions ProxyOptions + + // Depth controls the depth of the fetch/clone operation. + // A value of 0 means no depth limit (fetch/clone everything). + // A positive value will limit the history to that number of commits. + Depth int } type RemoteConnectOptions struct { @@ -685,7 +690,7 @@ func (c *RemoteCollection) Create(name string, url string) (*Remote, error) { return remote, nil } -//CreateWithOptions Creates a repository object with extended options. +// CreateWithOptions Creates a repository object with extended options. func (c *RemoteCollection) CreateWithOptions(url string, option *RemoteCreateOptions) (*Remote, error) { remote := &Remote{repo: c.repo} @@ -991,6 +996,12 @@ func populateFetchOptions(copts *C.git_fetch_options, opts *FetchOptions, errorT strings: makeCStringsFromStrings(opts.Headers), } populateProxyOptions(&copts.proxy_opts, &opts.ProxyOptions) + + // Set depth if specified + if opts.Depth > 0 { + copts.depth = C.int(opts.Depth) + } + return copts }