gofmt
This commit is contained in:
parent
9cd1d129bc
commit
e504c9c021
10
checkout.go
10
checkout.go
|
@ -5,8 +5,8 @@ package git
|
||||||
*/
|
*/
|
||||||
import "C"
|
import "C"
|
||||||
import (
|
import (
|
||||||
"runtime"
|
|
||||||
"os"
|
"os"
|
||||||
|
"runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CheckoutStrategy uint
|
type CheckoutStrategy uint
|
||||||
|
@ -32,10 +32,10 @@ const (
|
||||||
|
|
||||||
type CheckoutOpts struct {
|
type CheckoutOpts struct {
|
||||||
Strategy CheckoutStrategy // Default will be a dry run
|
Strategy CheckoutStrategy // Default will be a dry run
|
||||||
DisableFilters bool // Don't apply filters like CRLF conversion
|
DisableFilters bool // Don't apply filters like CRLF conversion
|
||||||
DirMode os.FileMode // Default is 0755
|
DirMode os.FileMode // Default is 0755
|
||||||
FileMode os.FileMode // Default is 0644 or 0755 as dictated by blob
|
FileMode os.FileMode // Default is 0644 or 0755 as dictated by blob
|
||||||
FileOpenFlags int // Default is O_CREAT | O_TRUNC | O_WRONLY
|
FileOpenFlags int // Default is O_CREAT | O_TRUNC | O_WRONLY
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert the CheckoutOpts struct to the corresponding
|
// Convert the CheckoutOpts struct to the corresponding
|
||||||
|
|
|
@ -36,14 +36,14 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
type ConfigEntry struct {
|
type ConfigEntry struct {
|
||||||
Name string
|
Name string
|
||||||
Value string
|
Value string
|
||||||
Level ConfigLevel
|
Level ConfigLevel
|
||||||
}
|
}
|
||||||
|
|
||||||
func newConfigEntryFromC(centry *C.git_config_entry) *ConfigEntry {
|
func newConfigEntryFromC(centry *C.git_config_entry) *ConfigEntry {
|
||||||
return &ConfigEntry{
|
return &ConfigEntry{
|
||||||
Name: C.GoString(centry.name),
|
Name: C.GoString(centry.name),
|
||||||
Value: C.GoString(centry.value),
|
Value: C.GoString(centry.value),
|
||||||
Level: ConfigLevel(centry.level),
|
Level: ConfigLevel(centry.level),
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,6 @@ func (c *Config) AddFile(path string, level ConfigLevel, force bool) error {
|
||||||
runtime.LockOSThread()
|
runtime.LockOSThread()
|
||||||
defer runtime.UnlockOSThread()
|
defer runtime.UnlockOSThread()
|
||||||
|
|
||||||
|
|
||||||
ret := C.git_config_add_file_ondisk(c.ptr, cpath, C.git_config_level_t(level), cbool(force))
|
ret := C.git_config_add_file_ondisk(c.ptr, cpath, C.git_config_level_t(level), cbool(force))
|
||||||
if ret < 0 {
|
if ret < 0 {
|
||||||
return MakeGitError(ret)
|
return MakeGitError(ret)
|
||||||
|
@ -131,7 +130,6 @@ func (c *Config) LookupString(name string) (string, error) {
|
||||||
return C.GoString(ptr), nil
|
return C.GoString(ptr), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (c *Config) LookupBool(name string) (bool, error) {
|
func (c *Config) LookupBool(name string) (bool, error) {
|
||||||
var out C.int
|
var out C.int
|
||||||
cname := C.CString(name)
|
cname := C.CString(name)
|
||||||
|
@ -374,4 +372,3 @@ func (iter *ConfigIterator) Free() {
|
||||||
runtime.SetFinalizer(iter, nil)
|
runtime.SetFinalizer(iter, nil)
|
||||||
C.free(unsafe.Pointer(iter.ptr))
|
C.free(unsafe.Pointer(iter.ptr))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ func (o *Cred) HasUsername() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *Cred) Type() CredType {
|
func (o *Cred) Type() CredType {
|
||||||
return (CredType)(o.ptr.credtype)
|
return CredType(o.ptr.credtype)
|
||||||
}
|
}
|
||||||
|
|
||||||
func credFromC(ptr *C.git_cred) *Cred {
|
func credFromC(ptr *C.git_cred) *Cred {
|
||||||
|
|
16
object.go
16
object.go
|
@ -10,12 +10,12 @@ import "runtime"
|
||||||
type ObjectType int
|
type ObjectType int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ObjectAny ObjectType = C.GIT_OBJ_ANY
|
ObjectAny ObjectType = C.GIT_OBJ_ANY
|
||||||
ObjectBad = C.GIT_OBJ_BAD
|
ObjectBad = C.GIT_OBJ_BAD
|
||||||
ObjectCommit = C.GIT_OBJ_COMMIT
|
ObjectCommit = C.GIT_OBJ_COMMIT
|
||||||
ObjectTree = C.GIT_OBJ_TREE
|
ObjectTree = C.GIT_OBJ_TREE
|
||||||
ObjectBlob = C.GIT_OBJ_BLOB
|
ObjectBlob = C.GIT_OBJ_BLOB
|
||||||
ObjectTag = C.GIT_OBJ_TAG
|
ObjectTag = C.GIT_OBJ_TAG
|
||||||
)
|
)
|
||||||
|
|
||||||
type Object interface {
|
type Object interface {
|
||||||
|
@ -28,8 +28,8 @@ type gitObject struct {
|
||||||
ptr *C.git_object
|
ptr *C.git_object
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t ObjectType) String() (string) {
|
func (t ObjectType) String() string {
|
||||||
switch (t) {
|
switch t {
|
||||||
case ObjectAny:
|
case ObjectAny:
|
||||||
return "Any"
|
return "Any"
|
||||||
case ObjectBad:
|
case ObjectBad:
|
||||||
|
|
12
odb.go
12
odb.go
|
@ -8,9 +8,9 @@ extern int _go_git_odb_foreach(git_odb *db, void *payload);
|
||||||
*/
|
*/
|
||||||
import "C"
|
import "C"
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Odb struct {
|
type Odb struct {
|
||||||
|
@ -63,9 +63,9 @@ func odbForEachCb(id *C.git_oid, payload unsafe.Pointer) int {
|
||||||
select {
|
select {
|
||||||
case ch <- oid:
|
case ch <- oid:
|
||||||
case <-ch:
|
case <-ch:
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
return 0;
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Odb) forEachWrap(ch chan *Oid) {
|
func (v *Odb) forEachWrap(ch chan *Oid) {
|
||||||
|
@ -88,7 +88,7 @@ func (v *Odb) Hash(data []byte, otype ObjectType) (oid *Oid, err error) {
|
||||||
runtime.LockOSThread()
|
runtime.LockOSThread()
|
||||||
defer runtime.UnlockOSThread()
|
defer runtime.UnlockOSThread()
|
||||||
|
|
||||||
ret := C.git_odb_hash(oid.toC(), ptr, C.size_t(header.Len), C.git_otype(otype));
|
ret := C.git_odb_hash(oid.toC(), ptr, C.size_t(header.Len), C.git_otype(otype))
|
||||||
if ret < 0 {
|
if ret < 0 {
|
||||||
err = MakeGitError(ret)
|
err = MakeGitError(ret)
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ func (object *OdbObject) Data() (data []byte) {
|
||||||
|
|
||||||
len := int(C.git_odb_object_size(object.ptr))
|
len := int(C.git_odb_object_size(object.ptr))
|
||||||
|
|
||||||
sliceHeader := (*reflect.SliceHeader)((unsafe.Pointer(&blob)))
|
sliceHeader := (*reflect.SliceHeader)(unsafe.Pointer(&blob))
|
||||||
sliceHeader.Cap = len
|
sliceHeader.Cap = len
|
||||||
sliceHeader.Len = len
|
sliceHeader.Len = len
|
||||||
sliceHeader.Data = uintptr(c_blob)
|
sliceHeader.Data = uintptr(c_blob)
|
||||||
|
@ -185,7 +185,7 @@ func (stream *OdbReadStream) Free() {
|
||||||
|
|
||||||
type OdbWriteStream struct {
|
type OdbWriteStream struct {
|
||||||
ptr *C.git_odb_stream
|
ptr *C.git_odb_stream
|
||||||
Id Oid
|
Id Oid
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write writes to the stream
|
// Write writes to the stream
|
||||||
|
|
|
@ -36,7 +36,7 @@ func TestOdbStream(t *testing.T) {
|
||||||
|
|
||||||
func TestOdbHash(t *testing.T) {
|
func TestOdbHash(t *testing.T) {
|
||||||
|
|
||||||
repo := createTestRepo(t)
|
repo := createTestRepo(t)
|
||||||
defer os.RemoveAll(repo.Workdir())
|
defer os.RemoveAll(repo.Workdir())
|
||||||
_, _ = seedTestRepo(t, repo)
|
_, _ = seedTestRepo(t, repo)
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ parent 66e1c476199ebcd3e304659992233132c5a52c6c
|
||||||
author John Doe <john@doe.com> 1390682018 +0000
|
author John Doe <john@doe.com> 1390682018 +0000
|
||||||
committer John Doe <john@doe.com> 1390682018 +0000
|
committer John Doe <john@doe.com> 1390682018 +0000
|
||||||
|
|
||||||
Initial commit.`;
|
Initial commit.`
|
||||||
|
|
||||||
oid, error := odb.Hash([]byte(str), ObjectCommit)
|
oid, error := odb.Hash([]byte(str), ObjectCommit)
|
||||||
checkFatal(t, error)
|
checkFatal(t, error)
|
||||||
|
|
|
@ -110,7 +110,7 @@ func (pb *Packbuilder) Written() uint32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
type packbuilderCbData struct {
|
type packbuilderCbData struct {
|
||||||
ch chan<- []byte
|
ch chan<- []byte
|
||||||
stop <-chan bool
|
stop <-chan bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ func packbuilderForEachCb(buf unsafe.Pointer, size C.size_t, payload unsafe.Poin
|
||||||
|
|
||||||
slice := C.GoBytes(buf, C.int(size))
|
slice := C.GoBytes(buf, C.int(size))
|
||||||
select {
|
select {
|
||||||
case <- stop:
|
case <-stop:
|
||||||
return -1
|
return -1
|
||||||
case ch <- slice:
|
case ch <- slice:
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@ func completionCallback(completion_type C.git_remote_completion_type, data unsaf
|
||||||
if callbacks.CompletionCallback == nil {
|
if callbacks.CompletionCallback == nil {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
return callbacks.CompletionCallback((RemoteCompletion)(completion_type))
|
return callbacks.CompletionCallback(RemoteCompletion(completion_type))
|
||||||
}
|
}
|
||||||
|
|
||||||
//export credentialsCallback
|
//export credentialsCallback
|
||||||
|
@ -92,7 +92,7 @@ func credentialsCallback(_cred **C.git_cred, _url *C.char, _username_from_url *C
|
||||||
}
|
}
|
||||||
url := C.GoString(_url)
|
url := C.GoString(_url)
|
||||||
username_from_url := C.GoString(_username_from_url)
|
username_from_url := C.GoString(_username_from_url)
|
||||||
ret, cred := callbacks.CredentialsCallback(url, username_from_url, (CredType)(allowed_types))
|
ret, cred := callbacks.CredentialsCallback(url, username_from_url, CredType(allowed_types))
|
||||||
*_cred = cred.ptr
|
*_cred = cred.ptr
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,9 +27,9 @@ int _go_git_opts_get_size_t(int opt, size_t *val)
|
||||||
*/
|
*/
|
||||||
import "C"
|
import "C"
|
||||||
import (
|
import (
|
||||||
|
"github.com/libgit2/git2go"
|
||||||
"runtime"
|
"runtime"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
"github.com/libgit2/git2go"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func MakeGitError(err C.int) error {
|
func MakeGitError(err C.int) error {
|
||||||
|
@ -71,7 +71,7 @@ func getSizet(opt C.int) (int, error) {
|
||||||
defer runtime.UnlockOSThread()
|
defer runtime.UnlockOSThread()
|
||||||
|
|
||||||
var val C.size_t
|
var val C.size_t
|
||||||
err := C._go_git_opts_get_size_t(opt, &val);
|
err := C._go_git_opts_get_size_t(opt, &val)
|
||||||
if err < 0 {
|
if err < 0 {
|
||||||
return 0, MakeGitError(err)
|
return 0, MakeGitError(err)
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ func setSizet(opt C.int, val int) error {
|
||||||
defer runtime.UnlockOSThread()
|
defer runtime.UnlockOSThread()
|
||||||
|
|
||||||
cval := C.size_t(val)
|
cval := C.size_t(val)
|
||||||
err := C._go_git_opts_set_size_t(opt, cval);
|
err := C._go_git_opts_set_size_t(opt, cval)
|
||||||
if err < 0 {
|
if err < 0 {
|
||||||
return MakeGitError(err)
|
return MakeGitError(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package settings
|
package settings
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
|
||||||
"runtime"
|
|
||||||
"github.com/libgit2/git2go"
|
"github.com/libgit2/git2go"
|
||||||
|
"runtime"
|
||||||
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
type pathPair struct {
|
type pathPair struct {
|
||||||
|
@ -13,9 +13,9 @@ type pathPair struct {
|
||||||
|
|
||||||
func TestSearchPath(t *testing.T) {
|
func TestSearchPath(t *testing.T) {
|
||||||
paths := []pathPair{
|
paths := []pathPair{
|
||||||
pathPair{git.ConfigLevelSystem, "/tmp/system"},
|
{git.ConfigLevelSystem, "/tmp/system"},
|
||||||
pathPair{git.ConfigLevelGlobal, "/tmp/global"},
|
{git.ConfigLevelGlobal, "/tmp/global"},
|
||||||
pathPair{git.ConfigLevelXDG, "/tmp/xdg"},
|
{git.ConfigLevelXDG, "/tmp/xdg"},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, pair := range paths {
|
for _, pair := range paths {
|
||||||
|
|
Loading…
Reference in New Issue