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.
This commit is contained in:
parent
5def02a589
commit
b78bde3d74
|
@ -9,18 +9,16 @@ import (
|
|||
)
|
||||
|
||||
type CherrypickOptions struct {
|
||||
Version uint
|
||||
Mainline uint
|
||||
MergeOpts MergeOptions
|
||||
CheckoutOpts CheckoutOptions
|
||||
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),
|
||||
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
|
||||
|
|
8
clone.go
8
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 {
|
||||
|
|
2
git.go
2
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])
|
||||
|
|
2
merge.go
2
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),
|
||||
|
|
|
@ -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),
|
||||
|
|
12
revert.go
12
revert.go
|
@ -11,8 +11,8 @@ import (
|
|||
// RevertOptions contains options for performing a revert
|
||||
type RevertOptions struct {
|
||||
Mainline uint
|
||||
MergeOpts MergeOptions
|
||||
CheckoutOpts CheckoutOptions
|
||||
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),
|
||||
MergeOptions: mergeOptionsFromC(&copts.merge_opts),
|
||||
CheckoutOptions: checkoutOptionsFromC(&copts.checkout_opts),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue