LockOSThread in CurrentOperationIndex for git error creation

This commit is contained in:
ezwiebel 2016-11-23 17:10:59 +11:00
parent a671e67ee8
commit 6118c9ba37
2 changed files with 5 additions and 23 deletions

View File

@ -145,16 +145,21 @@ func (r *Repository) OpenRebase(opts *RebaseOptions) (*Rebase, error) {
// OperationAt gets the rebase operation specified by the given index. // OperationAt gets the rebase operation specified by the given index.
func (rebase *Rebase) OperationAt(index uint) *RebaseOperation { func (rebase *Rebase) OperationAt(index uint) *RebaseOperation {
operation := C.git_rebase_operation_byindex(rebase.ptr, C.size_t(index)) operation := C.git_rebase_operation_byindex(rebase.ptr, C.size_t(index))
return newRebaseOperationFromC(operation) return newRebaseOperationFromC(operation)
} }
// CurrentOperationIndex gets the index of the rebase operation that is currently being applied. // CurrentOperationIndex gets the index of the rebase operation that is currently being applied.
// Returns an error if no rebase operation is currently applied. // Returns an error if no rebase operation is currently applied.
func (rebase *Rebase) CurrentOperationIndex() (uint, error) { func (rebase *Rebase) CurrentOperationIndex() (uint, error) {
runtime.LockOSThread()
defer runtime.UnlockOSThread()
operationIndex := int(C.git_rebase_operation_current(rebase.ptr)) operationIndex := int(C.git_rebase_operation_current(rebase.ptr))
if operationIndex == C.GIT_REBASE_NO_OPERATION { if operationIndex == C.GIT_REBASE_NO_OPERATION {
return 0, MakeGitError(C.GIT_REBASE_NO_OPERATION) return 0, MakeGitError(C.GIT_REBASE_NO_OPERATION)
} }
return uint(operationIndex), nil return uint(operationIndex), nil
} }

View File

@ -9,29 +9,6 @@ import (
// Tests // Tests
func TestDefaultRebaseOptions(t *testing.T) {
opts, err := DefaultRebaseOptions()
checkFatal(t, err)
if opts.Version != 1 {
t.Error("Expected opts Version to equal 1, got ", opts.Version)
}
if opts.Quiet != 0 {
t.Error("Expected opts Quiet to equal 1, got ", opts.Quiet)
}
if opts.InMemory != 0 {
t.Error("Expected opts InMemory to equal 1, got ", opts.InMemory)
}
if opts.RewriteNotesRef != "" {
t.Error("Expected opts RewriteNotesRef to equal 1, got ", opts.RewriteNotesRef)
}
copts := opts.toC()
if copts == nil {
t.Error("Copts should not be nil")
}
}
func TestRebaseAbort(t *testing.T) { func TestRebaseAbort(t *testing.T) {
// TEST DATA // TEST DATA