Additions #179
38
commit.go
38
commit.go
|
@ -9,6 +9,7 @@ import "C"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Commit
|
// Commit
|
||||||
|
@ -70,3 +71,40 @@ func (c *Commit) ParentId(n uint) *Oid {
|
||||||
func (c *Commit) ParentCount() uint {
|
func (c *Commit) ParentCount() uint {
|
||||||
return uint(C.git_commit_parentcount(c.cast_ptr))
|
return uint(C.git_commit_parentcount(c.cast_ptr))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Commit) Amend(refname string, author, committer *Signature, message string, tree *Tree) (*Oid, error) {
|
||||||
|
var cref *C.char
|
||||||
|
if refname == "" {
|
||||||
|
cref = nil
|
||||||
|
} else {
|
||||||
|
cref = C.CString(refname)
|
||||||
|
defer C.free(unsafe.Pointer(cref))
|
||||||
|
}
|
||||||
|
|
||||||
|
cmsg := C.CString(message)
|
||||||
|
defer C.free(unsafe.Pointer(cmsg))
|
||||||
|
|
||||||
|
runtime.LockOSThread()
|
||||||
|
defer runtime.UnlockOSThread()
|
||||||
|
|
||||||
|
authorSig, err := author.toC()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer C.git_signature_free(authorSig)
|
||||||
|
|
||||||
|
committerSig, err := committer.toC()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer C.git_signature_free(committerSig)
|
||||||
|
|
||||||
|
oid := new(Oid)
|
||||||
|
|
||||||
|
cerr := C.git_commit_amend(oid.toC(), c.cast_ptr, cref, authorSig, committerSig, nil, cmsg, tree.cast_ptr)
|
||||||
|
if cerr < 0 {
|
||||||
|
return nil, MakeGitError(cerr)
|
||||||
|
}
|
||||||
|
|
||||||
|
return oid, nil
|
||||||
|
}
|
||||||
|
|
50
diff.go
50
diff.go
|
@ -595,3 +595,53 @@ func (v *Repository) DiffTreeToWorkdir(oldTree *Tree, opts *DiffOptions) (*Diff,
|
||||||
}
|
}
|
||||||
return newDiffFromC(diffPtr), nil
|
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
|
||||||
|
}
|
||||||
|
|
1
index.go
1
index.go
|
@ -287,6 +287,7 @@ func (v *Index) HasConflicts() bool {
|
||||||
return C.git_index_has_conflicts(v.ptr) != 0
|
return C.git_index_has_conflicts(v.ptr) != 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: this might return an error
|
||||||
func (v *Index) CleanupConflicts() {
|
func (v *Index) CleanupConflicts() {
|
||||||
C.git_index_conflict_cleanup(v.ptr)
|
C.git_index_conflict_cleanup(v.ptr)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue