Skip to content

Commit aded938

Browse files
authored
Merge pull request libgit2#6204 from boretrk/merge_flags
merge: fix overlap between GIT_MERGE_FILE_FAVOR__CONFLICTED and GIT_MERGE_FILE_SIMPLIFY_ALNUM
2 parents d99b401 + 0fbf62c commit aded938

File tree

4 files changed

+21
-19
lines changed

4 files changed

+21
-19
lines changed

include/git2/merge.h

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,15 @@ typedef enum {
9191
* instead simply use the first base. This flag provides a similar
9292
* merge base to `git-merge-resolve`.
9393
*/
94-
GIT_MERGE_NO_RECURSIVE = (1 << 3)
94+
GIT_MERGE_NO_RECURSIVE = (1 << 3),
95+
96+
/**
97+
* Treat this merge as if it is to produce the virtual base
98+
* of a recursive merge. This will ensure that there are
99+
* no conflicts, any conflicting regions will keep conflict
100+
* markers in the merge result.
101+
*/
102+
GIT_MERGE_VIRTUAL_BASE = (1 << 4)
95103
} git_merge_flag_t;
96104

97105
/**
@@ -162,7 +170,14 @@ typedef enum {
162170
GIT_MERGE_FILE_DIFF_MINIMAL = (1 << 7),
163171

164172
/** Create zdiff3 ("zealous diff3")-style files */
165-
GIT_MERGE_FILE_STYLE_ZDIFF3 = (1 << 8)
173+
GIT_MERGE_FILE_STYLE_ZDIFF3 = (1 << 8),
174+
175+
/**
176+
* Do not produce file conflicts when common regions have
177+
* changed; keep the conflict markers in the file and accept
178+
* that as the merge result.
179+
*/
180+
GIT_MERGE_FILE_ACCEPT_CONFLICTS = (1 << 9)
166181
} git_merge_file_flag_t;
167182

168183
#define GIT_MERGE_CONFLICT_MARKER_SIZE 7

src/merge.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2116,11 +2116,11 @@ int git_merge__iterators(
21162116
file_opts.flags = opts.file_flags;
21172117

21182118
/* use the git-inspired labels when virtual base building */
2119-
if (opts.flags & GIT_MERGE__VIRTUAL_BASE) {
2119+
if (opts.flags & GIT_MERGE_VIRTUAL_BASE) {
21202120
file_opts.ancestor_label = "merged common ancestors";
21212121
file_opts.our_label = "Temporary merge branch 1";
21222122
file_opts.their_label = "Temporary merge branch 2";
2123-
file_opts.flags |= GIT_MERGE_FILE_FAVOR__CONFLICTED;
2123+
file_opts.flags |= GIT_MERGE_FILE_ACCEPT_CONFLICTS;
21242124
file_opts.marker_size = GIT_MERGE_CONFLICT_MARKER_SIZE + 2;
21252125
}
21262126

@@ -2280,7 +2280,7 @@ static int create_virtual_base(
22802280
memcpy(&virtual_opts, opts, sizeof(git_merge_options));
22812281

22822282
virtual_opts.flags &= ~GIT_MERGE_FAIL_ON_CONFLICT;
2283-
virtual_opts.flags |= GIT_MERGE__VIRTUAL_BASE;
2283+
virtual_opts.flags |= GIT_MERGE_VIRTUAL_BASE;
22842284

22852285
if ((merge_annotated_commits(&index, NULL, repo, one, two,
22862286
recursion_level + 1, &virtual_opts)) < 0)

src/merge.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,6 @@
2525
#define GIT_MERGE_DEFAULT_RENAME_THRESHOLD 50
2626
#define GIT_MERGE_DEFAULT_TARGET_LIMIT 1000
2727

28-
29-
/** Internal merge flags. */
30-
enum {
31-
/** The merge is for a virtual base in a recursive merge. */
32-
GIT_MERGE__VIRTUAL_BASE = (1 << 31)
33-
};
34-
35-
enum {
36-
/** Accept the conflict file, staging it as the merge result. */
37-
GIT_MERGE_FILE_FAVOR__CONFLICTED = 4
38-
};
39-
40-
4128
/** Types of changes when files are merged from branch to branch. */
4229
typedef enum {
4330
/* No conflict - a change only occurs in one branch. */

src/merge_driver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ int git_merge_driver__builtin_apply(
9393
goto done;
9494

9595
if (!result.automergeable &&
96-
!(file_opts.flags & GIT_MERGE_FILE_FAVOR__CONFLICTED)) {
96+
!(file_opts.flags & GIT_MERGE_FILE_ACCEPT_CONFLICTS)) {
9797
error = GIT_EMERGECONFLICT;
9898
goto done;
9999
}

0 commit comments

Comments
 (0)