diff options
| author | Axel Wagner <[email protected]> | 2013-04-26 21:12:27 +0200 |
|---|---|---|
| committer | Axel Wagner <[email protected]> | 2013-04-26 21:12:27 +0200 |
| commit | f1848e48b83d9a095944697e0bd56bf79e530f5e (patch) | |
| tree | 76548b58bc3e7b71e6d1723cfbdeb66fc48fd988 | |
| parent | 9822cc944e8c20061700ecd8b87aa9f5efbb9a40 (diff) | |
Implement most of the oid_-functions as Methods
| -rw-r--r-- | git.go | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -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 |
