MCPcopy Create free account
hub / github.com/libgit2/git2go / Ls

Method Ls

remote.go:1119–1165  ·  view source on GitHub ↗
(filterRefs ...string)

Source from the content-addressed store, hash-verified

1117}
1118
1119func (o *Remote) Ls(filterRefs ...string) ([]RemoteHead, error) {
1120
1121 var refs **C.git_remote_head
1122 var length C.size_t
1123
1124 runtime.LockOSThread()
1125 defer runtime.UnlockOSThread()
1126
1127 ret := C.git_remote_ls(&refs, &length, o.ptr)
1128 runtime.KeepAlive(o)
1129 if ret != 0 {
1130 return nil, MakeGitError(ret)
1131 }
1132
1133 size := int(length)
1134
1135 if size == 0 {
1136 return make([]RemoteHead, 0), nil
1137 }
1138
1139 hdr := reflect.SliceHeader{
1140 Data: uintptr(unsafe.Pointer(refs)),
1141 Len: size,
1142 Cap: size,
1143 }
1144
1145 goSlice := *(*[]*C.git_remote_head)(unsafe.Pointer(&hdr))
1146
1147 var heads []RemoteHead
1148
1149 for _, s := range goSlice {
1150 head := newRemoteHeadFromC(s)
1151
1152 if len(filterRefs) > 0 {
1153 for _, r := range filterRefs {
1154 if strings.Contains(head.Name, r) {
1155 heads = append(heads, head)
1156 break
1157 }
1158 }
1159 } else {
1160 heads = append(heads, head)
1161 }
1162 }
1163
1164 return heads, nil
1165}
1166
1167func (o *Remote) Push(refspecs []string, opts *PushOptions) error {
1168 crefspecs := C.git_strarray{

Callers 4

TestTransportFunction · 0.80
TestRemoteLsFunction · 0.80
TestRemoteLsFilteringFunction · 0.80
TestRemoteSSHFunction · 0.80

Calls 2

MakeGitErrorFunction · 0.85
newRemoteHeadFromCFunction · 0.85

Tested by 4

TestTransportFunction · 0.64
TestRemoteLsFunction · 0.64
TestRemoteLsFilteringFunction · 0.64
TestRemoteSSHFunction · 0.64