Skip to content

Commit 135cc71

Browse files
phillipwoodgitster
authored andcommitted
merge options: add a conflict style member
Add a conflict_style member to `struct merge_options` and `struct ll_merge_options` to allow callers to override the default conflict style. This will be used in the next commit. Signed-off-by: Phillip Wood <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 412aff7 commit 135cc71

File tree

5 files changed

+12
-2
lines changed

5 files changed

+12
-2
lines changed

merge-ll.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@ static enum ll_merge_result ll_xdl_merge(const struct ll_merge_driver *drv_unuse
128128
xmp.level = XDL_MERGE_ZEALOUS;
129129
xmp.favor = opts->variant;
130130
xmp.xpp.flags = opts->xdl_opts;
131-
if (git_xmerge_style >= 0)
131+
if (opts->conflict_style >= 0)
132+
xmp.style = opts->conflict_style;
133+
else if (git_xmerge_style >= 0)
132134
xmp.style = git_xmerge_style;
133135
if (marker_size > 0)
134136
xmp.marker_size = marker_size;

merge-ll.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,14 @@ struct ll_merge_options {
7878
*/
7979
unsigned extra_marker_size;
8080

81+
/* Override the global conflict style. */
82+
int conflict_style;
83+
8184
/* Extra xpparam_t flags as defined in xdiff/xdiff.h. */
8285
long xdl_opts;
8386
};
8487

85-
#define LL_MERGE_OPTIONS_INIT {0}
88+
#define LL_MERGE_OPTIONS_INIT { .conflict_style = -1 }
8689

8790
enum ll_merge_result {
8891
LL_MERGE_ERROR = -1,

merge-ort.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1966,6 +1966,7 @@ static int merge_3way(struct merge_options *opt,
19661966
ll_opts.renormalize = opt->renormalize;
19671967
ll_opts.extra_marker_size = extra_marker_size;
19681968
ll_opts.xdl_opts = opt->xdl_opts;
1969+
ll_opts.conflict_style = opt->conflict_style;
19691970

19701971
if (opt->priv->call_depth) {
19711972
ll_opts.virtual_ancestor = 1;

merge-recursive.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,6 +1054,7 @@ static int merge_3way(struct merge_options *opt,
10541054
ll_opts.renormalize = opt->renormalize;
10551055
ll_opts.extra_marker_size = extra_marker_size;
10561056
ll_opts.xdl_opts = opt->xdl_opts;
1057+
ll_opts.conflict_style = opt->conflict_style;
10571058

10581059
if (opt->priv->call_depth) {
10591060
ll_opts.virtual_ancestor = 1;
@@ -3899,6 +3900,8 @@ void init_merge_options(struct merge_options *opt,
38993900

39003901
opt->renormalize = 0;
39013902

3903+
opt->conflict_style = -1;
3904+
39023905
merge_recursive_config(opt);
39033906
merge_verbosity = getenv("GIT_MERGE_VERBOSITY");
39043907
if (merge_verbosity)

merge-recursive.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ struct merge_options {
3131

3232
/* xdiff-related options (patience, ignore whitespace, ours/theirs) */
3333
long xdl_opts;
34+
int conflict_style;
3435
enum {
3536
MERGE_VARIANT_NORMAL = 0,
3637
MERGE_VARIANT_OURS,

0 commit comments

Comments
 (0)