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 <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Phillip Wood committed
Mar 14, 2024 at 17:05 UTC
135cc712c39fa7ccf25b9b2b55d1d07fc85c85a4
5 files changed
+12
-2
merge-ll.c
+3
-1
@@ -128,7 +128,9 @@ static enum ll_merge_result ll_xdl_merge(const struct ll_merge_driver *drv_unuse
128
xmp.level = XDL_MERGE_ZEALOUS;
129
xmp.favor = opts->variant;
130
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)
134
xmp.style = git_xmerge_style;
135
if (marker_size > 0)
136
xmp.marker_size = marker_size;
merge-ll.h
+4
-1
@@ -78,11 +78,14 @@ struct ll_merge_options {
78
*/
79
unsigned extra_marker_size;
80
81
+ /* Override the global conflict style. */
82
+ int conflict_style;
83
+
84
/* Extra xpparam_t flags as defined in xdiff/xdiff.h. */
85
long xdl_opts;
86
};
87
85
-#define LL_MERGE_OPTIONS_INIT {0}
88
+#define LL_MERGE_OPTIONS_INIT { .conflict_style = -1 }
89
90
enum ll_merge_result {
91
LL_MERGE_ERROR = -1,
merge-ort.c
+1
@@ -1966,6 +1966,7 @@ static int merge_3way(struct merge_options *opt,
1966
ll_opts.renormalize = opt->renormalize;
1967
ll_opts.extra_marker_size = extra_marker_size;
1968
ll_opts.xdl_opts = opt->xdl_opts;
1969
+ ll_opts.conflict_style = opt->conflict_style;
1970
1971
if (opt->priv->call_depth) {
1972
ll_opts.virtual_ancestor = 1;
merge-recursive.c
+3
@@ -1054,6 +1054,7 @@ static int merge_3way(struct merge_options *opt,
1054
ll_opts.renormalize = opt->renormalize;
1055
ll_opts.extra_marker_size = extra_marker_size;
1056
ll_opts.xdl_opts = opt->xdl_opts;
1057
+ ll_opts.conflict_style = opt->conflict_style;
1058
1059
if (opt->priv->call_depth) {
1060
ll_opts.virtual_ancestor = 1;
@@ -3899,6 +3900,8 @@ void init_merge_options(struct merge_options *opt,
3900
3901
opt->renormalize = 0;
3902
3903
+ opt->conflict_style = -1;
3904
+
3905
merge_recursive_config(opt);
3906
merge_verbosity = getenv("GIT_MERGE_VERBOSITY");
3907
if (merge_verbosity)
merge-recursive.h
+1
@@ -31,6 +31,7 @@ struct merge_options {
31
32
/* xdiff-related options (patience, ignore whitespace, ours/theirs) */
33
long xdl_opts;
34
+ int conflict_style;
35
enum {
36
MERGE_VARIANT_NORMAL = 0,
37
MERGE_VARIANT_OURS,