summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlhchavez <[email protected]>2020-12-04 19:54:26 -0800
committerlhchavez <[email protected]>2021-09-05 18:52:01 -0700
commitb78bde3d74b1617d5b635723552aaec0583eb054 (patch)
tree16c98859171b6483b61ac710672694d823db2e1b
parent5def02a589a2c1653f4bb515fdec290361a222be (diff)
Make all Options objects consistent
This change makes all Options objects have child Option fields as values (instead of pointers) to mirror the libgit2 interface. It also names them Options instead of Opts to match the current libgit2 nomenclature and removes the Version fields.
-rw-r--r--cherrypick.go20
-rw-r--r--clone.go8
-rw-r--r--git.go2
-rw-r--r--merge.go2
-rw-r--r--rebase.go2
-rw-r--r--revert.go16
-rw-r--r--revert_test.go4
-rw-r--r--submodule.go8
8 files changed, 28 insertions, 34 deletions
diff --git a/cherrypick.go b/cherrypick.go
index 5ba57a5..a0ee0f0 100644
--- a/cherrypick.go
+++ b/cherrypick.go
@@ -9,18 +9,16 @@ import (
)
type CherrypickOptions struct {
- Version uint
- Mainline uint
- MergeOpts MergeOptions
- CheckoutOpts CheckoutOptions
+ Mainline uint
+ MergeOptions MergeOptions
+ CheckoutOptions CheckoutOptions
}
func cherrypickOptionsFromC(c *C.git_cherrypick_options) CherrypickOptions {
opts := CherrypickOptions{
- Version: uint(c.version),
- Mainline: uint(c.mainline),
- MergeOpts: mergeOptionsFromC(&c.merge_opts),
- CheckoutOpts: checkoutOptionsFromC(&c.checkout_opts),
+ Mainline: uint(c.mainline),
+ MergeOptions: mergeOptionsFromC(&c.merge_opts),
+ CheckoutOptions: checkoutOptionsFromC(&c.checkout_opts),
}
return opts
}
@@ -31,8 +29,8 @@ func populateCherrypickOptions(copts *C.git_cherrypick_options, opts *Cherrypick
return nil
}
copts.mainline = C.uint(opts.Mainline)
- populateMergeOptions(&copts.merge_opts, &opts.MergeOpts)
- populateCheckoutOptions(&copts.checkout_opts, &opts.CheckoutOpts, errorTarget)
+ populateMergeOptions(&copts.merge_opts, &opts.MergeOptions)
+ populateCheckoutOptions(&copts.checkout_opts, &opts.CheckoutOptions, errorTarget)
return copts
}
@@ -82,7 +80,7 @@ func (r *Repository) CherrypickCommit(pick, our *Commit, opts CherrypickOptions)
runtime.LockOSThread()
defer runtime.UnlockOSThread()
- cOpts := populateMergeOptions(&C.git_merge_options{}, &opts.MergeOpts)
+ cOpts := populateMergeOptions(&C.git_merge_options{}, &opts.MergeOptions)
defer freeMergeOptions(cOpts)
var ptr *C.git_index
diff --git a/clone.go b/clone.go
index 276e753..234efa0 100644
--- a/clone.go
+++ b/clone.go
@@ -14,8 +14,8 @@ import (
type RemoteCreateCallback func(repo *Repository, name, url string) (*Remote, error)
type CloneOptions struct {
- *CheckoutOpts
- *FetchOptions
+ CheckoutOptions CheckoutOptions
+ FetchOptions FetchOptions
Bare bool
CheckoutBranch string
RemoteCreateCallback RemoteCreateCallback
@@ -100,8 +100,8 @@ func populateCloneOptions(copts *C.git_clone_options, opts *CloneOptions, errorT
if opts == nil {
return nil
}
- populateCheckoutOptions(&copts.checkout_opts, opts.CheckoutOpts, errorTarget)
- populateFetchOptions(&copts.fetch_opts, opts.FetchOptions, errorTarget)
+ populateCheckoutOptions(&copts.checkout_opts, &opts.CheckoutOptions, errorTarget)
+ populateFetchOptions(&copts.fetch_opts, &opts.FetchOptions, errorTarget)
copts.bare = cbool(opts.Bare)
if opts.RemoteCreateCallback != nil {
diff --git a/git.go b/git.go
index 62cf5d9..383c492 100644
--- a/git.go
+++ b/git.go
@@ -227,7 +227,7 @@ func NewOid(s string) (*Oid, error) {
}
if len(slice) != 20 {
- return nil, &GitError{"Invalid Oid", ErrorClassNone, ErrGeneric}
+ return nil, &GitError{"invalid oid", ErrorClassNone, ErrorCodeGeneric}
}
copy(o[:], slice[:20])
diff --git a/merge.go b/merge.go
index a8e7d6e..6e7d581 100644
--- a/merge.go
+++ b/merge.go
@@ -138,7 +138,6 @@ const (
)
type MergeOptions struct {
- Version uint
TreeFlags MergeTreeFlag
RenameThreshold uint
@@ -151,7 +150,6 @@ type MergeOptions struct {
func mergeOptionsFromC(opts *C.git_merge_options) MergeOptions {
return MergeOptions{
- Version: uint(opts.version),
TreeFlags: MergeTreeFlag(opts.flags),
RenameThreshold: uint(opts.rename_threshold),
TargetLimit: uint(opts.target_limit),
diff --git a/rebase.go b/rebase.go
index 98c3e90..a61e8e7 100644
--- a/rebase.go
+++ b/rebase.go
@@ -130,7 +130,6 @@ func commitSigningCallback(errorMessage **C.char, _signature *C.git_buf, _signat
// RebaseOptions are used to tell the rebase machinery how to operate
type RebaseOptions struct {
- Version uint
Quiet int
InMemory int
RewriteNotesRef string
@@ -160,7 +159,6 @@ func DefaultRebaseOptions() (RebaseOptions, error) {
func rebaseOptionsFromC(opts *C.git_rebase_options) RebaseOptions {
return RebaseOptions{
- Version: uint(opts.version),
Quiet: int(opts.quiet),
InMemory: int(opts.inmemory),
RewriteNotesRef: C.GoString(opts.rewrite_notes_ref),
diff --git a/revert.go b/revert.go
index 085df16..76ddf53 100644
--- a/revert.go
+++ b/revert.go
@@ -10,9 +10,9 @@ import (
// RevertOptions contains options for performing a revert
type RevertOptions struct {
- Mainline uint
- MergeOpts MergeOptions
- CheckoutOpts CheckoutOptions
+ Mainline uint
+ MergeOptions MergeOptions
+ CheckoutOptions CheckoutOptions
}
func populateRevertOptions(copts *C.git_revert_options, opts *RevertOptions, errorTarget *error) *C.git_revert_options {
@@ -21,16 +21,16 @@ func populateRevertOptions(copts *C.git_revert_options, opts *RevertOptions, err
return nil
}
copts.mainline = C.uint(opts.Mainline)
- populateMergeOptions(&copts.merge_opts, &opts.MergeOpts)
- populateCheckoutOptions(&copts.checkout_opts, &opts.CheckoutOpts, errorTarget)
+ populateMergeOptions(&copts.merge_opts, &opts.MergeOptions)
+ populateCheckoutOptions(&copts.checkout_opts, &opts.CheckoutOptions, errorTarget)
return copts
}
func revertOptionsFromC(copts *C.git_revert_options) RevertOptions {
return RevertOptions{
- Mainline: uint(copts.mainline),
- MergeOpts: mergeOptionsFromC(&copts.merge_opts),
- CheckoutOpts: checkoutOptionsFromC(&copts.checkout_opts),
+ Mainline: uint(copts.mainline),
+ MergeOptions: mergeOptionsFromC(&copts.merge_opts),
+ CheckoutOptions: checkoutOptionsFromC(&copts.checkout_opts),
}
}
diff --git a/revert_test.go b/revert_test.go
index fcf8e43..1104866 100644
--- a/revert_test.go
+++ b/revert_test.go
@@ -60,11 +60,11 @@ func TestRevertCommit(t *testing.T) {
revertOptions, err := DefaultRevertOptions()
checkFatal(t, err)
- index, err := repo.RevertCommit(commit, commit, 0, &revertOptions.MergeOpts)
+ index, err := repo.RevertCommit(commit, commit, 0, &revertOptions.MergeOptions)
checkFatal(t, err)
defer index.Free()
- err = repo.CheckoutIndex(index, &revertOptions.CheckoutOpts)
+ err = repo.CheckoutIndex(index, &revertOptions.CheckoutOptions)
checkFatal(t, err)
actualReadmeContents := readReadme(t, repo)
diff --git a/submodule.go b/submodule.go
index 0fdaa12..34d5031 100644
--- a/submodule.go
+++ b/submodule.go
@@ -14,8 +14,8 @@ import (
// SubmoduleUpdateOptions
type SubmoduleUpdateOptions struct {
- *CheckoutOpts
- *FetchOptions
+ CheckoutOptions CheckoutOptions
+ FetchOptions FetchOptions
}
// Submodule
@@ -390,8 +390,8 @@ func populateSubmoduleUpdateOptions(copts *C.git_submodule_update_options, opts
return nil
}
- populateCheckoutOptions(&copts.checkout_opts, opts.CheckoutOpts, errorTarget)
- populateFetchOptions(&copts.fetch_opts, opts.FetchOptions, errorTarget)
+ populateCheckoutOptions(&copts.checkout_opts, &opts.CheckoutOptions, errorTarget)
+ populateFetchOptions(&copts.fetch_opts, &opts.FetchOptions, errorTarget)
return copts
}