Merge pull request #6204 from boretrk/merge_flags merge: fix overlap between GIT_MERGE_FILE_FAVOR__CONFLICTED and GIT_MERGE_FILE_SIMPLIFY_ALNUM
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
diff --git a/include/git2/merge.h b/include/git2/merge.h
index edd090c..e90941a 100644
--- a/include/git2/merge.h
+++ b/include/git2/merge.h
@@ -91,7 +91,15 @@ typedef enum {
* instead simply use the first base. This flag provides a similar
* merge base to `git-merge-resolve`.
*/
- GIT_MERGE_NO_RECURSIVE = (1 << 3)
+ GIT_MERGE_NO_RECURSIVE = (1 << 3),
+
+ /**
+ * Treat this merge as if it is to produce the virtual base
+ * of a recursive merge. This will ensure that there are
+ * no conflicts, any conflicting regions will keep conflict
+ * markers in the merge result.
+ */
+ GIT_MERGE_VIRTUAL_BASE = (1 << 4)
} git_merge_flag_t;
/**
@@ -162,7 +170,14 @@ typedef enum {
GIT_MERGE_FILE_DIFF_MINIMAL = (1 << 7),
/** Create zdiff3 ("zealous diff3")-style files */
- GIT_MERGE_FILE_STYLE_ZDIFF3 = (1 << 8)
+ GIT_MERGE_FILE_STYLE_ZDIFF3 = (1 << 8),
+
+ /**
+ * Do not produce file conflicts when common regions have
+ * changed; keep the conflict markers in the file and accept
+ * that as the merge result.
+ */
+ GIT_MERGE_FILE_ACCEPT_CONFLICTS = (1 << 9)
} git_merge_file_flag_t;
#define GIT_MERGE_CONFLICT_MARKER_SIZE 7
diff --git a/src/merge.c b/src/merge.c
index 24650bb..641b326 100644
--- a/src/merge.c
+++ b/src/merge.c
@@ -2116,11 +2116,11 @@ int git_merge__iterators(
file_opts.flags = opts.file_flags;
/* use the git-inspired labels when virtual base building */
- if (opts.flags & GIT_MERGE__VIRTUAL_BASE) {
+ if (opts.flags & GIT_MERGE_VIRTUAL_BASE) {
file_opts.ancestor_label = "merged common ancestors";
file_opts.our_label = "Temporary merge branch 1";
file_opts.their_label = "Temporary merge branch 2";
- file_opts.flags |= GIT_MERGE_FILE_FAVOR__CONFLICTED;
+ file_opts.flags |= GIT_MERGE_FILE_ACCEPT_CONFLICTS;
file_opts.marker_size = GIT_MERGE_CONFLICT_MARKER_SIZE + 2;
}
@@ -2280,7 +2280,7 @@ static int create_virtual_base(
memcpy(&virtual_opts, opts, sizeof(git_merge_options));
virtual_opts.flags &= ~GIT_MERGE_FAIL_ON_CONFLICT;
- virtual_opts.flags |= GIT_MERGE__VIRTUAL_BASE;
+ virtual_opts.flags |= GIT_MERGE_VIRTUAL_BASE;
if ((merge_annotated_commits(&index, NULL, repo, one, two,
recursion_level + 1, &virtual_opts)) < 0)
diff --git a/src/merge.h b/src/merge.h
index 632f2d8..2393290 100644
--- a/src/merge.h
+++ b/src/merge.h
@@ -25,19 +25,6 @@
#define GIT_MERGE_DEFAULT_RENAME_THRESHOLD 50
#define GIT_MERGE_DEFAULT_TARGET_LIMIT 1000
-
-/** Internal merge flags. */
-enum {
- /** The merge is for a virtual base in a recursive merge. */
- GIT_MERGE__VIRTUAL_BASE = (1 << 31)
-};
-
-enum {
- /** Accept the conflict file, staging it as the merge result. */
- GIT_MERGE_FILE_FAVOR__CONFLICTED = 4
-};
-
-
/** Types of changes when files are merged from branch to branch. */
typedef enum {
/* No conflict - a change only occurs in one branch. */
diff --git a/src/merge_driver.c b/src/merge_driver.c
index be4d3bf..19b35ac 100644
--- a/src/merge_driver.c
+++ b/src/merge_driver.c
@@ -93,7 +93,7 @@ int git_merge_driver__builtin_apply(
goto done;
if (!result.automergeable &&
- !(file_opts.flags & GIT_MERGE_FILE_FAVOR__CONFLICTED)) {
+ !(file_opts.flags & GIT_MERGE_FILE_ACCEPT_CONFLICTS)) {
error = GIT_EMERGECONFLICT;
goto done;
}