summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--git.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/git.go b/git.go
index 68712d4..45806c2 100644
--- a/git.go
+++ b/git.go
@@ -7,6 +7,7 @@ package git
*/
import "C"
import (
+ "bytes"
"unsafe"
)
@@ -67,6 +68,33 @@ func (oid *Oid) Bytes() []byte {
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 {
Message string
Code int