summaryrefslogtreecommitdiff
path: root/status.go
diff options
context:
space:
mode:
authorBen Navetta <[email protected]>2014-08-25 23:18:00 -0400
committerBen Navetta <[email protected]>2014-08-25 23:18:00 -0400
commit80997c6fa55da6a25c30dccab379e808d9f07b28 (patch)
treeedf2c583fd577e88ce77f5720bb523c666f3ba4b /status.go
parent0059b26255190153337c3ce43c675606a044c1c1 (diff)
fix status list to handle null head_to_index in entries
Diffstat (limited to 'status.go')
-rw-r--r--status.go16
1 files changed, 14 insertions, 2 deletions
diff --git a/status.go b/status.go
index f69cd14..09a06c4 100644
--- a/status.go
+++ b/status.go
@@ -35,10 +35,21 @@ type StatusEntry struct {
}
func statusEntryFromC(statusEntry *C.git_status_entry) StatusEntry {
+ var headToIndex DiffDelta = DiffDelta{}
+ var indexToWorkdir DiffDelta = DiffDelta{}
+
+ // Based on the libgit2 status example, head_to_index can be null in some cases
+ if statusEntry.head_to_index != nil {
+ headToIndex = diffDeltaFromC(statusEntry.head_to_index)
+ }
+ if statusEntry.index_to_workdir != nil {
+ indexToWorkdir = diffDeltaFromC(statusEntry.index_to_workdir)
+ }
+
return StatusEntry {
Status: Status(statusEntry.status),
- HeadToIndex: diffDeltaFromC(statusEntry.head_to_index),
- IndexToWorkdir: diffDeltaFromC(statusEntry.index_to_workdir),
+ HeadToIndex: headToIndex,
+ IndexToWorkdir: indexToWorkdir,
}
}
@@ -158,6 +169,7 @@ func (v *Repository) StatusList(opts *StatusOptions) (*StatusList, error) {
if ret < 0 {
return nil, MakeGitError(ret)
}
+
return newStatusListFromC(ptr), nil
}