Commit b8e9467a4b7f76c711103c9722deaf8c828d9abc

Edward Thomson 2018-01-20T19:39:34

merge: allow custom conflict marker size Allow for a custom conflict marker size, allowing callers to override the default size of the "<<<<<<<" and ">>>>>>>" markers in the conflicted output file.

diff --git a/include/git2/merge.h b/include/git2/merge.h
index 94ac8b5..80ef864 100644
--- a/include/git2/merge.h
+++ b/include/git2/merge.h
@@ -162,6 +162,8 @@ typedef enum {
 	GIT_MERGE_FILE_DIFF_MINIMAL = (1 << 7),
 } git_merge_file_flag_t;
 
+#define GIT_MERGE_CONFLICT_MARKER_SIZE	7
+
 /**
  * Options for merging a file
  */
@@ -191,6 +193,10 @@ typedef struct {
 
 	/** see `git_merge_file_flag_t` above */
 	git_merge_file_flag_t flags;
+
+	/** The size of conflict markers (eg, "<<<<<<<").  Default is
+	 * GIT_MERGE_CONFLICT_MARKER_SIZE. */
+	unsigned short marker_size;
 } git_merge_file_options;
 
 #define GIT_MERGE_FILE_OPTIONS_VERSION 1
diff --git a/src/merge_file.c b/src/merge_file.c
index a54d6bd..a36c198 100644
--- a/src/merge_file.c
+++ b/src/merge_file.c
@@ -126,6 +126,8 @@ static int merge_file__xdiff(
 	if (options.flags & GIT_MERGE_FILE_DIFF_MINIMAL)
 		xmparam.xpp.flags |= XDF_NEED_MINIMAL;
 
+	xmparam.marker_size = options.marker_size;
+
 	if ((xdl_result = xdl_merge(&ancestor_mmfile, &our_mmfile,
 		&their_mmfile, &xmparam, &mmbuffer)) < 0) {
 		giterr_set(GITERR_MERGE, "failed to merge files");