Esempio n. 1
0
func (repo *Repository) Head() (*Reference, error) {
	ref := new(Reference)
	ecode := C.git_repository_head(&ref.git_reference, repo.git_repository)
	if ecode != git_SUCCESS {
		return nil, gitError()
	}
	return ref, nil
}
Esempio n. 2
0
// Returns the Commit that is the current HEAD of the repository.
// If orphaned is true the Commit is
func (r Repository) Head() (head *Reference, orphaned bool, err error) {
	ref := new(Reference)
	if err := gitError(C.git_repository_head(&ref.ref, r.repo)); err != nil {
		if err.(*GitError).klass == err_EORPHANEDHEAD {
			orphaned = true
		} else {
			return nil, false, err
		}
	}
	// sucessfully got head ref
	return ref, orphaned, nil
}
Esempio n. 3
0
File: git.go Progetto: fsouza/gogit
// Head returns the commit at the head of the repository.
func (r *Repository) Head() (*Commit, error) {
	var reference *C.struct_git_reference
	if C.git_repository_head(&reference, r.repository) != C.GIT_OK {
		return nil, lastErr()
	}
	defer C.git_reference_free(reference)
	c := new(Commit)
	if C.git_commit_lookup(&c.commit, r.repository, C.git_reference_oid(reference)) != C.GIT_OK {
		return nil, lastErr()
	}
	return c, nil
}
Esempio n. 4
0
func (v *Repository) Head() (*Reference, error) {
	var ptr *C.git_reference

	runtime.LockOSThread()
	defer runtime.UnlockOSThread()

	ecode := C.git_repository_head(&ptr, v.ptr)
	if ecode < 0 {
		return nil, MakeGitError(ecode)
	}

	return newReferenceFromC(ptr, v), nil
}