fix msg handling to treat empty str as nil
This commit is contained in:
parent
b404c8b862
commit
d6332f9526
26
branch.go
26
branch.go
|
@ -23,7 +23,7 @@ type Branch struct {
|
||||||
Reference
|
Reference
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repo *Repository) CreateBranch(branchName string, target *Commit, force bool, signature *Signature, message string) (*Reference, error) {
|
func (repo *Repository) CreateBranch(branchName string, target *Commit, force bool, signature *Signature, msg string) (*Reference, error) {
|
||||||
|
|
||||||
ref := new(Reference)
|
ref := new(Reference)
|
||||||
cBranchName := C.CString(branchName)
|
cBranchName := C.CString(branchName)
|
||||||
|
@ -32,13 +32,18 @@ func (repo *Repository) CreateBranch(branchName string, target *Commit, force bo
|
||||||
cSignature := signature.toC()
|
cSignature := signature.toC()
|
||||||
defer C.git_signature_free(cSignature)
|
defer C.git_signature_free(cSignature)
|
||||||
|
|
||||||
cMessage := C.CString(message)
|
var cmsg *C.char
|
||||||
defer C.free(unsafe.Pointer(cMessage))
|
if msg == "" {
|
||||||
|
cmsg = nil
|
||||||
|
} else {
|
||||||
|
cmsg = C.CString(msg)
|
||||||
|
defer C.free(unsafe.Pointer(cmsg))
|
||||||
|
}
|
||||||
|
|
||||||
runtime.LockOSThread()
|
runtime.LockOSThread()
|
||||||
defer runtime.UnlockOSThread()
|
defer runtime.UnlockOSThread()
|
||||||
|
|
||||||
ret := C.git_branch_create(&ref.ptr, repo.ptr, cBranchName, target.ptr, cForce, cSignature, cMessage)
|
ret := C.git_branch_create(&ref.ptr, repo.ptr, cBranchName, target.ptr, cForce, cSignature, cmsg)
|
||||||
if ret < 0 {
|
if ret < 0 {
|
||||||
return nil, MakeGitError(ret)
|
return nil, MakeGitError(ret)
|
||||||
}
|
}
|
||||||
|
@ -56,7 +61,7 @@ func (b *Branch) Delete() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Branch) Move(newBranchName string, force bool, signature *Signature, message string) (*Branch, error) {
|
func (b *Branch) Move(newBranchName string, force bool, signature *Signature, msg string) (*Branch, error) {
|
||||||
newBranch := new(Branch)
|
newBranch := new(Branch)
|
||||||
cNewBranchName := C.CString(newBranchName)
|
cNewBranchName := C.CString(newBranchName)
|
||||||
cForce := cbool(force)
|
cForce := cbool(force)
|
||||||
|
@ -64,13 +69,18 @@ func (b *Branch) Move(newBranchName string, force bool, signature *Signature, me
|
||||||
cSignature := signature.toC()
|
cSignature := signature.toC()
|
||||||
defer C.git_signature_free(cSignature)
|
defer C.git_signature_free(cSignature)
|
||||||
|
|
||||||
cMessage := C.CString(message)
|
var cmsg *C.char
|
||||||
defer C.free(unsafe.Pointer(cMessage))
|
if msg == "" {
|
||||||
|
cmsg = nil
|
||||||
|
} else {
|
||||||
|
cmsg = C.CString(msg)
|
||||||
|
defer C.free(unsafe.Pointer(cmsg))
|
||||||
|
}
|
||||||
|
|
||||||
runtime.LockOSThread()
|
runtime.LockOSThread()
|
||||||
defer runtime.UnlockOSThread()
|
defer runtime.UnlockOSThread()
|
||||||
|
|
||||||
ret := C.git_branch_move(&newBranch.ptr, b.ptr, cNewBranchName, cForce, cSignature, cMessage)
|
ret := C.git_branch_move(&newBranch.ptr, b.ptr, cNewBranchName, cForce, cSignature, cmsg)
|
||||||
if ret < 0 {
|
if ret < 0 {
|
||||||
return nil, MakeGitError(ret)
|
return nil, MakeGitError(ret)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue