diff options
| author | Carlos Martín Nieto <[email protected]> | 2015-04-27 23:29:49 +0200 |
|---|---|---|
| committer | Carlos Martín Nieto <[email protected]> | 2015-04-27 23:29:49 +0200 |
| commit | f7781c0e0004f76833c6be93409320b5c143e0c8 (patch) | |
| tree | 791b5f551780a5fc963316dac4976780def878c3 /diff.go | |
| parent | 9538c7f750dafaf3752e04b1c1747d7984ca31d0 (diff) | |
| parent | b3e7304abf6f0c4ef50e973acb220c40a5ddac86 (diff) | |
Merge pull request #179 from schani/master
Additions
Diffstat (limited to 'diff.go')
| -rw-r--r-- | diff.go | 50 |
1 files changed, 50 insertions, 0 deletions
@@ -595,3 +595,53 @@ func (v *Repository) DiffTreeToWorkdir(oldTree *Tree, opts *DiffOptions) (*Diff, } return newDiffFromC(diffPtr), nil } + +func (v *Repository) DiffTreeToWorkdirWithIndex(oldTree *Tree, opts *DiffOptions) (*Diff, error) { + var diffPtr *C.git_diff + var oldPtr *C.git_tree + + if oldTree != nil { + oldPtr = oldTree.cast_ptr + } + + copts, notifyData := diffOptionsToC(opts) + defer freeDiffOptions(copts) + + runtime.LockOSThread() + defer runtime.UnlockOSThread() + + ecode := C.git_diff_tree_to_workdir_with_index(&diffPtr, v.ptr, oldPtr, copts) + if ecode < 0 { + return nil, MakeGitError(ecode) + } + + if notifyData != nil && notifyData.Diff != nil { + return notifyData.Diff, nil + } + return newDiffFromC(diffPtr), nil +} + +func (v *Repository) DiffIndexToWorkdir(index *Index, opts *DiffOptions) (*Diff, error) { + var diffPtr *C.git_diff + var indexPtr *C.git_index + + if index != nil { + indexPtr = index.ptr + } + + copts, notifyData := diffOptionsToC(opts) + defer freeDiffOptions(copts) + + runtime.LockOSThread() + defer runtime.UnlockOSThread() + + ecode := C.git_diff_index_to_workdir(&diffPtr, v.ptr, indexPtr, copts) + if ecode < 0 { + return nil, MakeGitError(ecode) + } + + if notifyData != nil && notifyData.Diff != nil { + return notifyData.Diff, nil + } + return newDiffFromC(diffPtr), nil +} |
