aboutsummaryrefslogtreecommitdiffstats
path: root/options.go
diff options
context:
space:
mode:
authorPaulo Gomes <pjbgf@linux.com>2023-08-05 10:20:38 +0100
committerGitHub <noreply@github.com>2023-08-05 10:20:38 +0100
commite6f68d2e4cd1bc4447126816c7c27e1fc2098e30 (patch)
tree15c5e333b93641f9eadcb4bf4b34c338135f7a23 /options.go
parent5882d60fb7ccd4cfc0fe69286aa96e198c9d1eb0 (diff)
parent4ec6b3f4fa9cdfe8f10d0953ac7d398d01a90f17 (diff)
downloadgo-git-e6f68d2e4cd1bc4447126816c7c27e1fc2098e30.tar.gz
Merge branch 'master' into jc/commit-ammend
Diffstat (limited to 'options.go')
-rw-r--r--options.go71
1 files changed, 67 insertions, 4 deletions
diff --git a/options.go b/options.go
index a2d62bd..757bdc8 100644
--- a/options.go
+++ b/options.go
@@ -10,6 +10,7 @@ import (
"github.com/ProtonMail/go-crypto/openpgp"
"github.com/go-git/go-git/v5/config"
"github.com/go-git/go-git/v5/plumbing"
+ formatcfg "github.com/go-git/go-git/v5/plumbing/format/config"
"github.com/go-git/go-git/v5/plumbing/object"
"github.com/go-git/go-git/v5/plumbing/protocol/packp/sideband"
"github.com/go-git/go-git/v5/plumbing/transport"
@@ -45,6 +46,14 @@ type CloneOptions struct {
ReferenceName plumbing.ReferenceName
// Fetch only ReferenceName if true.
SingleBranch bool
+ // Mirror clones the repository as a mirror.
+ //
+ // Compared to a bare clone, mirror not only maps local branches of the
+ // source to local branches of the target, it maps all refs (including
+ // remote-tracking branches, notes etc.) and sets up a refspec configuration
+ // such that all these refs are overwritten by a git remote update in the
+ // target repository.
+ Mirror bool
// No checkout of HEAD after clone if true.
NoCheckout bool
// Limit fetching to the specified number of commits.
@@ -53,6 +62,9 @@ type CloneOptions struct {
// within, using their default settings. This option is ignored if the
// cloned repository does not have a worktree.
RecurseSubmodules SubmoduleRescursivity
+ // ShallowSubmodules limit cloning submodules to the 1 level of depth.
+ // It matches the git command --shallow-submodules.
+ ShallowSubmodules bool
// Progress is where the human readable information sent by the server is
// stored, if nil nothing is stored and the capability (if supported)
// no-progress, is sent to the server to avoid send this information.
@@ -64,6 +76,8 @@ type CloneOptions struct {
InsecureSkipTLS bool
// CABundle specify additional ca bundle with system cert pool
CABundle []byte
+ // ProxyOptions provides info required for connecting to a proxy.
+ ProxyOptions transport.ProxyOptions
}
// Validate validates the fields and sets the default values.
@@ -115,6 +129,8 @@ type PullOptions struct {
InsecureSkipTLS bool
// CABundle specify additional ca bundle with system cert pool
CABundle []byte
+ // ProxyOptions provides info required for connecting to a proxy.
+ ProxyOptions transport.ProxyOptions
}
// Validate validates the fields and sets the default values.
@@ -171,6 +187,8 @@ type FetchOptions struct {
InsecureSkipTLS bool
// CABundle specify additional ca bundle with system cert pool
CABundle []byte
+ // ProxyOptions provides info required for connecting to a proxy.
+ ProxyOptions transport.ProxyOptions
}
// Validate validates the fields and sets the default values.
@@ -218,7 +236,7 @@ type PushOptions struct {
// Force allows the push to update a remote branch even when the local
// branch does not descend from it.
Force bool
- // InsecureSkipTLS skips ssl verify if protocal is https
+ // InsecureSkipTLS skips ssl verify if protocol is https
InsecureSkipTLS bool
// CABundle specify additional ca bundle with system cert pool
CABundle []byte
@@ -234,6 +252,8 @@ type PushOptions struct {
Options map[string]string
// Atomic sets option to be an atomic push
Atomic bool
+ // ProxyOptions provides info required for connecting to a proxy.
+ ProxyOptions transport.ProxyOptions
}
// ForceWithLease sets fields on the lease
@@ -283,6 +303,9 @@ type SubmoduleUpdateOptions struct {
RecurseSubmodules SubmoduleRescursivity
// Auth credentials, if required, to use with the remote repository.
Auth transport.AuthMethod
+ // Depth limit fetching to the specified number of commits from the tip of
+ // each remote branch history.
+ Depth int
}
var (
@@ -402,7 +425,7 @@ type LogOptions struct {
// Show only those commits in which the specified file was inserted/updated.
// It is equivalent to running `git log -- <file-name>`.
- // this field is kept for compatility, it can be replaced with PathFilter
+ // this field is kept for compatibility, it can be replaced with PathFilter
FileName *string
// Filter commits based on the path of files that are updated
@@ -458,6 +481,10 @@ type CommitOptions struct {
// All automatically stage files that have been modified and deleted, but
// new files you have not told Git about are not affected.
All bool
+ // AllowEmptyCommits enable empty commits to be created. An empty commit
+ // is when no changes to the tree were made, but a new commit message is
+ // provided. The default behavior is false, which results in ErrEmptyCommit.
+ AllowEmptyCommits bool
// Author is the author's signature of the commit. If Author is empty the
// Name and Email is read from the config, and time.Now it's used as When.
Author *object.Signature
@@ -618,12 +645,35 @@ func (o *CreateTagOptions) loadConfigTagger(r *Repository) error {
type ListOptions struct {
// Auth credentials, if required, to use with the remote repository.
Auth transport.AuthMethod
- // InsecureSkipTLS skips ssl verify if protocal is https
+ // InsecureSkipTLS skips ssl verify if protocol is https
InsecureSkipTLS bool
// CABundle specify additional ca bundle with system cert pool
CABundle []byte
+ // PeelingOption defines how peeled objects are handled during a
+ // remote list.
+ PeelingOption PeelingOption
+ // ProxyOptions provides info required for connecting to a proxy.
+ ProxyOptions transport.ProxyOptions
+ // Timeout specifies the timeout in seconds for list operations
+ Timeout int
}
+// PeelingOption represents the different ways to handle peeled references.
+//
+// Peeled references represent the underlying object of an annotated
+// (or signed) tag. Refer to upstream documentation for more info:
+// https://github.com/git/git/blob/master/Documentation/technical/reftable.txt
+type PeelingOption uint8
+
+const (
+ // IgnorePeeled ignores all peeled reference names. This is the default behavior.
+ IgnorePeeled PeelingOption = 0
+ // OnlyPeeled returns only peeled reference names.
+ OnlyPeeled PeelingOption = 1
+ // AppendPeeled appends peeled reference names to the reference list.
+ AppendPeeled PeelingOption = 2
+)
+
// CleanOptions describes how a clean should be performed.
type CleanOptions struct {
Dir bool
@@ -648,7 +698,13 @@ var (
)
// Validate validates the fields and sets the default values.
+//
+// TODO: deprecate in favor of Validate(r *Repository) in v6.
func (o *GrepOptions) Validate(w *Worktree) error {
+ return o.validate(w.r)
+}
+
+func (o *GrepOptions) validate(r *Repository) error {
if !o.CommitHash.IsZero() && o.ReferenceName != "" {
return ErrHashOrReference
}
@@ -656,7 +712,7 @@ func (o *GrepOptions) Validate(w *Worktree) error {
// If none of CommitHash and ReferenceName are provided, set commit hash of
// the repository's head.
if o.CommitHash.IsZero() && o.ReferenceName == "" {
- ref, err := w.r.Head()
+ ref, err := r.Head()
if err != nil {
return err
}
@@ -679,3 +735,10 @@ type PlainOpenOptions struct {
// Validate validates the fields and sets the default values.
func (o *PlainOpenOptions) Validate() error { return nil }
+
+type PlainInitOptions struct {
+ ObjectFormat formatcfg.ObjectFormat
+}
+
+// Validate validates the fields and sets the default values.
+func (o *PlainInitOptions) Validate() error { return nil }