diff options
Diffstat (limited to 'patch.go')
| -rw-r--r-- | patch.go | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/patch.go b/patch.go new file mode 100644 index 0000000..561786e --- /dev/null +++ b/patch.go @@ -0,0 +1,37 @@ +package git + +/* +#include <git2.h> +*/ +import "C" +import ( + "runtime" +) + +type Patch struct { + ptr *C.git_patch +} + +func newPatch(ptr *C.git_patch) *Patch { + if ptr == nil { + return nil + } + + patch := &Patch{ + ptr: ptr, + } + + runtime.SetFinalizer(patch, (*Patch).Free) + return patch +} + +func (patch *Patch) Free() { + runtime.SetFinalizer(patch, nil) + C.git_patch_free(patch.ptr) +} + +func (patch *Patch) String() string { + var cptr *C.char + C.git_patch_to_str(&cptr, patch.ptr) + return C.GoString(cptr) +} |
