init a StatusEntry with an initializer that takes in a git_status_entry

This commit is contained in:
Jake Van Alstyne 🎩 2017-09-08 17:19:05 -06:00
parent 5f4043bb0e
commit d7154e6f40
2 changed files with 13 additions and 14 deletions

View File

@ -11,6 +11,18 @@ public struct StatusEntry {
public var status: Diff.Status public var status: Diff.Status
public var headToIndex: Diff.Delta? public var headToIndex: Diff.Delta?
public var indexToWorkDir: Diff.Delta? public var indexToWorkDir: Diff.Delta?
public init(from statusEntry: git_status_entry) {
self.status = Diff.Status(rawValue: statusEntry.status.rawValue)
if let htoi = statusEntry.head_to_index {
self.headToIndex = Diff.Delta(from: htoi.pointee)
}
if let itow = statusEntry.index_to_workdir {
self.indexToWorkDir = Diff.Delta(from: itow.pointee)
}
}
} }
public struct Diff { public struct Diff {

View File

@ -688,20 +688,7 @@ final public class Repository {
continue continue
} }
var headToIndex: Diff.Delta? = nil let statusEntry = StatusEntry(from: (s?.pointee)!)
var indexToWorkDir: Diff.Delta? = nil
let status = Diff.Status(rawValue: (s?.pointee.status.rawValue)!)
if let htoi = s?.pointee.head_to_index {
headToIndex = Diff.Delta(from: htoi.pointee)
}
if let itow = s?.pointee.index_to_workdir {
indexToWorkDir = Diff.Delta(from: itow.pointee)
}
let statusEntry = StatusEntry(status: status, headToIndex: headToIndex, indexToWorkDir: indexToWorkDir)
returnArray.append(statusEntry) returnArray.append(statusEntry)
} }