Skip to content

Commit 03e10c5

Browse files
committed
Fix reference bug introduced with RebaseOptions implementation
1 parent adc3a4b commit 03e10c5

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

rebase.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,19 @@ func (ro *RebaseOptions) toC() *C.git_rebase_options {
8484
version: C.uint(ro.Version),
8585
quiet: C.int(ro.Quiet),
8686
inmemory: C.int(ro.InMemory),
87-
rewrite_notes_ref: C.CString(ro.RewriteNotesRef),
87+
rewrite_notes_ref: rewriteNotesRefToC(ro.RewriteNotesRef),
8888
merge_options: *ro.MergeOptions.toC(),
8989
checkout_options: *ro.CheckoutOptions.toC(),
9090
}
9191
}
9292

93+
func rewriteNotesRefToC(ref string) *C.char {
94+
if ref == "" {
95+
return nil
96+
}
97+
return C.CString(ref)
98+
}
99+
93100
// Rebase object wrapper for C pointer
94101
type Rebase struct {
95102
ptr *C.git_rebase

rebase_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,12 @@ func TestRebaseNoConflicts(t *testing.T) {
143143
err = rebase.Finish()
144144
checkFatal(t, err)
145145

146+
// Check no more rebase is in progress
147+
oRebase, err = repo.RebaseOpen(nil)
148+
if err == nil {
149+
t.Fatal("Did not expect to find a rebase in progress")
150+
}
151+
146152
// Check history is in correct order
147153
actualHistory, err := commitMsgsList(repo)
148154
checkFatal(t, err)

0 commit comments

Comments
 (0)