diff options
| author | Ben Navetta <[email protected]> | 2014-08-25 23:18:00 -0400 |
|---|---|---|
| committer | Ben Navetta <[email protected]> | 2014-08-25 23:18:00 -0400 |
| commit | 80997c6fa55da6a25c30dccab379e808d9f07b28 (patch) | |
| tree | edf2c583fd577e88ce77f5720bb523c666f3ba4b /status.go | |
| parent | 0059b26255190153337c3ce43c675606a044c1c1 (diff) | |
fix status list to handle null head_to_index in entries
Diffstat (limited to 'status.go')
| -rw-r--r-- | status.go | 16 |
1 files changed, 14 insertions, 2 deletions
@@ -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 } |
