summaryrefslogtreecommitdiff
path: root/git.go
diff options
context:
space:
mode:
authorVicent Martí <[email protected]>2013-04-26 14:54:14 -0700
committerVicent Martí <[email protected]>2013-04-26 14:54:14 -0700
commitc9adbf05d77d17e9b6de0b9c674e2c1e61744bcc (patch)
tree76548b58bc3e7b71e6d1723cfbdeb66fc48fd988 /git.go
parent9822cc944e8c20061700ecd8b87aa9f5efbb9a40 (diff)
parentf1848e48b83d9a095944697e0bd56bf79e530f5e (diff)
Merge pull request #17 from Merovius/oid
Implement most of the oid_-functions as Methods
Diffstat (limited to 'git.go')
-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