aboutsummaryrefslogtreecommitdiff
path: root/xdiff
diff options
context:
space:
mode:
authorBert Wesarg <bert.wesarg@googlemail.com>2010-03-01 22:46:25 +0100
committerJunio C Hamano <gitster@pobox.com>2010-03-02 11:43:40 -0800
commitcd1d61c44fb5c3d1c8e4c19becb66d90bbb9c676 (patch)
tree339840994a9f049d433d90b73762679a6d6b0485 /xdiff
parente923eaeb901ff056421b9007adcbbce271caa7b6 (diff)
downloadgit-cd1d61c44fb5c3d1c8e4c19becb66d90bbb9c676.tar.gz
git-cd1d61c44fb5c3d1c8e4c19becb66d90bbb9c676.tar.xz
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>
Diffstat (limited to 'xdiff')
-rw-r--r--xdiff/xdiff.h1
-rw-r--r--xdiff/xmerge.c20
2 files changed, 14 insertions, 7 deletions
diff --git a/xdiff/xdiff.h b/xdiff/xdiff.h
index 3f6229edb..22614d56e 100644
--- a/xdiff/xdiff.h
+++ b/xdiff/xdiff.h
@@ -61,6 +61,7 @@ extern "C" {
/* merge favor modes */
#define XDL_MERGE_FAVOR_OURS 1
#define XDL_MERGE_FAVOR_THEIRS 2
+#define XDL_MERGE_FAVOR_UNION 3
#define XDL_MERGE_FAVOR(flags) (((flags)>>4) & 3)
#define XDL_MERGE_FLAGS(level, style, favor) ((level)|(style)|((favor)<<4))
diff --git a/xdiff/xmerge.c b/xdiff/xmerge.c
index 8cbe45e67..c901ecb99 100644
--- a/xdiff/xmerge.c
+++ b/xdiff/xmerge.c
@@ -28,6 +28,7 @@ typedef struct s_xdmerge {
* 0 = conflict,
* 1 = no conflict, take first,
* 2 = no conflict, take second.
+ * 3 = no conflict, take both.
*/
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, i, style, m, dest,
marker_size);
- else if (m->mode == 1)
- size += xdl_recs_copy(xe1, i, m->i1 + m->chg1 - i, 0,
+ else if (m->mode & 3) {
+ /* Before conflicting part */
+ size += xdl_recs_copy(xe1, i, m->i1 - i, 0,
dest ? dest + size : NULL);
- else if (m->mode == 2)
- size += xdl_recs_copy(xe2, m->i2 - m->i1 + i,
- m->i1 + m->chg2 - i, 0,
- dest ? dest + size : NULL);
- else
+ /* Postimage from side #1 */
+ if (m->mode & 1)
+ size += xdl_recs_copy(xe1, m->i1, m->chg1, 1,
+ dest ? dest + size : NULL);
+ /* Postimage from side #2 */
+ if (m->mode & 2)
+ size += xdl_recs_copy(xe2, m->i2, m->chg2, 1,
+ dest ? dest + size : NULL);
+ } else
continue;
i = m->i1 + m->chg1;
}