const char *names[3] = { NULL, NULL, NULL };
mmfile_t mmfs[3];
mmbuffer_t result = {NULL, 0};
- xpparam_t xpp = {XDF_NEED_MINIMAL};
+ xmparam_t xmp = {{XDF_NEED_MINIMAL}};
int ret = 0, i = 0, to_stdout = 0;
- int merge_level = XDL_MERGE_ZEALOUS_ALNUM;
- int merge_style = 0, quiet = 0;
+ int level = XDL_MERGE_ZEALOUS_ALNUM;
+ int style = 0, quiet = 0;
+ int favor = 0;
int nongit;
struct option options[] = {
}
ret = xdl_merge(mmfs + 1, mmfs + 0, names[0], mmfs + 2, names[2],
- &xpp, XDL_MERGE_FLAGS(level, style, favor), &result);
- &xmp, merge_level | merge_style, &result);
++ &xmp, XDL_MERGE_FLAGS(level, style, favor), &result);
for (i = 0; i < 3; i++)
free(mmfs[i].ptr);
mmfile_t *orig,
mmfile_t *src1, const char *name1,
mmfile_t *src2, const char *name2,
- int flag);
- int virtual_ancestor,
++ int flag,
+ int marker_size);
struct ll_merge_driver {
const char *name;
mmfile_t *orig,
mmfile_t *src1, const char *name1,
mmfile_t *src2, const char *name2,
- int flag)
- int virtual_ancestor, int marker_size)
++ int flag, int marker_size)
{
/*
* The tentative merge result is "ours" for the final round,
mmfile_t *orig,
mmfile_t *src1, const char *name1,
mmfile_t *src2, const char *name2,
- int flag)
- int virtual_ancestor, int marker_size)
++ int flag, int marker_size)
{
- xpparam_t xpp;
+ xmparam_t xmp;
int style = 0;
+ int favor = (flag >> 1) & 03;
if (buffer_is_binary(orig->ptr, orig->size) ||
buffer_is_binary(src1->ptr, src1->size) ||
return ll_binary_merge(drv_unused, result,
path,
orig, src1, name1,
- src2, name2, flag);
+ src2, name2,
- virtual_ancestor, marker_size);
++ flag, marker_size);
}
- memset(&xpp, 0, sizeof(xpp));
+ memset(&xmp, 0, sizeof(xmp));
if (git_xmerge_style >= 0)
style = git_xmerge_style;
+ if (marker_size > 0)
+ xmp.marker_size = marker_size;
return xdl_merge(orig,
src1, name1,
src2, name2,
- &xpp, XDL_MERGE_FLAGS(XDL_MERGE_ZEALOUS, style, favor),
- &xmp, XDL_MERGE_ZEALOUS | style,
++ &xmp, XDL_MERGE_FLAGS(XDL_MERGE_ZEALOUS, style, favor),
result);
}
mmfile_t *orig,
mmfile_t *src1, const char *name1,
mmfile_t *src2, const char *name2,
- int flag)
- int virtual_ancestor, int marker_size)
++ int flag, int marker_size)
{
char *src, *dst;
long size;
git_xmerge_style = 0;
status = ll_xdl_merge(drv_unused, result, path_unused,
orig, src1, NULL, src2, NULL,
- flag);
- virtual_ancestor, marker_size);
++ flag, marker_size);
git_xmerge_style = saved_style;
if (status <= 0)
return status;
mmfile_t *orig,
mmfile_t *src1, const char *name1,
mmfile_t *src2, const char *name2,
- int flag)
- int virtual_ancestor, int marker_size)
++ int flag, int marker_size)
{
- char temp[3][50];
+ char temp[4][50];
struct strbuf cmd = STRBUF_INIT;
struct strbuf_expand_dict_entry dict[] = {
{ "O", temp[0] },
{ "A", temp[1] },
{ "B", temp[2] },
+ { "L", temp[3] },
{ NULL }
};
- const char *args[] = { "sh", "-c", NULL, NULL };
+ const char *args[] = { NULL, NULL };
int status, fd, i;
struct stat st;
mmfile_t *ancestor,
mmfile_t *ours, const char *our_label,
mmfile_t *theirs, const char *their_label,
- int virtual_ancestor)
+ int flag)
{
- const char *ll_driver_name;
+ static struct git_attr_check check[2];
+ const char *ll_driver_name = NULL;
+ int marker_size = DEFAULT_CONFLICT_MARKER_SIZE;
const struct ll_merge_driver *driver;
+ int virtual_ancestor = flag & 01;
- ll_driver_name = git_path_check_merge(path);
+ if (!git_path_check_merge(path, check)) {
+ ll_driver_name = check[0].value;
+ if (check[1].value) {
+ marker_size = atoi(check[1].value);
+ if (marker_size <= 0)
+ marker_size = DEFAULT_CONFLICT_MARKER_SIZE;
+ }
+ }
driver = find_ll_merge_driver(ll_driver_name);
-
if (virtual_ancestor && driver->recursive)
driver = find_ll_merge_driver(driver->recursive);
- return driver->fn(driver, result_buf, path,
- ancestor,
- ours, our_label,
- theirs, their_label, flag);
+ return driver->fn(driver, result_buf, path, ancestor,
+ ours, our_label, theirs, their_label,
- virtual_ancestor, marker_size);
++ flag, marker_size);
+ }
+
+ int ll_merge_marker_size(const char *path)
+ {
+ static struct git_attr_check check;
+ int marker_size = DEFAULT_CONFLICT_MARKER_SIZE;
+
+ if (!check.attr)
+ check.attr = git_attr("conflict-marker-size");
+ if (!git_checkattr(path, 1, &check) && check.value) {
+ marker_size = atoi(check.value);
+ if (marker_size <= 0)
+ marker_size = DEFAULT_CONFLICT_MARKER_SIZE;
+ }
+ return marker_size;
}
static int xdl_fill_merge_buffer(xdfenv_t *xe1, const char *name1,
xdfenv_t *xe2, const char *name2,
- xdmerge_t *m, char *dest, int style)
+ int favor,
+ xdmerge_t *m, char *dest, int style,
+ int marker_size)
{
int size, i;
for (size = i = 0; m; m = m->next) {
+ if (favor && !m->mode)
+ m->mode = favor;
+
if (m->mode == 0)
size = fill_conflict_hunk(xe1, name1, xe2, name2,
- size, i, style, m, dest);
+ size, i, style, m, dest,
+ marker_size);
else if (m->mode == 1)
size += xdl_recs_copy(xe1, i, m->i1 + m->chg1 - i, 0,
dest ? dest + size : NULL);
}
/* output */
if (result) {
+ int marker_size = xmp->marker_size;
int size = xdl_fill_merge_buffer(xe1, name1, xe2, name2,
- favor, changes, NULL, style);
- changes, NULL, style,
++ favor, changes, NULL, style,
+ marker_size);
result->ptr = xdl_malloc(size);
if (!result->ptr) {
xdl_cleanup_merge(changes);
return -1;
}
result->size = size;
- xdl_fill_merge_buffer(xe1, name1, xe2, name2, changes,
+ xdl_fill_merge_buffer(xe1, name1, xe2, name2, favor, changes,
- result->ptr, style);
+ result->ptr, style, marker_size);
}
return xdl_cleanup_merge(changes);
}