Beispiel #1
0
func MergeFile(ancestor MergeFileInput, ours MergeFileInput, theirs MergeFileInput, options *MergeFileOptions) (*MergeFileResult, error) {

	var cancestor C.git_merge_file_input
	var cours C.git_merge_file_input
	var ctheirs C.git_merge_file_input

	populateCMergeFileInput(&cancestor, ancestor)
	defer freeCMergeFileInput(&cancestor)
	populateCMergeFileInput(&cours, ours)
	defer freeCMergeFileInput(&cours)
	populateCMergeFileInput(&ctheirs, theirs)
	defer freeCMergeFileInput(&ctheirs)

	var copts *C.git_merge_file_options
	if options != nil {
		copts = &C.git_merge_file_options{}
		ecode := C.git_merge_file_init_options(copts, C.GIT_MERGE_FILE_OPTIONS_VERSION)
		if ecode < 0 {
			return nil, MakeGitError(ecode)
		}
		populateCMergeFileOptions(copts, *options)
	}

	runtime.LockOSThread()
	defer runtime.UnlockOSThread()

	var result C.git_merge_file_result
	ecode := C.git_merge_file(&result, &cancestor, &cours, &ctheirs, copts)
	if ecode < 0 {
		return nil, MakeGitError(ecode)
	}

	return newMergeFileResultFromC(&result), nil

}
Beispiel #2
0
func Test(t *testing.T) {
	var in C.git_merge_file_input
	var opts *C.git_merge_file_options
	C.git_merge_file(&in, opts)

	// Test that the generated type names are deterministic.
	// (Previously this would fail about 10% of the time.)
	//
	// Brittle: the assertion may fail spuriously when the algorithm
	// changes, but should remain stable otherwise.
	got := fmt.Sprintf("%T %T", in, opts)
	want := "issue9026._Ctype_struct___0 *issue9026._Ctype_struct___1"
	if got != want {
		t.Errorf("Non-deterministic type names: got %s, want %s", got, want)
	}
}