本文整理汇总了Golang中C.git_strarray类的典型用法代码示例。如果您正苦于以下问题:Golang git_strarray类的具体用法?Golang git_strarray怎么用?Golang git_strarray使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了git_strarray类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: RemoveAll
func (v *Index) RemoveAll(pathspecs []string, callback IndexMatchedPathCallback) error {
cpathspecs := C.git_strarray{}
cpathspecs.count = C.size_t(len(pathspecs))
cpathspecs.strings = makeCStringsFromStrings(pathspecs)
defer freeStrarray(&cpathspecs)
runtime.LockOSThread()
defer runtime.UnlockOSThread()
var handle unsafe.Pointer
if callback != nil {
handle = pointerHandles.Track(callback)
defer pointerHandles.Untrack(handle)
}
ret := C._go_git_index_remove_all(
v.ptr,
&cpathspecs,
handle,
)
if ret < 0 {
return MakeGitError(ret)
}
return nil
}
示例2: diffOptionsToC
func diffOptionsToC(opts *DiffOptions) (copts *C.git_diff_options, notifyData *diffNotifyData) {
cpathspec := C.git_strarray{}
if opts != nil {
notifyData = &diffNotifyData{
Callback: opts.NotifyCallback,
}
if opts.Pathspec != nil {
cpathspec.count = C.size_t(len(opts.Pathspec))
cpathspec.strings = makeCStringsFromStrings(opts.Pathspec)
}
copts = &C.git_diff_options{
version: C.GIT_DIFF_OPTIONS_VERSION,
flags: C.uint32_t(opts.Flags),
ignore_submodules: C.git_submodule_ignore_t(opts.IgnoreSubmodules),
pathspec: cpathspec,
context_lines: C.uint32_t(opts.ContextLines),
interhunk_lines: C.uint32_t(opts.InterhunkLines),
id_abbrev: C.uint16_t(opts.IdAbbrev),
max_size: C.git_off_t(opts.MaxSize),
old_prefix: C.CString(opts.OldPrefix),
new_prefix: C.CString(opts.NewPrefix),
}
if opts.NotifyCallback != nil {
C._go_git_setup_diff_notify_callbacks(copts)
copts.notify_payload = unsafe.Pointer(notifyData)
}
}
return
}
示例3: AddAll
func (v *Index) AddAll(pathspecs []string, flags IndexAddOpts, callback IndexMatchedPathCallback) error {
cpathspecs := C.git_strarray{}
cpathspecs.count = C.size_t(len(pathspecs))
cpathspecs.strings = makeCStringsFromStrings(pathspecs)
defer freeStrarray(&cpathspecs)
runtime.LockOSThread()
defer runtime.UnlockOSThread()
var cb *IndexMatchedPathCallback
if callback != nil {
cb = &callback
}
ret := C._go_git_index_add_all(
v.ptr,
&cpathspecs,
C.uint(flags),
unsafe.Pointer(cb),
)
if ret < 0 {
return MakeGitError(ret)
}
return nil
}
示例4: Fetch
// Fetch performs a fetch operation. refspecs specifies which refspecs
// to use for this fetch, use an empty list to use the refspecs from
// the configuration; sig and msg specify what to use for the reflog
// entries. Leave nil and "" to use defaults.
func (o *Remote) Fetch(refspecs []string, sig *Signature, msg string) error {
var csig *C.git_signature = nil
if sig != nil {
csig = sig.toC()
defer C.free(unsafe.Pointer(csig))
}
var cmsg *C.char = nil
if msg != "" {
cmsg = C.CString(msg)
defer C.free(unsafe.Pointer(cmsg))
}
crefspecs := C.git_strarray{}
crefspecs.count = C.size_t(len(refspecs))
crefspecs.strings = makeCStringsFromStrings(refspecs)
defer freeStrarray(&crefspecs)
ret := C.git_remote_fetch(o.ptr, &crefspecs, csig, cmsg)
if ret < 0 {
return MakeGitError(ret)
}
return nil
}
示例5: Fetch
// Fetch performs a fetch operation. refspecs specifies which refspecs
// to use for this fetch, use an empty list to use the refspecs from
// the configuration; msg specifies what to use for the reflog
// entries. Leave "" to use defaults.
func (o *Remote) Fetch(refspecs []string, opts *FetchOptions, msg string) error {
var cmsg *C.char = nil
if msg != "" {
cmsg = C.CString(msg)
defer C.free(unsafe.Pointer(cmsg))
}
crefspecs := C.git_strarray{}
crefspecs.count = C.size_t(len(refspecs))
crefspecs.strings = makeCStringsFromStrings(refspecs)
defer freeStrarray(&crefspecs)
var coptions C.git_fetch_options
populateFetchOptions(&coptions, opts)
defer untrackCalbacksPayload(&coptions.callbacks)
runtime.LockOSThread()
defer runtime.UnlockOSThread()
ret := C.git_remote_fetch(o.ptr, &crefspecs, &coptions, cmsg)
if ret < 0 {
return MakeGitError(ret)
}
return nil
}
示例6: DiffTreeToTree
func (v *Repository) DiffTreeToTree(oldTree, newTree *Tree, opts *DiffOptions) (*Diff, error) {
var diffPtr *C.git_diff
var oldPtr, newPtr *C.git_tree
if oldTree != nil {
oldPtr = oldTree.cast_ptr
}
if newTree != nil {
newPtr = newTree.cast_ptr
}
cpathspec := C.git_strarray{}
var copts *C.git_diff_options
var notifyData *diffNotifyData
if opts != nil {
notifyData = &diffNotifyData{
Callback: opts.NotifyCallback,
}
if opts.Pathspec != nil {
cpathspec.count = C.size_t(len(opts.Pathspec))
cpathspec.strings = makeCStringsFromStrings(opts.Pathspec)
defer freeStrarray(&cpathspec)
}
copts = &C.git_diff_options{
version: C.GIT_DIFF_OPTIONS_VERSION,
flags: C.uint32_t(opts.Flags),
ignore_submodules: C.git_submodule_ignore_t(opts.IgnoreSubmodules),
pathspec: cpathspec,
context_lines: C.uint16_t(opts.ContextLines),
interhunk_lines: C.uint16_t(opts.InterhunkLines),
id_abbrev: C.uint16_t(opts.IdAbbrev),
max_size: C.git_off_t(opts.MaxSize),
}
if opts.NotifyCallback != nil {
C._go_git_setup_diff_notify_callbacks(copts)
copts.notify_payload = unsafe.Pointer(notifyData)
}
}
ecode := C.git_diff_tree_to_tree(&diffPtr, v.ptr, oldPtr, newPtr, copts)
if ecode < 0 {
return nil, MakeGitError(ecode)
}
if notifyData != nil && notifyData.Diff != nil {
return notifyData.Diff, nil
}
return newDiffFromC(diffPtr), nil
}
示例7: SetPushRefspecs
func (o *Remote) SetPushRefspecs(refspecs []string) error {
crefspecs := C.git_strarray{}
crefspecs.count = C.size_t(len(refspecs))
crefspecs.strings = makeCStringsFromStrings(refspecs)
defer freeStrarray(&crefspecs)
runtime.LockOSThread()
defer runtime.UnlockOSThread()
ret := C.git_remote_set_push_refspecs(o.ptr, &crefspecs)
if ret < 0 {
return MakeGitError(ret)
}
return nil
}
示例8: Push
func (o *Remote) Push(refspecs []string, opts *PushOptions) error {
crefspecs := C.git_strarray{}
crefspecs.count = C.size_t(len(refspecs))
crefspecs.strings = makeCStringsFromStrings(refspecs)
defer freeStrarray(&crefspecs)
var coptions C.git_push_options
populatePushOptions(&coptions, opts)
defer untrackCalbacksPayload(&coptions.callbacks)
runtime.LockOSThread()
defer runtime.UnlockOSThread()
ret := C.git_remote_push(o.ptr, &crefspecs, &coptions)
if ret < 0 {
return MakeGitError(ret)
}
return nil
}
示例9: toC
func (opts *StatusOptions) toC() *C.git_status_options {
if opts == nil {
return nil
}
cpathspec := C.git_strarray{}
if opts.Pathspec != nil {
cpathspec.count = C.size_t(len(opts.Pathspec))
cpathspec.strings = makeCStringsFromStrings(opts.Pathspec)
defer freeStrarray(&cpathspec)
}
copts := &C.git_status_options{
version: C.GIT_STATUS_OPTIONS_VERSION,
show: C.git_status_show_t(opts.Show),
flags: C.uint(opts.Flags),
pathspec: cpathspec,
}
return copts
}
示例10: Push
func (o *Remote) Push(refspecs []string, opts *PushOptions) error {
crefspecs := C.git_strarray{}
crefspecs.count = C.size_t(len(refspecs))
crefspecs.strings = makeCStringsFromStrings(refspecs)
defer freeStrarray(&crefspecs)
coptions := (*C.git_push_options)(C.calloc(1, C.size_t(unsafe.Sizeof(C.git_push_options{}))))
defer C.free(unsafe.Pointer(coptions))
populatePushOptions(coptions, opts)
defer untrackCalbacksPayload(&coptions.callbacks)
runtime.LockOSThread()
defer runtime.UnlockOSThread()
ret := C.git_remote_push(o.ptr, &crefspecs, coptions)
if ret < 0 {
return MakeGitError(ret)
}
return nil
}
示例11: Push
func (o *Remote) Push(refspecs []string, opts *PushOptions, sig *Signature, msg string) error {
var csig *C.git_signature = nil
if sig != nil {
csig, err := sig.toC()
if err != nil {
return err
}
defer C.git_signature_free(csig)
}
var cmsg *C.char
if msg == "" {
cmsg = nil
} else {
cmsg = C.CString(msg)
defer C.free(unsafe.Pointer(cmsg))
}
var copts C.git_push_options
C.git_push_init_options(&copts, C.GIT_PUSH_OPTIONS_VERSION)
if opts != nil {
copts.pb_parallelism = C.uint(opts.PbParallelism)
}
crefspecs := C.git_strarray{}
crefspecs.count = C.size_t(len(refspecs))
crefspecs.strings = makeCStringsFromStrings(refspecs)
defer freeStrarray(&crefspecs)
runtime.LockOSThread()
defer runtime.UnlockOSThread()
ret := C.git_remote_push(o.ptr, &crefspecs, &copts, csig, cmsg)
if ret < 0 {
return MakeGitError(ret)
}
return nil
}
示例12: StatusList
func (v *Repository) StatusList(opts *StatusOptions) (*StatusList, error) {
var ptr *C.git_status_list
var copts *C.git_status_options
if opts != nil {
cpathspec := C.git_strarray{}
if opts.Pathspec != nil {
cpathspec.count = C.size_t(len(opts.Pathspec))
cpathspec.strings = makeCStringsFromStrings(opts.Pathspec)
defer freeStrarray(&cpathspec)
}
copts = &C.git_status_options{
version: C.GIT_STATUS_OPTIONS_VERSION,
show: C.git_status_show_t(opts.Show),
flags: C.uint(opts.Flags),
pathspec: cpathspec,
}
} else {
copts = &C.git_status_options{}
ret := C.git_status_init_options(copts, C.GIT_STATUS_OPTIONS_VERSION)
if ret < 0 {
return nil, MakeGitError(ret)
}
}
runtime.LockOSThread()
defer runtime.UnlockOSThread()
ret := C.git_status_list_new(&ptr, v.ptr, copts)
if ret < 0 {
return nil, MakeGitError(ret)
}
return newStatusListFromC(ptr), nil
}