Merge remote-tracking branch 'origin/master' into actions

This commit is contained in:
lhchavez 2020-02-13 02:50:31 +00:00
commit 150a8c6016
16 changed files with 131 additions and 30 deletions

View File

@ -1,10 +1,9 @@
language: go
go:
- 1.7
- 1.8
- 1.9
- "1.10"
- "1.11"
- "1.12"
- "1.13"
- tip
script: make test-static

View File

@ -2,7 +2,7 @@ default: test
test: build-libgit2
go run script/check-MakeGitError-thread-lock.go
go test ./...
go test --count=1 ./...
install: build-libgit2
go install ./...
@ -15,4 +15,4 @@ install-static: build-libgit2
test-static: build-libgit2
go run script/check-MakeGitError-thread-lock.go
go test --tags "static" ./...
go test --count=1 --tags "static" ./...

View File

@ -2,6 +2,9 @@ package git
/*
#include <git2.h>
#include <git2/sys/cred.h>
git_credtype_t _go_git_cred_credtype(git_cred *cred);
*/
import "C"
import "unsafe"
@ -27,7 +30,7 @@ func (o *Cred) HasUsername() bool {
}
func (o *Cred) Type() CredType {
return (CredType)(o.ptr.credtype)
return (CredType)(C._go_git_cred_credtype(o.ptr))
}
func credFromC(ptr *C.git_cred) *Cred {

33
delta_string.go Normal file
View File

@ -0,0 +1,33 @@
// Code generated by "stringer -type Delta -trimprefix Delta -tags static"; DO NOT EDIT.
package git
import "strconv"
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[DeltaUnmodified-0]
_ = x[DeltaAdded-1]
_ = x[DeltaDeleted-2]
_ = x[DeltaModified-3]
_ = x[DeltaRenamed-4]
_ = x[DeltaCopied-5]
_ = x[DeltaIgnored-6]
_ = x[DeltaUntracked-7]
_ = x[DeltaTypeChange-8]
_ = x[DeltaUnreadable-9]
_ = x[DeltaConflicted-10]
}
const _Delta_name = "UnmodifiedAddedDeletedModifiedRenamedCopiedIgnoredUntrackedTypeChangeUnreadableConflicted"
var _Delta_index = [...]uint8{0, 10, 15, 22, 30, 37, 43, 50, 59, 69, 79, 89}
func (i Delta) String() string {
if i < 0 || i >= Delta(len(_Delta_index)-1) {
return "Delta(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _Delta_name[_Delta_index[i]:_Delta_index[i+1]]
}

View File

@ -39,6 +39,8 @@ const (
DeltaConflicted Delta = C.GIT_DELTA_CONFLICTED
)
//go:generate stringer -type Delta -trimprefix Delta -tags static
type DiffLineType int
const (
@ -54,6 +56,8 @@ const (
DiffLineBinary DiffLineType = C.GIT_DIFF_LINE_BINARY
)
//go:generate stringer -type DiffLineType -trimprefix DiffLine -tags static
type DiffFile struct {
Path string
Oid *Oid
@ -284,7 +288,7 @@ type diffForEachData struct {
Error error
}
type DiffForEachFileCallback func(DiffDelta, float64) (DiffForEachHunkCallback, error)
type DiffForEachFileCallback func(delta DiffDelta, progress float64) (DiffForEachHunkCallback, error)
type DiffDetail int

56
difflinetype_string.go Normal file
View File

@ -0,0 +1,56 @@
// Code generated by "stringer -type DiffLineType -trimprefix DiffLine -tags static"; DO NOT EDIT.
package git
import "strconv"
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[DiffLineContext-32]
_ = x[DiffLineAddition-43]
_ = x[DiffLineDeletion-45]
_ = x[DiffLineContextEOFNL-61]
_ = x[DiffLineAddEOFNL-62]
_ = x[DiffLineDelEOFNL-60]
_ = x[DiffLineFileHdr-70]
_ = x[DiffLineHunkHdr-72]
_ = x[DiffLineBinary-66]
}
const (
_DiffLineType_name_0 = "Context"
_DiffLineType_name_1 = "Addition"
_DiffLineType_name_2 = "Deletion"
_DiffLineType_name_3 = "DelEOFNLContextEOFNLAddEOFNL"
_DiffLineType_name_4 = "Binary"
_DiffLineType_name_5 = "FileHdr"
_DiffLineType_name_6 = "HunkHdr"
)
var (
_DiffLineType_index_3 = [...]uint8{0, 8, 20, 28}
)
func (i DiffLineType) String() string {
switch {
case i == 32:
return _DiffLineType_name_0
case i == 43:
return _DiffLineType_name_1
case i == 45:
return _DiffLineType_name_2
case 60 <= i && i <= 62:
i -= 60
return _DiffLineType_name_3[_DiffLineType_index_3[i]:_DiffLineType_index_3[i+1]]
case i == 66:
return _DiffLineType_name_4
case i == 70:
return _DiffLineType_name_5
case i == 72:
return _DiffLineType_name_6
default:
return "DiffLineType(" + strconv.FormatInt(int64(i), 10) + ")"
}
}

View File

@ -6,8 +6,8 @@ package git
#include <git2.h>
#cgo pkg-config: libgit2
#if LIBGIT2_VER_MAJOR != 0 || LIBGIT2_VER_MINOR != 27
# error "Invalid libgit2 version; this git2go supports libgit2 v0.27"
#if LIBGIT2_VER_MAJOR != 0 || LIBGIT2_VER_MINOR != 28
# error "Invalid libgit2 version; this git2go supports libgit2 v0.28"
#endif
*/

2
go.mod
View File

@ -1 +1,3 @@
module github.com/libgit2/git2go
go 1.13

View File

@ -132,7 +132,7 @@ func (mo *MergeOptions) toC() *C.git_merge_options {
}
return &C.git_merge_options{
version: C.uint(mo.Version),
flags: C.git_merge_flag_t(mo.TreeFlags),
flags: C.uint32_t(mo.TreeFlags),
rename_threshold: C.uint(mo.RenameThreshold),
target_limit: C.uint(mo.TargetLimit),
file_favor: C.git_merge_file_favor_t(mo.FileFavor),
@ -394,7 +394,7 @@ func populateCMergeFileOptions(c *C.git_merge_file_options, options MergeFileOpt
c.our_label = C.CString(options.OurLabel)
c.their_label = C.CString(options.TheirLabel)
c.favor = C.git_merge_file_favor_t(options.Favor)
c.flags = C.git_merge_file_flag_t(options.Flags)
c.flags = C.uint32_t(options.Flags)
c.marker_size = C.ushort(options.MarkerSize)
}

2
odb.go
View File

@ -221,7 +221,7 @@ func (v *Odb) NewWriteStream(size int64, otype ObjectType) (*OdbWriteStream, err
runtime.LockOSThread()
defer runtime.UnlockOSThread()
ret := C.git_odb_open_wstream(&stream.ptr, v.ptr, C.git_off_t(size), C.git_object_t(otype))
ret := C.git_odb_open_wstream(&stream.ptr, v.ptr, C.git_object_size_t(size), C.git_object_t(otype))
runtime.KeepAlive(v)
if ret < 0 {
return nil, MakeGitError(ret)

View File

@ -2,7 +2,7 @@
set -ex
ROOT="$(cd "$0/../.." && echo "${PWD}")"
ROOT="$(cd "$(dirname "$0")/.." && echo "${PWD}")"
BUILD_PATH="${ROOT}/static-build"
VENDORED_PATH="${ROOT}/vendor/libgit2"

View File

@ -171,7 +171,7 @@ func (opts *StashApplyOptions) toC() (
optsC = &C.git_stash_apply_options{
version: C.GIT_STASH_APPLY_OPTIONS_VERSION,
flags: C.git_stash_apply_flags(opts.Flags),
flags: C.uint32_t(opts.Flags),
}
populateCheckoutOpts(&optsC.checkout_options, &opts.CheckoutOptions)
if opts.ProgressCallback != nil {

12
tag.go
View File

@ -21,26 +21,26 @@ func (t *Tag) AsObject() *Object {
return &t.Object
}
func (t Tag) Message() string {
func (t *Tag) Message() string {
ret := C.GoString(C.git_tag_message(t.cast_ptr))
runtime.KeepAlive(t)
return ret
}
func (t Tag) Name() string {
func (t *Tag) Name() string {
ret := C.GoString(C.git_tag_name(t.cast_ptr))
runtime.KeepAlive(t)
return ret
}
func (t Tag) Tagger() *Signature {
func (t *Tag) Tagger() *Signature {
cast_ptr := C.git_tag_tagger(t.cast_ptr)
ret := newSignatureFromC(cast_ptr)
runtime.KeepAlive(t)
return ret
}
func (t Tag) Target() *Object {
func (t *Tag) Target() *Object {
var ptr *C.git_object
ret := C.git_tag_target(&ptr, t.cast_ptr)
runtime.KeepAlive(t)
@ -51,13 +51,13 @@ func (t Tag) Target() *Object {
return allocObject(ptr, t.repo)
}
func (t Tag) TargetId() *Oid {
func (t *Tag) TargetId() *Oid {
ret := newOidFromC(C.git_tag_target_id(t.cast_ptr))
runtime.KeepAlive(t)
return ret
}
func (t Tag) TargetType() ObjectType {
func (t *Tag) TargetType() ObjectType {
ret := ObjectType(C.git_tag_target_type(t.cast_ptr))
runtime.KeepAlive(t)
return ret

15
tree.go
View File

@ -47,7 +47,7 @@ func newTreeEntry(entry *C.git_tree_entry) *TreeEntry {
}
}
func (t Tree) EntryByName(filename string) *TreeEntry {
func (t *Tree) EntryByName(filename string) *TreeEntry {
cname := C.CString(filename)
defer C.free(unsafe.Pointer(cname))
@ -67,7 +67,7 @@ func (t Tree) EntryByName(filename string) *TreeEntry {
// free it, but you must not use it after the Tree is freed.
//
// Warning: this must examine every entry in the tree, so it is not fast.
func (t Tree) EntryById(id *Oid) *TreeEntry {
func (t *Tree) EntryById(id *Oid) *TreeEntry {
runtime.LockOSThread()
defer runtime.UnlockOSThread()
@ -84,7 +84,7 @@ func (t Tree) EntryById(id *Oid) *TreeEntry {
// EntryByPath looks up an entry by its full path, recursing into
// deeper trees if necessary (i.e. if there are slashes in the path)
func (t Tree) EntryByPath(path string) (*TreeEntry, error) {
func (t *Tree) EntryByPath(path string) (*TreeEntry, error) {
cpath := C.CString(path)
defer C.free(unsafe.Pointer(cpath))
var entry *C.git_tree_entry
@ -102,7 +102,7 @@ func (t Tree) EntryByPath(path string) (*TreeEntry, error) {
return newTreeEntry(entry), nil
}
func (t Tree) EntryByIndex(index uint64) *TreeEntry {
func (t *Tree) EntryByIndex(index uint64) *TreeEntry {
entry := C.git_tree_entry_byindex(t.cast_ptr, C.size_t(index))
if entry == nil {
return nil
@ -113,7 +113,7 @@ func (t Tree) EntryByIndex(index uint64) *TreeEntry {
return goEntry
}
func (t Tree) EntryCount() uint64 {
func (t *Tree) EntryCount() uint64 {
num := C.git_tree_entrycount(t.cast_ptr)
runtime.KeepAlive(t)
return uint64(num)
@ -122,9 +122,8 @@ func (t Tree) EntryCount() uint64 {
type TreeWalkCallback func(string, *TreeEntry) int
//export CallbackGitTreeWalk
func CallbackGitTreeWalk(_root *C.char, _entry unsafe.Pointer, ptr unsafe.Pointer) C.int {
func CallbackGitTreeWalk(_root *C.char, entry *C.git_tree_entry, ptr unsafe.Pointer) C.int {
root := C.GoString(_root)
entry := (*C.git_tree_entry)(_entry)
if callback, ok := pointerHandles.Get(ptr).(TreeWalkCallback); ok {
return C.int(callback(root, newTreeEntry(entry)))
@ -133,7 +132,7 @@ func CallbackGitTreeWalk(_root *C.char, _entry unsafe.Pointer, ptr unsafe.Pointe
}
}
func (t Tree) Walk(callback TreeWalkCallback) error {
func (t *Tree) Walk(callback TreeWalkCallback) error {
runtime.LockOSThread()
defer runtime.UnlockOSThread()

2
vendor/libgit2 vendored

@ -1 +1 @@
Subproject commit 08cfa43d0e1a9214a2f1239593686078e75e5636
Subproject commit 6777db8e8343014d57c41b335e0c60af44d4e9f2

View File

@ -2,6 +2,7 @@
#include <git2.h>
#include <git2/sys/odb_backend.h>
#include <git2/sys/refdb_backend.h>
#include <git2/sys/cred.h>
typedef int (*gogit_submodule_cbk)(git_submodule *sm, const char *name, void *payload);
@ -180,4 +181,8 @@ void _go_git_writestream_free(git_writestream *stream)
stream->free(stream);
}
git_credtype_t _go_git_cred_credtype(git_cred *cred) {
return cred->credtype;
}
/* EOF */