summaryrefslogtreecommitdiff
path: root/branch.go
diff options
context:
space:
mode:
Diffstat (limited to 'branch.go')
-rw-r--r--branch.go41
1 files changed, 9 insertions, 32 deletions
diff --git a/branch.go b/branch.go
index 8cf73b6..d381c23 100644
--- a/branch.go
+++ b/branch.go
@@ -13,6 +13,7 @@ import (
type BranchType uint
const (
+ BranchAll BranchType = C.GIT_BRANCH_ALL
BranchLocal BranchType = C.GIT_BRANCH_LOCAL
BranchRemote BranchType = C.GIT_BRANCH_REMOTE
)
@@ -72,6 +73,10 @@ func (i *BranchIterator) ForEach(f BranchIteratorFunc) error {
}
}
+ if err != nil && IsErrorCode(err, ErrIterOver) {
+ return nil
+ }
+
return err
}
@@ -90,31 +95,17 @@ func (repo *Repository) NewBranchIterator(flags BranchType) (*BranchIterator, er
return newBranchIteratorFromC(repo, ptr), nil
}
-func (repo *Repository) CreateBranch(branchName string, target *Commit, force bool, signature *Signature, msg string) (*Branch, error) {
+func (repo *Repository) CreateBranch(branchName string, target *Commit, force bool) (*Branch, error) {
var ptr *C.git_reference
cBranchName := C.CString(branchName)
defer C.free(unsafe.Pointer(cBranchName))
cForce := cbool(force)
- cSignature, err := signature.toC()
- if err != nil {
- return nil, err
- }
- defer C.git_signature_free(cSignature)
-
- var cmsg *C.char
- if msg == "" {
- cmsg = nil
- } else {
- cmsg = C.CString(msg)
- defer C.free(unsafe.Pointer(cmsg))
- }
-
runtime.LockOSThread()
defer runtime.UnlockOSThread()
- ret := C.git_branch_create(&ptr, repo.ptr, cBranchName, target.cast_ptr, cForce, cSignature, cmsg)
+ ret := C.git_branch_create(&ptr, repo.ptr, cBranchName, target.cast_ptr, cForce)
if ret < 0 {
return nil, MakeGitError(ret)
}
@@ -132,30 +123,16 @@ func (b *Branch) Delete() error {
return nil
}
-func (b *Branch) Move(newBranchName string, force bool, signature *Signature, msg string) (*Branch, error) {
+func (b *Branch) Move(newBranchName string, force bool) (*Branch, error) {
var ptr *C.git_reference
cNewBranchName := C.CString(newBranchName)
defer C.free(unsafe.Pointer(cNewBranchName))
cForce := cbool(force)
- cSignature, err := signature.toC()
- if err != nil {
- return nil, err
- }
- defer C.git_signature_free(cSignature)
-
- var cmsg *C.char
- if msg == "" {
- cmsg = nil
- } else {
- cmsg = C.CString(msg)
- defer C.free(unsafe.Pointer(cmsg))
- }
-
runtime.LockOSThread()
defer runtime.UnlockOSThread()
- ret := C.git_branch_move(&ptr, b.Reference.ptr, cNewBranchName, cForce, cSignature, cmsg)
+ ret := C.git_branch_move(&ptr, b.Reference.ptr, cNewBranchName, cForce)
if ret < 0 {
return nil, MakeGitError(ret)
}