Update to libgit2 d675982a153
There's been some changes to the checkout strategy, especially the SAFE_CREATE mode, which is now the RECREATE_MISSING flag, though that shouldn't be necessary to use in the general case. The largest changes come from the removal of the signture from ref-modifying functions/methods and the removal of the reflog string in all but those directly related to moving references.
This commit is contained in:
parent
050e6fbc49
commit
c4fce1a218
36
branch.go
36
branch.go
|
@ -90,30 +90,16 @@ func (repo *Repository) NewBranchIterator(flags BranchType) (*BranchIterator, er
|
||||||
return newBranchIteratorFromC(repo, ptr), nil
|
return newBranchIteratorFromC(repo, ptr), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repo *Repository) CreateBranch(branchName string, target *Commit, force bool, signature *Signature, msg string) (*Branch, error) {
|
func (repo *Repository) CreateBranch(branchName string, target *Commit, force bool) (*Branch, error) {
|
||||||
|
|
||||||
ref := new(Reference)
|
ref := new(Reference)
|
||||||
cBranchName := C.CString(branchName)
|
cBranchName := C.CString(branchName)
|
||||||
cForce := cbool(force)
|
cForce := cbool(force)
|
||||||
|
|
||||||
cSignature, err := signature.toC()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
defer C.git_signature_free(cSignature)
|
|
||||||
|
|
||||||
var cmsg *C.char
|
|
||||||
if msg == "" {
|
|
||||||
cmsg = nil
|
|
||||||
} else {
|
|
||||||
cmsg = C.CString(msg)
|
|
||||||
defer C.free(unsafe.Pointer(cmsg))
|
|
||||||
}
|
|
||||||
|
|
||||||
runtime.LockOSThread()
|
runtime.LockOSThread()
|
||||||
defer runtime.UnlockOSThread()
|
defer runtime.UnlockOSThread()
|
||||||
|
|
||||||
ret := C.git_branch_create(&ref.ptr, repo.ptr, cBranchName, target.cast_ptr, cForce, cSignature, cmsg)
|
ret := C.git_branch_create(&ref.ptr, repo.ptr, cBranchName, target.cast_ptr, cForce)
|
||||||
if ret < 0 {
|
if ret < 0 {
|
||||||
return nil, MakeGitError(ret)
|
return nil, MakeGitError(ret)
|
||||||
}
|
}
|
||||||
|
@ -131,29 +117,15 @@ func (b *Branch) Delete() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Branch) Move(newBranchName string, force bool, signature *Signature, msg string) (*Branch, error) {
|
func (b *Branch) Move(newBranchName string, force bool) (*Branch, error) {
|
||||||
var ptr *C.git_reference
|
var ptr *C.git_reference
|
||||||
cNewBranchName := C.CString(newBranchName)
|
cNewBranchName := C.CString(newBranchName)
|
||||||
cForce := cbool(force)
|
cForce := cbool(force)
|
||||||
|
|
||||||
cSignature, err := signature.toC()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
defer C.git_signature_free(cSignature)
|
|
||||||
|
|
||||||
var cmsg *C.char
|
|
||||||
if msg == "" {
|
|
||||||
cmsg = nil
|
|
||||||
} else {
|
|
||||||
cmsg = C.CString(msg)
|
|
||||||
defer C.free(unsafe.Pointer(cmsg))
|
|
||||||
}
|
|
||||||
|
|
||||||
runtime.LockOSThread()
|
runtime.LockOSThread()
|
||||||
defer runtime.UnlockOSThread()
|
defer runtime.UnlockOSThread()
|
||||||
|
|
||||||
ret := C.git_branch_move(&ptr, b.Reference.ptr, cNewBranchName, cForce, cSignature, cmsg)
|
ret := C.git_branch_move(&ptr, b.Reference.ptr, cNewBranchName, cForce)
|
||||||
if ret < 0 {
|
if ret < 0 {
|
||||||
return nil, MakeGitError(ret)
|
return nil, MakeGitError(ret)
|
||||||
}
|
}
|
||||||
|
|
15
checkout.go
15
checkout.go
|
@ -15,18 +15,23 @@ type CheckoutStrategy uint
|
||||||
const (
|
const (
|
||||||
CheckoutNone CheckoutStrategy = C.GIT_CHECKOUT_NONE // Dry run, no actual updates
|
CheckoutNone CheckoutStrategy = C.GIT_CHECKOUT_NONE // Dry run, no actual updates
|
||||||
CheckoutSafe CheckoutStrategy = C.GIT_CHECKOUT_SAFE // Allow safe updates that cannot overwrite uncommitted data
|
CheckoutSafe CheckoutStrategy = C.GIT_CHECKOUT_SAFE // Allow safe updates that cannot overwrite uncommitted data
|
||||||
CheckoutSafeCreate CheckoutStrategy = C.GIT_CHECKOUT_SAFE_CREATE // Allow safe updates plus creation of missing files
|
CheckoutRecreateMissing CheckoutStrategy = C.GIT_CHECKOUT_RECREATE_MISSING // Allow checkout to recreate missing files
|
||||||
CheckoutForce CheckoutStrategy = C.GIT_CHECKOUT_FORCE // Allow all updates to force working directory to look like index
|
|
||||||
CheckoutAllowConflicts CheckoutStrategy = C.GIT_CHECKOUT_ALLOW_CONFLICTS // Allow checkout to make safe updates even if conflicts are found
|
CheckoutAllowConflicts CheckoutStrategy = C.GIT_CHECKOUT_ALLOW_CONFLICTS // Allow checkout to make safe updates even if conflicts are found
|
||||||
CheckoutRemoveUntracked CheckoutStrategy = C.GIT_CHECKOUT_REMOVE_UNTRACKED // Remove untracked files not in index (that are not ignored)
|
CheckoutRemoveUntracked CheckoutStrategy = C.GIT_CHECKOUT_REMOVE_UNTRACKED // Remove untracked files not in index (that are not ignored)
|
||||||
CheckoutRemoveIgnored CheckoutStrategy = C.GIT_CHECKOUT_REMOVE_IGNORED // Remove ignored files not in index
|
CheckoutRemoveIgnored CheckoutStrategy = C.GIT_CHECKOUT_REMOVE_IGNORED // Remove ignored files not in index
|
||||||
CheckoutUpdateOnly CheckoutStrategy = C.GIT_CHECKOUT_UPDATE_ONLY // Only update existing files, don't create new ones
|
CheckoutUpdateOnly CheckoutStrategy = C.GIT_CHECKOUT_UPDATE_ONLY // Only update existing files, don't create new ones
|
||||||
CheckoutDontUpdateIndex CheckoutStrategy = C.GIT_CHECKOUT_DONT_UPDATE_INDEX // Normally checkout updates index entries as it goes; this stops that
|
CheckoutDontUpdateIndex CheckoutStrategy = C.GIT_CHECKOUT_DONT_UPDATE_INDEX // Normally checkout updates index entries as it goes; this stops that
|
||||||
CheckoutNoRefresh CheckoutStrategy = C.GIT_CHECKOUT_NO_REFRESH // Don't refresh index/config/etc before doing checkout
|
CheckoutNoRefresh CheckoutStrategy = C.GIT_CHECKOUT_NO_REFRESH // Don't refresh index/config/etc before doing checkout
|
||||||
|
CheckoutSkipUnmerged CheckoutStrategy = C.GIT_CHECKOUT_SKIP_UNMERGED // Allow checkout to skip unmerged files
|
||||||
|
CheckoutUserOurs CheckoutStrategy = C.GIT_CHECKOUT_USE_OURS // For unmerged files, checkout stage 2 from index
|
||||||
|
CheckoutUseTheirs CheckoutStrategy = C.GIT_CHECKOUT_USE_THEIRS // For unmerged files, checkout stage 3 from index
|
||||||
CheckoutDisablePathspecMatch CheckoutStrategy = C.GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH // Treat pathspec as simple list of exact match file paths
|
CheckoutDisablePathspecMatch CheckoutStrategy = C.GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH // Treat pathspec as simple list of exact match file paths
|
||||||
CheckoutSkipUnmerged CheckoutStrategy = C.GIT_CHECKOUT_SKIP_UNMERGED // Allow checkout to skip unmerged files (NOT IMPLEMENTED)
|
CheckoutSkipLockedDirectories CheckoutStrategy = C.GIT_CHECKOUT_SKIP_LOCKED_DIRECTORIES // Ignore directories in use, they will be left empty
|
||||||
CheckoutUserOurs CheckoutStrategy = C.GIT_CHECKOUT_USE_OURS // For unmerged files, checkout stage 2 from index (NOT IMPLEMENTED)
|
CheckoutDontOverwriteIgnored CheckoutStrategy = C.GIT_CHECKOUT_DONT_OVERWRITE_IGNORED // Don't overwrite ignored files that exist in the checkout target
|
||||||
CheckoutUseTheirs CheckoutStrategy = C.GIT_CHECKOUT_USE_THEIRS // For unmerged files, checkout stage 3 from index (NOT IMPLEMENTED)
|
CheckoutConflictStyleMerge CheckoutStrategy = C.GIT_CHECKOUT_CONFLICT_STYLE_MERGE // Write normal merge files for conflicts
|
||||||
|
CheckoutConflictStyleDiff3 CheckoutStrategy = C.GIT_CHECKOUT_CONFLICT_STYLE_DIFF3 // Include common ancestor data in diff3 format files for conflicts
|
||||||
|
CheckoutDontRemoveExisting CheckoutStrategy = C.GIT_CHECKOUT_DONT_REMOVE_EXISTING // Don't overwrite existing files or folders
|
||||||
|
CheckoutDontWriteIndex CheckoutStrategy = C.GIT_CHECKOUT_DONT_WRITE_INDEX // Normally checkout writes the index upon completion; this prevents that
|
||||||
CheckoutUpdateSubmodules CheckoutStrategy = C.GIT_CHECKOUT_UPDATE_SUBMODULES // Recursively checkout submodules with same options (NOT IMPLEMENTED)
|
CheckoutUpdateSubmodules CheckoutStrategy = C.GIT_CHECKOUT_UPDATE_SUBMODULES // Recursively checkout submodules with same options (NOT IMPLEMENTED)
|
||||||
CheckoutUpdateSubmodulesIfChanged CheckoutStrategy = C.GIT_CHECKOUT_UPDATE_SUBMODULES_IF_CHANGED // Recursively checkout submodules if HEAD moved in super repo (NOT IMPLEMENTED)
|
CheckoutUpdateSubmodulesIfChanged CheckoutStrategy = C.GIT_CHECKOUT_UPDATE_SUBMODULES_IF_CHANGED // Recursively checkout submodules if HEAD moved in super repo (NOT IMPLEMENTED)
|
||||||
)
|
)
|
||||||
|
|
|
@ -16,7 +16,7 @@ func checkout(t *testing.T, repo *Repository, commit *Commit) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = repo.SetHeadDetached(commit.Id(), commit.Author(), "checkout")
|
err = repo.SetHeadDetached(commit.Id())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ func TestRemotePush(t *testing.T) {
|
||||||
|
|
||||||
seedTestRepo(t, localRepo)
|
seedTestRepo(t, localRepo)
|
||||||
|
|
||||||
err = remote.Push([]string{"refs/heads/master"}, nil, nil, "")
|
err = remote.Push([]string{"refs/heads/master"}, nil)
|
||||||
checkFatal(t, err)
|
checkFatal(t, err)
|
||||||
|
|
||||||
_, err = localRepo.LookupReference("refs/remotes/test_push/master")
|
_, err = localRepo.LookupReference("refs/remotes/test_push/master")
|
||||||
|
|
30
reference.go
30
reference.go
|
@ -27,7 +27,7 @@ func newReferenceFromC(ptr *C.git_reference, repo *Repository) *Reference {
|
||||||
return ref
|
return ref
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Reference) SetSymbolicTarget(target string, sig *Signature, msg string) (*Reference, error) {
|
func (v *Reference) SetSymbolicTarget(target string, msg string) (*Reference, error) {
|
||||||
var ptr *C.git_reference
|
var ptr *C.git_reference
|
||||||
|
|
||||||
ctarget := C.CString(target)
|
ctarget := C.CString(target)
|
||||||
|
@ -36,12 +36,6 @@ func (v *Reference) SetSymbolicTarget(target string, sig *Signature, msg string)
|
||||||
runtime.LockOSThread()
|
runtime.LockOSThread()
|
||||||
defer runtime.UnlockOSThread()
|
defer runtime.UnlockOSThread()
|
||||||
|
|
||||||
csig, err := sig.toC()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
defer C.free(unsafe.Pointer(csig))
|
|
||||||
|
|
||||||
var cmsg *C.char
|
var cmsg *C.char
|
||||||
if msg == "" {
|
if msg == "" {
|
||||||
cmsg = nil
|
cmsg = nil
|
||||||
|
@ -50,7 +44,7 @@ func (v *Reference) SetSymbolicTarget(target string, sig *Signature, msg string)
|
||||||
defer C.free(unsafe.Pointer(cmsg))
|
defer C.free(unsafe.Pointer(cmsg))
|
||||||
}
|
}
|
||||||
|
|
||||||
ret := C.git_reference_symbolic_set_target(&ptr, v.ptr, ctarget, csig, cmsg)
|
ret := C.git_reference_symbolic_set_target(&ptr, v.ptr, ctarget, cmsg)
|
||||||
if ret < 0 {
|
if ret < 0 {
|
||||||
return nil, MakeGitError(ret)
|
return nil, MakeGitError(ret)
|
||||||
}
|
}
|
||||||
|
@ -58,18 +52,12 @@ func (v *Reference) SetSymbolicTarget(target string, sig *Signature, msg string)
|
||||||
return newReferenceFromC(ptr, v.repo), nil
|
return newReferenceFromC(ptr, v.repo), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Reference) SetTarget(target *Oid, sig *Signature, msg string) (*Reference, error) {
|
func (v *Reference) SetTarget(target *Oid, msg string) (*Reference, error) {
|
||||||
var ptr *C.git_reference
|
var ptr *C.git_reference
|
||||||
|
|
||||||
runtime.LockOSThread()
|
runtime.LockOSThread()
|
||||||
defer runtime.UnlockOSThread()
|
defer runtime.UnlockOSThread()
|
||||||
|
|
||||||
csig, err := sig.toC()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
defer C.free(unsafe.Pointer(csig))
|
|
||||||
|
|
||||||
var cmsg *C.char
|
var cmsg *C.char
|
||||||
if msg == "" {
|
if msg == "" {
|
||||||
cmsg = nil
|
cmsg = nil
|
||||||
|
@ -78,7 +66,7 @@ func (v *Reference) SetTarget(target *Oid, sig *Signature, msg string) (*Referen
|
||||||
defer C.free(unsafe.Pointer(cmsg))
|
defer C.free(unsafe.Pointer(cmsg))
|
||||||
}
|
}
|
||||||
|
|
||||||
ret := C.git_reference_set_target(&ptr, v.ptr, target.toC(), csig, cmsg)
|
ret := C.git_reference_set_target(&ptr, v.ptr, target.toC(), cmsg)
|
||||||
if ret < 0 {
|
if ret < 0 {
|
||||||
return nil, MakeGitError(ret)
|
return nil, MakeGitError(ret)
|
||||||
}
|
}
|
||||||
|
@ -100,17 +88,11 @@ func (v *Reference) Resolve() (*Reference, error) {
|
||||||
return newReferenceFromC(ptr, v.repo), nil
|
return newReferenceFromC(ptr, v.repo), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Reference) Rename(name string, force bool, sig *Signature, msg string) (*Reference, error) {
|
func (v *Reference) Rename(name string, force bool, msg string) (*Reference, error) {
|
||||||
var ptr *C.git_reference
|
var ptr *C.git_reference
|
||||||
cname := C.CString(name)
|
cname := C.CString(name)
|
||||||
defer C.free(unsafe.Pointer(cname))
|
defer C.free(unsafe.Pointer(cname))
|
||||||
|
|
||||||
csig, err := sig.toC()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
defer C.free(unsafe.Pointer(csig))
|
|
||||||
|
|
||||||
var cmsg *C.char
|
var cmsg *C.char
|
||||||
if msg == "" {
|
if msg == "" {
|
||||||
cmsg = nil
|
cmsg = nil
|
||||||
|
@ -122,7 +104,7 @@ func (v *Reference) Rename(name string, force bool, sig *Signature, msg string)
|
||||||
runtime.LockOSThread()
|
runtime.LockOSThread()
|
||||||
defer runtime.UnlockOSThread()
|
defer runtime.UnlockOSThread()
|
||||||
|
|
||||||
ret := C.git_reference_rename(&ptr, v.ptr, cname, cbool(force), csig, cmsg)
|
ret := C.git_reference_rename(&ptr, v.ptr, cname, cbool(force), cmsg)
|
||||||
|
|
||||||
if ret < 0 {
|
if ret < 0 {
|
||||||
return nil, MakeGitError(ret)
|
return nil, MakeGitError(ret)
|
||||||
|
|
|
@ -14,14 +14,7 @@ func TestRefModification(t *testing.T) {
|
||||||
|
|
||||||
commitId, treeId := seedTestRepo(t, repo)
|
commitId, treeId := seedTestRepo(t, repo)
|
||||||
|
|
||||||
loc, err := time.LoadLocation("Europe/Berlin")
|
_, err := repo.CreateReference("refs/tags/tree", treeId, true, "testTreeTag")
|
||||||
checkFatal(t, err)
|
|
||||||
sig := &Signature{
|
|
||||||
Name: "Rand Om Hacker",
|
|
||||||
Email: "random@hacker.com",
|
|
||||||
When: time.Date(2013, 03, 06, 14, 30, 0, 0, loc),
|
|
||||||
}
|
|
||||||
_, err = repo.CreateReference("refs/tags/tree", treeId, true, sig, "testTreeTag")
|
|
||||||
checkFatal(t, err)
|
checkFatal(t, err)
|
||||||
|
|
||||||
tag, err := repo.LookupReference("refs/tags/tree")
|
tag, err := repo.LookupReference("refs/tags/tree")
|
||||||
|
@ -52,7 +45,7 @@ func TestRefModification(t *testing.T) {
|
||||||
t.Fatalf("Wrong ref target")
|
t.Fatalf("Wrong ref target")
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = tag.Rename("refs/tags/renamed", false, nil, "")
|
_, err = tag.Rename("refs/tags/renamed", false, "")
|
||||||
checkFatal(t, err)
|
checkFatal(t, err)
|
||||||
tag, err = repo.LookupReference("refs/tags/renamed")
|
tag, err = repo.LookupReference("refs/tags/renamed")
|
||||||
checkFatal(t, err)
|
checkFatal(t, err)
|
||||||
|
@ -85,13 +78,13 @@ func TestReferenceIterator(t *testing.T) {
|
||||||
commitId, err := repo.CreateCommit("HEAD", sig, sig, message, tree)
|
commitId, err := repo.CreateCommit("HEAD", sig, sig, message, tree)
|
||||||
checkFatal(t, err)
|
checkFatal(t, err)
|
||||||
|
|
||||||
_, err = repo.CreateReference("refs/heads/one", commitId, true, sig, "headOne")
|
_, err = repo.CreateReference("refs/heads/one", commitId, true, "headOne")
|
||||||
checkFatal(t, err)
|
checkFatal(t, err)
|
||||||
|
|
||||||
_, err = repo.CreateReference("refs/heads/two", commitId, true, sig, "headTwo")
|
_, err = repo.CreateReference("refs/heads/two", commitId, true, "headTwo")
|
||||||
checkFatal(t, err)
|
checkFatal(t, err)
|
||||||
|
|
||||||
_, err = repo.CreateReference("refs/heads/three", commitId, true, sig, "headThree")
|
_, err = repo.CreateReference("refs/heads/three", commitId, true, "headThree")
|
||||||
checkFatal(t, err)
|
checkFatal(t, err)
|
||||||
|
|
||||||
iter, err := repo.NewReferenceIterator()
|
iter, err := repo.NewReferenceIterator()
|
||||||
|
@ -143,7 +136,7 @@ func TestReferenceOwner(t *testing.T) {
|
||||||
defer os.RemoveAll(repo.Workdir())
|
defer os.RemoveAll(repo.Workdir())
|
||||||
commitId, _ := seedTestRepo(t, repo)
|
commitId, _ := seedTestRepo(t, repo)
|
||||||
|
|
||||||
ref, err := repo.CreateReference("refs/heads/foo", commitId, true, nil, "")
|
ref, err := repo.CreateReference("refs/heads/foo", commitId, true, "")
|
||||||
checkFatal(t, err)
|
checkFatal(t, err)
|
||||||
|
|
||||||
owner := ref.Owner()
|
owner := ref.Owner()
|
||||||
|
@ -162,7 +155,7 @@ func TestUtil(t *testing.T) {
|
||||||
|
|
||||||
commitId, _ := seedTestRepo(t, repo)
|
commitId, _ := seedTestRepo(t, repo)
|
||||||
|
|
||||||
ref, err := repo.CreateReference("refs/heads/foo", commitId, true, nil, "")
|
ref, err := repo.CreateReference("refs/heads/foo", commitId, true, "")
|
||||||
checkFatal(t, err)
|
checkFatal(t, err)
|
||||||
|
|
||||||
ref2, err := repo.DwimReference("foo")
|
ref2, err := repo.DwimReference("foo")
|
||||||
|
|
38
remote.go
38
remote.go
|
@ -598,18 +598,9 @@ func (o *Remote) UpdateFetchHead() bool {
|
||||||
|
|
||||||
// Fetch performs a fetch operation. refspecs specifies which refspecs
|
// Fetch performs a fetch operation. refspecs specifies which refspecs
|
||||||
// to use for this fetch, use an empty list to use the refspecs from
|
// to use for this fetch, use an empty list to use the refspecs from
|
||||||
// the configuration; sig and msg specify what to use for the reflog
|
// the configuration; msg specifies what to use for the reflog
|
||||||
// entries. Leave nil and "" to use defaults.
|
// entries. Leave "" to use defaults.
|
||||||
func (o *Remote) Fetch(refspecs []string, sig *Signature, msg string) error {
|
func (o *Remote) Fetch(refspecs []string, msg string) error {
|
||||||
|
|
||||||
var csig *C.git_signature = nil
|
|
||||||
if sig != nil {
|
|
||||||
csig, err := sig.toC()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer C.free(unsafe.Pointer(csig))
|
|
||||||
}
|
|
||||||
|
|
||||||
var cmsg *C.char = nil
|
var cmsg *C.char = nil
|
||||||
if msg != "" {
|
if msg != "" {
|
||||||
|
@ -625,7 +616,7 @@ func (o *Remote) Fetch(refspecs []string, sig *Signature, msg string) error {
|
||||||
runtime.LockOSThread()
|
runtime.LockOSThread()
|
||||||
defer runtime.UnlockOSThread()
|
defer runtime.UnlockOSThread()
|
||||||
|
|
||||||
ret := C.git_remote_fetch(o.ptr, &crefspecs, csig, cmsg)
|
ret := C.git_remote_fetch(o.ptr, &crefspecs, cmsg)
|
||||||
if ret < 0 {
|
if ret < 0 {
|
||||||
return MakeGitError(ret)
|
return MakeGitError(ret)
|
||||||
}
|
}
|
||||||
|
@ -696,24 +687,7 @@ func (o *Remote) Ls(filterRefs ...string) ([]RemoteHead, error) {
|
||||||
return heads, nil
|
return heads, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *Remote) Push(refspecs []string, opts *PushOptions, sig *Signature, msg string) error {
|
func (o *Remote) Push(refspecs []string, opts *PushOptions) error {
|
||||||
var csig *C.git_signature = nil
|
|
||||||
if sig != nil {
|
|
||||||
csig, err := sig.toC()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer C.free(unsafe.Pointer(csig))
|
|
||||||
}
|
|
||||||
|
|
||||||
var cmsg *C.char
|
|
||||||
if msg == "" {
|
|
||||||
cmsg = nil
|
|
||||||
} else {
|
|
||||||
cmsg = C.CString(msg)
|
|
||||||
defer C.free(unsafe.Pointer(cmsg))
|
|
||||||
}
|
|
||||||
|
|
||||||
var copts C.git_push_options
|
var copts C.git_push_options
|
||||||
C.git_push_init_options(&copts, C.GIT_PUSH_OPTIONS_VERSION)
|
C.git_push_init_options(&copts, C.GIT_PUSH_OPTIONS_VERSION)
|
||||||
if opts != nil {
|
if opts != nil {
|
||||||
|
@ -728,7 +702,7 @@ func (o *Remote) Push(refspecs []string, opts *PushOptions, sig *Signature, msg
|
||||||
runtime.LockOSThread()
|
runtime.LockOSThread()
|
||||||
defer runtime.UnlockOSThread()
|
defer runtime.UnlockOSThread()
|
||||||
|
|
||||||
ret := C.git_remote_push(o.ptr, &crefspecs, &copts, csig, cmsg)
|
ret := C.git_remote_push(o.ptr, &crefspecs, &copts)
|
||||||
if ret < 0 {
|
if ret < 0 {
|
||||||
return MakeGitError(ret)
|
return MakeGitError(ret)
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestRefspecs(t *testing.T) {
|
func TestRefspecs(t *testing.T) {
|
||||||
|
@ -73,7 +72,7 @@ func TestCertificateCheck(t *testing.T) {
|
||||||
|
|
||||||
err = remote.SetCallbacks(&callbacks)
|
err = remote.SetCallbacks(&callbacks)
|
||||||
checkFatal(t, err)
|
checkFatal(t, err)
|
||||||
err = remote.Fetch([]string{}, nil, "")
|
err = remote.Fetch([]string{}, "")
|
||||||
checkFatal(t, err)
|
checkFatal(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,13 +167,7 @@ func TestRemotePrune(t *testing.T) {
|
||||||
checkFatal(t, err)
|
checkFatal(t, err)
|
||||||
defer commit.Free()
|
defer commit.Free()
|
||||||
|
|
||||||
sig := &Signature{
|
remoteRef, err := remoteRepo.CreateBranch("test-prune", commit, true)
|
||||||
Name: "Rand Om Hacker",
|
|
||||||
Email: "random@hacker.com",
|
|
||||||
When: time.Now(),
|
|
||||||
}
|
|
||||||
|
|
||||||
remoteRef, err := remoteRepo.CreateBranch("test-prune", commit, true, sig, "branch test-prune")
|
|
||||||
checkFatal(t, err)
|
checkFatal(t, err)
|
||||||
|
|
||||||
repo := createTestRepo(t)
|
repo := createTestRepo(t)
|
||||||
|
@ -189,10 +182,10 @@ func TestRemotePrune(t *testing.T) {
|
||||||
remote, err := repo.CreateRemote("origin", remoteUrl)
|
remote, err := repo.CreateRemote("origin", remoteUrl)
|
||||||
checkFatal(t, err)
|
checkFatal(t, err)
|
||||||
|
|
||||||
err = remote.Fetch([]string{"test-prune"}, sig, "")
|
err = remote.Fetch([]string{"test-prune"}, "")
|
||||||
checkFatal(t, err)
|
checkFatal(t, err)
|
||||||
|
|
||||||
_, err = repo.CreateReference("refs/remotes/origin/test-prune", head, true, sig, "remote reference")
|
_, err = repo.CreateReference("refs/remotes/origin/test-prune", head, true, "remote reference")
|
||||||
checkFatal(t, err)
|
checkFatal(t, err)
|
||||||
|
|
||||||
err = remoteRef.Delete()
|
err = remoteRef.Delete()
|
||||||
|
|
|
@ -206,65 +206,35 @@ func (v *Repository) Head() (*Reference, error) {
|
||||||
return newReferenceFromC(ptr, v), nil
|
return newReferenceFromC(ptr, v), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Repository) SetHead(refname string, sig *Signature, msg string) error {
|
func (v *Repository) SetHead(refname string) error {
|
||||||
cname := C.CString(refname)
|
cname := C.CString(refname)
|
||||||
defer C.free(unsafe.Pointer(cname))
|
defer C.free(unsafe.Pointer(cname))
|
||||||
|
|
||||||
csig, err := sig.toC()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer C.free(unsafe.Pointer(csig))
|
|
||||||
|
|
||||||
var cmsg *C.char
|
|
||||||
if msg != "" {
|
|
||||||
cmsg = C.CString(msg)
|
|
||||||
defer C.free(unsafe.Pointer(cmsg))
|
|
||||||
}
|
|
||||||
|
|
||||||
runtime.LockOSThread()
|
runtime.LockOSThread()
|
||||||
defer runtime.UnlockOSThread()
|
defer runtime.UnlockOSThread()
|
||||||
|
|
||||||
ecode := C.git_repository_set_head(v.ptr, cname, csig, cmsg)
|
ecode := C.git_repository_set_head(v.ptr, cname)
|
||||||
if ecode != 0 {
|
if ecode != 0 {
|
||||||
return MakeGitError(ecode)
|
return MakeGitError(ecode)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Repository) SetHeadDetached(id *Oid, sig *Signature, msg string) error {
|
func (v *Repository) SetHeadDetached(id *Oid) error {
|
||||||
csig, err := sig.toC()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer C.free(unsafe.Pointer(csig))
|
|
||||||
|
|
||||||
var cmsg *C.char
|
|
||||||
if msg != "" {
|
|
||||||
cmsg = C.CString(msg)
|
|
||||||
defer C.free(unsafe.Pointer(cmsg))
|
|
||||||
}
|
|
||||||
|
|
||||||
runtime.LockOSThread()
|
runtime.LockOSThread()
|
||||||
defer runtime.UnlockOSThread()
|
defer runtime.UnlockOSThread()
|
||||||
|
|
||||||
ecode := C.git_repository_set_head_detached(v.ptr, id.toC(), csig, cmsg)
|
ecode := C.git_repository_set_head_detached(v.ptr, id.toC())
|
||||||
if ecode != 0 {
|
if ecode != 0 {
|
||||||
return MakeGitError(ecode)
|
return MakeGitError(ecode)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Repository) CreateReference(name string, id *Oid, force bool, sig *Signature, msg string) (*Reference, error) {
|
func (v *Repository) CreateReference(name string, id *Oid, force bool, msg string) (*Reference, error) {
|
||||||
cname := C.CString(name)
|
cname := C.CString(name)
|
||||||
defer C.free(unsafe.Pointer(cname))
|
defer C.free(unsafe.Pointer(cname))
|
||||||
|
|
||||||
csig, err := sig.toC()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
defer C.free(unsafe.Pointer(csig))
|
|
||||||
|
|
||||||
var cmsg *C.char
|
var cmsg *C.char
|
||||||
if msg == "" {
|
if msg == "" {
|
||||||
cmsg = nil
|
cmsg = nil
|
||||||
|
@ -278,7 +248,7 @@ func (v *Repository) CreateReference(name string, id *Oid, force bool, sig *Sign
|
||||||
runtime.LockOSThread()
|
runtime.LockOSThread()
|
||||||
defer runtime.UnlockOSThread()
|
defer runtime.UnlockOSThread()
|
||||||
|
|
||||||
ecode := C.git_reference_create(&ptr, v.ptr, cname, id.toC(), cbool(force), csig, cmsg)
|
ecode := C.git_reference_create(&ptr, v.ptr, cname, id.toC(), cbool(force), cmsg)
|
||||||
if ecode < 0 {
|
if ecode < 0 {
|
||||||
return nil, MakeGitError(ecode)
|
return nil, MakeGitError(ecode)
|
||||||
}
|
}
|
||||||
|
@ -286,19 +256,13 @@ func (v *Repository) CreateReference(name string, id *Oid, force bool, sig *Sign
|
||||||
return newReferenceFromC(ptr, v), nil
|
return newReferenceFromC(ptr, v), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Repository) CreateSymbolicReference(name, target string, force bool, sig *Signature, msg string) (*Reference, error) {
|
func (v *Repository) CreateSymbolicReference(name, target string, force bool, msg string) (*Reference, error) {
|
||||||
cname := C.CString(name)
|
cname := C.CString(name)
|
||||||
defer C.free(unsafe.Pointer(cname))
|
defer C.free(unsafe.Pointer(cname))
|
||||||
|
|
||||||
ctarget := C.CString(target)
|
ctarget := C.CString(target)
|
||||||
defer C.free(unsafe.Pointer(ctarget))
|
defer C.free(unsafe.Pointer(ctarget))
|
||||||
|
|
||||||
csig, err := sig.toC()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
defer C.free(unsafe.Pointer(csig))
|
|
||||||
|
|
||||||
var cmsg *C.char
|
var cmsg *C.char
|
||||||
if msg == "" {
|
if msg == "" {
|
||||||
cmsg = nil
|
cmsg = nil
|
||||||
|
@ -312,7 +276,7 @@ func (v *Repository) CreateSymbolicReference(name, target string, force bool, si
|
||||||
runtime.LockOSThread()
|
runtime.LockOSThread()
|
||||||
defer runtime.UnlockOSThread()
|
defer runtime.UnlockOSThread()
|
||||||
|
|
||||||
ecode := C.git_reference_symbolic_create(&ptr, v.ptr, cname, ctarget, cbool(force), csig, cmsg)
|
ecode := C.git_reference_symbolic_create(&ptr, v.ptr, cname, ctarget, cbool(force), cmsg)
|
||||||
if ecode < 0 {
|
if ecode < 0 {
|
||||||
return nil, MakeGitError(ecode)
|
return nil, MakeGitError(ecode)
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ func TestRevparseExt(t *testing.T) {
|
||||||
|
|
||||||
_, treeId := seedTestRepo(t, repo)
|
_, treeId := seedTestRepo(t, repo)
|
||||||
|
|
||||||
ref, err := repo.CreateReference("refs/heads/master", treeId, true, nil, "")
|
ref, err := repo.CreateReference("refs/heads/master", treeId, true, "")
|
||||||
checkFatal(t, err)
|
checkFatal(t, err)
|
||||||
|
|
||||||
obj, ref, err := repo.RevparseExt("master")
|
obj, ref, err := repo.RevparseExt("master")
|
||||||
|
|
|
@ -16,7 +16,6 @@ type SubmoduleUpdateOptions struct {
|
||||||
*CheckoutOpts
|
*CheckoutOpts
|
||||||
*RemoteCallbacks
|
*RemoteCallbacks
|
||||||
CloneCheckoutStrategy CheckoutStrategy
|
CloneCheckoutStrategy CheckoutStrategy
|
||||||
Signature *Signature
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Submodule
|
// Submodule
|
||||||
|
@ -345,11 +344,5 @@ func populateSubmoduleUpdateOptions(ptr *C.git_submodule_update_options, opts *S
|
||||||
populateRemoteCallbacks(&ptr.remote_callbacks, opts.RemoteCallbacks)
|
populateRemoteCallbacks(&ptr.remote_callbacks, opts.RemoteCallbacks)
|
||||||
ptr.clone_checkout_strategy = C.uint(opts.CloneCheckoutStrategy)
|
ptr.clone_checkout_strategy = C.uint(opts.CloneCheckoutStrategy)
|
||||||
|
|
||||||
sig, err := opts.Signature.toC()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
ptr.signature = sig
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 04bdd97f2b63793a8720fd19007911e946ba3c55
|
Subproject commit d675982a15388d8c413acda139b4662062cf3286
|
Loading…
Reference in New Issue