Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
b70973e5c7
2
blob.go
2
blob.go
|
@ -84,7 +84,7 @@ func (repo *Repository) CreateBlobFromChunks(hintPath string, callback BlobChunk
|
||||||
|
|
||||||
var chintPath *C.char = nil
|
var chintPath *C.char = nil
|
||||||
if len(hintPath) > 0 {
|
if len(hintPath) > 0 {
|
||||||
C.CString(hintPath)
|
chintPath = C.CString(hintPath)
|
||||||
defer C.free(unsafe.Pointer(chintPath))
|
defer C.free(unsafe.Pointer(chintPath))
|
||||||
}
|
}
|
||||||
oid := C.git_oid{}
|
oid := C.git_oid{}
|
||||||
|
|
15
odb.go
15
odb.go
|
@ -54,6 +54,21 @@ func (v *Odb) AddBackend(backend *OdbBackend, priority int) (err error) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (v *Odb) ReadHeader(oid *Oid) (uint64, ObjectType, error) {
|
||||||
|
runtime.LockOSThread()
|
||||||
|
defer runtime.UnlockOSThread()
|
||||||
|
|
||||||
|
var sz C.size_t
|
||||||
|
var cotype C.git_otype
|
||||||
|
|
||||||
|
ret := C.git_odb_read_header(&sz, &cotype, v.ptr, oid.toC())
|
||||||
|
if ret < 0 {
|
||||||
|
return 0, C.GIT_OBJ_BAD, MakeGitError(ret)
|
||||||
|
}
|
||||||
|
|
||||||
|
return uint64(sz), ObjectType(cotype), nil
|
||||||
|
}
|
||||||
|
|
||||||
func (v *Odb) Exists(oid *Oid) bool {
|
func (v *Odb) Exists(oid *Oid) bool {
|
||||||
ret := C.git_odb_exists(v.ptr, oid.toC())
|
ret := C.git_odb_exists(v.ptr, oid.toC())
|
||||||
return ret != 0
|
return ret != 0
|
||||||
|
|
28
odb_test.go
28
odb_test.go
|
@ -6,6 +6,34 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func TestOdbReadHeader(t *testing.T) {
|
||||||
|
repo := createTestRepo(t)
|
||||||
|
defer cleanupTestRepo(t, repo)
|
||||||
|
|
||||||
|
_, _ = seedTestRepo(t, repo)
|
||||||
|
odb, err := repo.Odb()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Odb: %v", err)
|
||||||
|
}
|
||||||
|
data := []byte("hello")
|
||||||
|
id, err := odb.Write(data, ObjectBlob)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("odb.Write: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
sz, typ, err := odb.ReadHeader(id)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("ReadHeader: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if sz != uint64(len(data)) {
|
||||||
|
t.Errorf("ReadHeader got size %d, want %d", sz, len(data))
|
||||||
|
}
|
||||||
|
if typ != ObjectBlob {
|
||||||
|
t.Errorf("ReadHeader got object type %s", typ)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestOdbStream(t *testing.T) {
|
func TestOdbStream(t *testing.T) {
|
||||||
repo := createTestRepo(t)
|
repo := createTestRepo(t)
|
||||||
defer cleanupTestRepo(t, repo)
|
defer cleanupTestRepo(t, repo)
|
||||||
|
|
|
@ -433,3 +433,24 @@ func (r *Repository) StateCleanup() error {
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
func (r *Repository) AddGitIgnoreRules(rules string) error {
|
||||||
|
runtime.LockOSThread()
|
||||||
|
defer runtime.UnlockOSThread()
|
||||||
|
|
||||||
|
crules := C.CString(rules)
|
||||||
|
defer C.free(unsafe.Pointer(crules))
|
||||||
|
if ret := C.git_ignore_add_rule(r.ptr, crules); ret < 0 {
|
||||||
|
return MakeGitError(ret)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *Repository) ClearGitIgnoreRules() error {
|
||||||
|
runtime.LockOSThread()
|
||||||
|
defer runtime.UnlockOSThread()
|
||||||
|
|
||||||
|
if ret := C.git_ignore_clear_internal_rules(r.ptr); ret < 0 {
|
||||||
|
return MakeGitError(ret)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
4
walk.go
4
walk.go
|
@ -194,6 +194,10 @@ func (v *RevWalk) Iterate(fun RevWalkIterator) (err error) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (v *RevWalk) SimplifyFirstParent() {
|
||||||
|
C.git_revwalk_simplify_first_parent(v.ptr)
|
||||||
|
}
|
||||||
|
|
||||||
func (v *RevWalk) Sorting(sm SortType) {
|
func (v *RevWalk) Sorting(sm SortType) {
|
||||||
C.git_revwalk_sorting(v.ptr, C.uint(sm))
|
C.git_revwalk_sorting(v.ptr, C.uint(sm))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue