Implement most of the oid_-functions as Methods
This commit is contained in:
parent
9822cc944e
commit
f1848e48b8
28
git.go
28
git.go
|
@ -7,6 +7,7 @@ package git
|
||||||
*/
|
*/
|
||||||
import "C"
|
import "C"
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -67,6 +68,33 @@ func (oid *Oid) Bytes() []byte {
|
||||||
return oid.bytes[0:]
|
return oid.bytes[0:]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (oid *Oid) Cmp(oid2 *Oid) int {
|
||||||
|
return bytes.Compare(oid.bytes[:], oid2.bytes[:])
|
||||||
|
}
|
||||||
|
|
||||||
|
func (oid *Oid) Copy() *Oid {
|
||||||
|
ret := new(Oid)
|
||||||
|
copy(ret.bytes[:], oid.bytes[:])
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
func (oid *Oid) Equal(oid2 *Oid) bool {
|
||||||
|
return bytes.Equal(oid.bytes[:], oid2.bytes[:])
|
||||||
|
}
|
||||||
|
|
||||||
|
func (oid *Oid) IsZero() bool {
|
||||||
|
for _, a := range(oid.bytes) {
|
||||||
|
if a != '0' {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (oid *Oid) NCmp(oid2 *Oid, n uint) int {
|
||||||
|
return bytes.Compare(oid.bytes[:n], oid2.bytes[:n])
|
||||||
|
}
|
||||||
|
|
||||||
type GitError struct {
|
type GitError struct {
|
||||||
Message string
|
Message string
|
||||||
Code int
|
Code int
|
||||||
|
|
Loading…
Reference in New Issue