Add git_diff_merge

This commit is contained in:
André R. de Miranda 2023-01-25 13:05:17 -03:00
parent 4b14d29c20
commit aa70b9bd50
1 changed files with 14 additions and 0 deletions

14
diff.go
View File

@ -157,6 +157,20 @@ func (diff *Diff) Delta(index int) (DiffDelta, error) {
return ret, nil
}
func (diff *Diff) Merge(from *Diff) error {
if diff.ptr == nil {
return ErrInvalid
}
ret := C.git_diff_merge(diff.ptr, from.ptr)
if ret < 0 {
return MakeGitError(ret)
}
runtime.KeepAlive(diff)
runtime.KeepAlive(from)
return nil
}
// deprecated: You should use `Diff.Delta()` instead.
func (diff *Diff) GetDelta(index int) (DiffDelta, error) {
return diff.Delta(index)