From 9de57cc90ef4e3d778613ad9eec35dfb9b6b21b2 Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Thu, 25 Jan 2018 16:43:27 -0800 Subject: merge: add missing MergeFileFlag constants While we're here, pull in comments as well. While one can pop back and forth between godoc and libgit2 refs, it's much nicer to have it in one place. Note that MergeFileStyleSimplifyAlnum probably should have been called merely MergeFileSimplifyAlnum (no "Style"). It's probably not worth breaking backwards compatibility to fix it, but we avoid the mistake going forwards. --- merge.go | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'merge.go') diff --git a/merge.go b/merge.go index bfbf9a3..abe1426 100644 --- a/merge.go +++ b/merge.go @@ -344,9 +344,29 @@ type MergeFileFlags int const ( MergeFileDefault MergeFileFlags = C.GIT_MERGE_FILE_DEFAULT - MergeFileStyleMerge MergeFileFlags = C.GIT_MERGE_FILE_STYLE_MERGE - MergeFileStyleDiff MergeFileFlags = C.GIT_MERGE_FILE_STYLE_DIFF3 + // Create standard conflicted merge files + MergeFileStyleMerge MergeFileFlags = C.GIT_MERGE_FILE_STYLE_MERGE + + // Create diff3-style files + MergeFileStyleDiff MergeFileFlags = C.GIT_MERGE_FILE_STYLE_DIFF3 + + // Condense non-alphanumeric regions for simplified diff file MergeFileStyleSimplifyAlnum MergeFileFlags = C.GIT_MERGE_FILE_SIMPLIFY_ALNUM + + // Ignore all whitespace + MergeFileIgnoreWhitespace MergeFileFlags = C.GIT_MERGE_FILE_IGNORE_WHITESPACE + + // Ignore changes in amount of whitespace + MergeFileIgnoreWhitespaceChange MergeFileFlags = C.GIT_MERGE_FILE_IGNORE_WHITESPACE_CHANGE + + // Ignore whitespace at end of line + MergeFileIgnoreWhitespaceEOL MergeFileFlags = C.GIT_MERGE_FILE_IGNORE_WHITESPACE_EOL + + // Use the "patience diff" algorithm + MergeFileDiffPatience MergeFileFlags = C.GIT_MERGE_FILE_DIFF_PATIENCE + + // Take extra time to find minimal diff + MergeFileDiffMinimal MergeFileFlags = C.GIT_MERGE_FILE_DIFF_MINIMAL ) type MergeFileOptions struct { -- cgit v1.2.3 From 661e1a6f1b70a3f4837c4aec6a3006dcc5689bc6 Mon Sep 17 00:00:00 2001 From: Carlos Martín Nieto Date: Thu, 22 Feb 2018 09:46:42 +0100 Subject: merge: expose the conflict marker size option --- merge.go | 3 +++ 1 file changed, 3 insertions(+) (limited to 'merge.go') diff --git a/merge.go b/merge.go index bfbf9a3..adc521a 100644 --- a/merge.go +++ b/merge.go @@ -355,6 +355,7 @@ type MergeFileOptions struct { TheirLabel string Favor MergeFileFavor Flags MergeFileFlags + MarkerSize uint16 } func mergeFileOptionsFromC(c C.git_merge_file_options) MergeFileOptions { @@ -364,6 +365,7 @@ func mergeFileOptionsFromC(c C.git_merge_file_options) MergeFileOptions { TheirLabel: C.GoString(c.their_label), Favor: MergeFileFavor(c.favor), Flags: MergeFileFlags(c.flags), + MarkerSize: uint16(c.marker_size), } } @@ -373,6 +375,7 @@ func populateCMergeFileOptions(c *C.git_merge_file_options, options MergeFileOpt c.their_label = C.CString(options.TheirLabel) c.favor = C.git_merge_file_favor_t(options.Favor) c.flags = C.git_merge_file_flag_t(options.Flags) + c.marker_size = C.ushort(options.MarkerSize) } func freeCMergeFileOptions(c *C.git_merge_file_options) { -- cgit v1.2.3 From 97e6392d3ab67bbf3e3e59b86a0bc9ebf7430e98 Mon Sep 17 00:00:00 2001 From: Carlos Martín Nieto Date: Tue, 10 Dec 2019 22:15:32 +0000 Subject: Adjust to libgit2 changes --- credentials.go | 1 + go.mod | 2 ++ merge.go | 4 ++-- odb.go | 2 +- stash.go | 2 +- 5 files changed, 7 insertions(+), 4 deletions(-) (limited to 'merge.go') diff --git a/credentials.go b/credentials.go index 4e42b6e..766619c 100644 --- a/credentials.go +++ b/credentials.go @@ -2,6 +2,7 @@ package git /* #include +#include */ import "C" import "unsafe" diff --git a/go.mod b/go.mod index 688b8e3..7a68658 100644 --- a/go.mod +++ b/go.mod @@ -1 +1,3 @@ module github.com/libgit2/git2go + +go 1.13 diff --git a/merge.go b/merge.go index bc672ce..955289a 100644 --- a/merge.go +++ b/merge.go @@ -132,7 +132,7 @@ func (mo *MergeOptions) toC() *C.git_merge_options { } return &C.git_merge_options{ version: C.uint(mo.Version), - flags: C.git_merge_flag_t(mo.TreeFlags), + flags: C.uint32_t(mo.TreeFlags), rename_threshold: C.uint(mo.RenameThreshold), target_limit: C.uint(mo.TargetLimit), file_favor: C.git_merge_file_favor_t(mo.FileFavor), @@ -394,7 +394,7 @@ func populateCMergeFileOptions(c *C.git_merge_file_options, options MergeFileOpt c.our_label = C.CString(options.OurLabel) c.their_label = C.CString(options.TheirLabel) c.favor = C.git_merge_file_favor_t(options.Favor) - c.flags = C.git_merge_file_flag_t(options.Flags) + c.flags = C.uint32_t(options.Flags) c.marker_size = C.ushort(options.MarkerSize) } diff --git a/odb.go b/odb.go index fec0eb9..6489653 100644 --- a/odb.go +++ b/odb.go @@ -221,7 +221,7 @@ func (v *Odb) NewWriteStream(size int64, otype ObjectType) (*OdbWriteStream, err runtime.LockOSThread() defer runtime.UnlockOSThread() - ret := C.git_odb_open_wstream(&stream.ptr, v.ptr, C.git_off_t(size), C.git_object_t(otype)) + ret := C.git_odb_open_wstream(&stream.ptr, v.ptr, C.git_object_size_t(size), C.git_object_t(otype)) runtime.KeepAlive(v) if ret < 0 { return nil, MakeGitError(ret) diff --git a/stash.go b/stash.go index 8743da8..6624bce 100644 --- a/stash.go +++ b/stash.go @@ -171,7 +171,7 @@ func (opts *StashApplyOptions) toC() ( optsC = &C.git_stash_apply_options{ version: C.GIT_STASH_APPLY_OPTIONS_VERSION, - flags: C.git_stash_apply_flags(opts.Flags), + flags: C.uint32_t(opts.Flags), } populateCheckoutOpts(&optsC.checkout_options, &opts.CheckoutOptions) if opts.ProgressCallback != nil { -- cgit v1.2.3