Add git_diff_merge #945

Open
ribeiromiranda wants to merge 1 commits from galgotech/git_diff_merge into main
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 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. // deprecated: You should use `Diff.Delta()` instead.
func (diff *Diff) GetDelta(index int) (DiffDelta, error) { func (diff *Diff) GetDelta(index int) (DiffDelta, error) {
return diff.Delta(index) return diff.Delta(index)