make union merge an xdl merge favor
The current union merge driver is implemented as an post process. But the xdl_merge code is quite capable to produce the result by itself. Therefore move it there. Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
e923eaeb90
commit
cd1d61c44f
39
ll-merge.c
39
ll-merge.c
@ -98,44 +98,11 @@ static int ll_union_merge(const struct ll_merge_driver *drv_unused,
|
|||||||
mmfile_t *src2, const char *name2,
|
mmfile_t *src2, const char *name2,
|
||||||
int flag, int marker_size)
|
int flag, int marker_size)
|
||||||
{
|
{
|
||||||
char *src, *dst;
|
/* Use union favor */
|
||||||
long size;
|
flag = (flag & 1) | (XDL_MERGE_FAVOR_UNION << 1);
|
||||||
int status, saved_style;
|
return ll_xdl_merge(drv_unused, result, path_unused,
|
||||||
|
|
||||||
/* We have to force the RCS "merge" style */
|
|
||||||
saved_style = git_xmerge_style;
|
|
||||||
git_xmerge_style = 0;
|
|
||||||
status = ll_xdl_merge(drv_unused, result, path_unused,
|
|
||||||
orig, src1, NULL, src2, NULL,
|
orig, src1, NULL, src2, NULL,
|
||||||
flag, marker_size);
|
flag, marker_size);
|
||||||
git_xmerge_style = saved_style;
|
|
||||||
if (status <= 0)
|
|
||||||
return status;
|
|
||||||
size = result->size;
|
|
||||||
src = dst = result->ptr;
|
|
||||||
while (size) {
|
|
||||||
char ch;
|
|
||||||
if ((marker_size < size) &&
|
|
||||||
(*src == '<' || *src == '=' || *src == '>')) {
|
|
||||||
int i;
|
|
||||||
ch = *src;
|
|
||||||
for (i = 0; i < marker_size; i++)
|
|
||||||
if (src[i] != ch)
|
|
||||||
goto not_a_marker;
|
|
||||||
if (src[marker_size] != '\n')
|
|
||||||
goto not_a_marker;
|
|
||||||
src += marker_size + 1;
|
|
||||||
size -= marker_size + 1;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
not_a_marker:
|
|
||||||
do {
|
|
||||||
ch = *src++;
|
|
||||||
*dst++ = ch;
|
|
||||||
size--;
|
|
||||||
} while (ch != '\n' && size);
|
|
||||||
}
|
|
||||||
result->size = dst - result->ptr;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,6 +61,7 @@ extern "C" {
|
|||||||
/* merge favor modes */
|
/* merge favor modes */
|
||||||
#define XDL_MERGE_FAVOR_OURS 1
|
#define XDL_MERGE_FAVOR_OURS 1
|
||||||
#define XDL_MERGE_FAVOR_THEIRS 2
|
#define XDL_MERGE_FAVOR_THEIRS 2
|
||||||
|
#define XDL_MERGE_FAVOR_UNION 3
|
||||||
#define XDL_MERGE_FAVOR(flags) (((flags)>>4) & 3)
|
#define XDL_MERGE_FAVOR(flags) (((flags)>>4) & 3)
|
||||||
#define XDL_MERGE_FLAGS(level, style, favor) ((level)|(style)|((favor)<<4))
|
#define XDL_MERGE_FLAGS(level, style, favor) ((level)|(style)|((favor)<<4))
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ typedef struct s_xdmerge {
|
|||||||
* 0 = conflict,
|
* 0 = conflict,
|
||||||
* 1 = no conflict, take first,
|
* 1 = no conflict, take first,
|
||||||
* 2 = no conflict, take second.
|
* 2 = no conflict, take second.
|
||||||
|
* 3 = no conflict, take both.
|
||||||
*/
|
*/
|
||||||
int mode;
|
int mode;
|
||||||
/*
|
/*
|
||||||
@ -230,14 +231,19 @@ static int xdl_fill_merge_buffer(xdfenv_t *xe1, const char *name1,
|
|||||||
size = fill_conflict_hunk(xe1, name1, xe2, name2,
|
size = fill_conflict_hunk(xe1, name1, xe2, name2,
|
||||||
size, i, style, m, dest,
|
size, i, style, m, dest,
|
||||||
marker_size);
|
marker_size);
|
||||||
else if (m->mode == 1)
|
else if (m->mode & 3) {
|
||||||
size += xdl_recs_copy(xe1, i, m->i1 + m->chg1 - i, 0,
|
/* Before conflicting part */
|
||||||
|
size += xdl_recs_copy(xe1, i, m->i1 - i, 0,
|
||||||
dest ? dest + size : NULL);
|
dest ? dest + size : NULL);
|
||||||
else if (m->mode == 2)
|
/* Postimage from side #1 */
|
||||||
size += xdl_recs_copy(xe2, m->i2 - m->i1 + i,
|
if (m->mode & 1)
|
||||||
m->i1 + m->chg2 - i, 0,
|
size += xdl_recs_copy(xe1, m->i1, m->chg1, 1,
|
||||||
dest ? dest + size : NULL);
|
dest ? dest + size : NULL);
|
||||||
else
|
/* Postimage from side #2 */
|
||||||
|
if (m->mode & 2)
|
||||||
|
size += xdl_recs_copy(xe2, m->i2, m->chg2, 1,
|
||||||
|
dest ? dest + size : NULL);
|
||||||
|
} else
|
||||||
continue;
|
continue;
|
||||||
i = m->i1 + m->chg1;
|
i = m->i1 + m->chg1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user