14
15
struct ll_merge_driver;
16
17
-typedef int (*ll_merge_fn)(const struct ll_merge_driver *,
17
+typedef enum ll_merge_result (*ll_merge_fn)(const struct ll_merge_driver *,
18
mmbuffer_t *result,
19
const char *path,
20
mmfile_t *orig, const char *orig_name,
49
/*
50
* Built-in low-levels
51
*/
52
-static int ll_binary_merge(const struct ll_merge_driver *drv_unused,
52
+static enum ll_merge_result ll_binary_merge(const struct ll_merge_driver *drv_unused,
53
mmbuffer_t *result,
54
const char *path,
55
mmfile_t *orig, const char *orig_name,
58
const struct ll_merge_options *opts,
59
int marker_size)
60
{
61
+ enum ll_merge_result ret;
62
mmfile_t *stolen;
63
assert(opts);
64
69
*/
70
if (opts->virtual_ancestor) {
71
stolen = orig;
72
+ ret = LL_MERGE_OK;
73
} else {
74
switch (opts->variant) {
75
default:
74
- warning("Cannot merge binary files: %s (%s vs. %s)",
75
- path, name1, name2);
76
- /* fallthru */
76
+ ret = LL_MERGE_BINARY_CONFLICT;
77
+ stolen = src1;
78
+ break;
79
case XDL_MERGE_FAVOR_OURS:
80
+ ret = LL_MERGE_OK;
81
stolen = src1;
82
break;
83
case XDL_MERGE_FAVOR_THEIRS:
84
+ ret = LL_MERGE_OK;
85
stolen = src2;
86
break;
87
}
91
result->size = stolen->size;
92
stolen->ptr = NULL;
93
90
- /*
91
- * With -Xtheirs or -Xours, we have cleanly merged;
92
- * otherwise we got a conflict.
93
- */
94
- return opts->variant == XDL_MERGE_FAVOR_OURS ||
95
- opts->variant == XDL_MERGE_FAVOR_THEIRS ?
96
- 0 : 1;
94
+ return ret;
95
}
96
99
-static int ll_xdl_merge(const struct ll_merge_driver *drv_unused,
97
+static enum ll_merge_result ll_xdl_merge(const struct ll_merge_driver *drv_unused,
98
mmbuffer_t *result,
99
const char *path,
100
mmfile_t *orig, const char *orig_name,
103
const struct ll_merge_options *opts,
104
int marker_size)
105
{
106
+ enum ll_merge_result ret;
107
xmparam_t xmp;
108
+ int status;
109
assert(opts);
110
111
if (orig->size > MAX_XDIFF_SIZE ||
133
xmp.ancestor = orig_name;
134
xmp.file1 = name1;
135
xmp.file2 = name2;
136
- return xdl_merge(orig, src1, src2, &xmp, result);
136
+ status = xdl_merge(orig, src1, src2, &xmp, result);
137
+ ret = (status > 0) ? LL_MERGE_CONFLICT : status;
138
+ return ret;
139
}
140
139
-static int ll_union_merge(const struct ll_merge_driver *drv_unused,
141
+static enum ll_merge_result ll_union_merge(const struct ll_merge_driver *drv_unused,
142
mmbuffer_t *result,
143
const char *path,
144
mmfile_t *orig, const char *orig_name,
180
/*
181
* User defined low-level merge driver support.
182
*/
181
-static int ll_ext_merge(const struct ll_merge_driver *fn,
183
+static enum ll_merge_result ll_ext_merge(const struct ll_merge_driver *fn,
184
mmbuffer_t *result,
185
const char *path,
186
mmfile_t *orig, const char *orig_name,
196
const char *args[] = { NULL, NULL };
197
int status, fd, i;
198
struct stat st;
199
+ enum ll_merge_result ret;
200
assert(opts);
201
202
sq_quote_buf(&path_sq, path);
239
unlink_or_warn(temp[i]);
240
strbuf_release(&cmd);
241
strbuf_release(&path_sq);
239
- return status;
242
+ ret = (status > 0) ? LL_MERGE_CONFLICT : status;
243
+ return ret;
244
}
245
246
/*
366
}
367
}
368
365
-int ll_merge(mmbuffer_t *result_buf,
369
+enum ll_merge_result ll_merge(mmbuffer_t *result_buf,
370
const char *path,
371
mmfile_t *ancestor, const char *ancestor_label,
372
mmfile_t *ours, const char *our_label,