summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--repository.go6
-rw-r--r--status_test.go27
2 files changed, 30 insertions, 3 deletions
diff --git a/repository.go b/repository.go
index 90d71ff..83e1fab 100644
--- a/repository.go
+++ b/repository.go
@@ -121,17 +121,17 @@ func (v *Repository) Index() (*Index, error) {
func (v *Repository) StatusList() (*StatusList, error) {
var ptr *C.git_status_list
- var options *C.git_status_options
+ options := C.git_status_options{}
runtime.LockOSThread()
defer runtime.UnlockOSThread()
- ret := C.git_status_init_options(options, C.GIT_STATUS_OPTIONS_VERSION)
+ ret := C.git_status_init_options(&options, C.GIT_STATUS_OPTIONS_VERSION)
if ret < 0 {
return nil, MakeGitError(ret)
}
- ret = C.git_status_list_new(&ptr, v.ptr, options)
+ ret = C.git_status_list_new(&ptr, v.ptr, &options)
if ret < 0 {
return nil, MakeGitError(ret)
}
diff --git a/status_test.go b/status_test.go
new file mode 100644
index 0000000..0cc9de3
--- /dev/null
+++ b/status_test.go
@@ -0,0 +1,27 @@
+package git
+
+import (
+ "io/ioutil"
+ "os"
+ "path"
+ "testing"
+)
+
+func TestEntryCount(t *testing.T) {
+ repo := createTestRepo(t)
+ defer repo.Free()
+ defer os.RemoveAll(repo.Workdir())
+
+ err := ioutil.WriteFile(path.Join(path.Dir(repo.Path()), "hello.txt"), []byte("Hello, World"), 0644)
+ checkFatal(t, err)
+
+ statusList, err := repo.StatusList()
+ checkFatal(t, err)
+
+ entryCount, err := statusList.EntryCount()
+ checkFatal(t, err)
+
+ if entryCount != 1 {
+ t.Fatal("Incorrect number of status entries: ", entryCount)
+ }
+}