package git

/*
#include <git2.h>
*/
import "C"
import (
	"runtime"
)

func (repo *Repository) DescendantOf(commit, ancestor *Oid) (bool, error) {
	runtime.LockOSThread()
	defer runtime.UnlockOSThread()

	ret := C.git_graph_descendant_of(repo.ptr, commit.toC(), ancestor.toC())
	if ret < 0 {
		return false, MakeGitError(ret)
	}

	return (ret > 0), nil
}

func (repo *Repository) AheadBehind(local, upstream *Oid) (ahead, behind int, err error) {
	runtime.LockOSThread()
	defer runtime.UnlockOSThread()

	var aheadT C.size_t
	var behindT C.size_t

	ret := C.git_graph_ahead_behind(&aheadT, &behindT, repo.ptr, local.toC(), upstream.toC())
	if ret < 0 {
		return 0, 0, MakeGitError(ret)
	}

	return int(aheadT), int(behindT), nil
}

package git

/*
#include <git2.h>
*/
import "C"
import (
	"runtime"
)

func (repo *Repository) GraphDescendantOf(commit, ancestor *Oid) (bool, error) {
	runtime.LockOSThread()
	defer runtime.UnlockOSThread()

	ret := C.git_graph_descendant_of(repo.ptr, commit.toC(), ancestor.toC())
	if ret < 0 {
		return false, MakeGitError(ret)
	}

	return (ret > 0), nil
}

func (repo *Repository) GraphAheadBehind(local, upstream *Oid) (ahead, behind int, err error) {
	runtime.LockOSThread()
	defer runtime.UnlockOSThread()

	var aheadT C.size_t
	var behindT C.size_t

	ret := C.git_graph_ahead_behind(&aheadT, &behindT, repo.ptr, local.toC(), upstream.toC())
	if ret < 0 {
		return 0, 0, MakeGitError(ret)
	}

	return int(aheadT), int(behindT), nil
}

--- 
+++ 
@@ -8,7 +8,7 @@
 	"runtime"
 )
 
-func (repo *Repository) GraphDescendantOf(commit, ancestor *Oid) (bool, error) {
+func (repo *Repository) DescendantOf(commit, ancestor *Oid) (bool, error) {
 	runtime.LockOSThread()
 	defer runtime.UnlockOSThread()
 
@@ -20,7 +20,7 @@
 	return (ret > 0), nil
 }
 
-func (repo *Repository) GraphAheadBehind(local, upstream *Oid) (ahead, behind int, err error) {
+func (repo *Repository) AheadBehind(local, upstream *Oid) (ahead, behind int, err error) {
 	runtime.LockOSThread()
 	defer runtime.UnlockOSThread()
 
Remove "Graph" prefix on method names
