add ByIndex, reorder to match other files
This commit is contained in:
parent
39d825a2a8
commit
37ccc4c00d
26
status.go
26
status.go
|
@ -27,16 +27,24 @@ const (
|
||||||
StatusIgnored = C.GIT_STATUS_IGNORED
|
StatusIgnored = C.GIT_STATUS_IGNORED
|
||||||
)
|
)
|
||||||
|
|
||||||
type StatusList struct {
|
|
||||||
ptr *C.git_status_list
|
|
||||||
}
|
|
||||||
|
|
||||||
type StatusEntry struct {
|
type StatusEntry struct {
|
||||||
Status Status
|
Status Status
|
||||||
HeadToIndex DiffDelta
|
HeadToIndex DiffDelta
|
||||||
IndexToWorkdir DiffDelta
|
IndexToWorkdir DiffDelta
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func statusEntryFromC(statusEntry *C.git_status_entry) StatusEntry {
|
||||||
|
return StatusEntry {
|
||||||
|
Status: Status(statusEntry.status),
|
||||||
|
HeadToIndex: diffDeltaFromC(statusEntry.head_to_index),
|
||||||
|
IndexToWorkdir: diffDeltaFromC(statusEntry.index_to_workdir),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type StatusList struct {
|
||||||
|
ptr *C.git_status_list
|
||||||
|
}
|
||||||
|
|
||||||
func newStatusListFromC(ptr *C.git_status_list) *StatusList {
|
func newStatusListFromC(ptr *C.git_status_list) *StatusList {
|
||||||
if ptr == nil {
|
if ptr == nil {
|
||||||
return nil
|
return nil
|
||||||
|
@ -60,10 +68,10 @@ func (statusList *StatusList) Free() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func statusEntryFromC(statusEntry *C.git_status_entry) StatusEntry {
|
func (statusList *StatusList) ByIndex(index int) (StatusEntry, error) {
|
||||||
return StatusEntry {
|
if statusList.ptr == nil {
|
||||||
Status: Status(statusEntry.status),
|
return StatusEntry{}, ErrInvalid
|
||||||
HeadToIndex: diffDeltaFromC(statusEntry.head_to_index),
|
|
||||||
IndexToWorkdir: diffDeltaFromC(statusEntry.index_to_workdir),
|
|
||||||
}
|
}
|
||||||
|
ptr := C.git_status_byindex(statusList.ptr, C.size_t(index))
|
||||||
|
return statusEntryFromC(ptr), nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue