Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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}

Expand Down Expand Up @@ -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
}

Expand Down