diff --git a/xdiff/xmerge.c b/xdiff/xmerge.c
index 1fe7a1b060324f1382c924ba961d983b61d49c02..b83b3348cc3aab66b13cb565a0a0fabaef4b689b 100644 (file)
--- a/xdiff/xmerge.c
+++ b/xdiff/xmerge.c
long i1, long chg1, long i2, long chg2)
{
xdmerge_t *m = *merge;
long i1, long chg1, long i2, long chg2)
{
xdmerge_t *m = *merge;
- if (m && mode == m->mode &&
- (i1 == m->i1 + m->chg1 || i2 == m->i2 + m->chg2)) {
+ if (m && (i1 <= m->i1 + m->chg1 || i2 <= m->i2 + m->chg2)) {
+ if (mode != m->mode)
+ m->mode = 0;
m->chg1 = i1 + chg1 - m->i1;
m->chg2 = i2 + chg2 - m->i2;
} else {
m->chg1 = i1 + chg1 - m->i1;
m->chg2 = i2 + chg2 - m->i2;
} else {
size += xdl_recs_copy(xe2, m->i2 - m->i1 + i1,
m->i1 + m->chg2 - i1, 0,
dest ? dest + size : NULL);
size += xdl_recs_copy(xe2, m->i2 - m->i1 + i1,
m->i1 + m->chg2 - i1, 0,
dest ? dest + size : NULL);
+ else
+ continue;
i1 = m->i1 + m->chg1;
}
size += xdl_recs_copy(xe1, i1, xe1->xdf2.nrec - i1, 0,
i1 = m->i1 + m->chg1;
}
size += xdl_recs_copy(xe1, i1, xe1->xdf2.nrec - i1, 0,
if (m->mode)
continue;
if (m->mode)
continue;
+ /* no sense refining a conflict when one side is empty */
+ if (m->chg1 == 0 || m->chg2 == 0)
+ continue;
+
/*
* This probably does not work outside git, since
* we have a very simple mmfile structure.
/*
* This probably does not work outside git, since
* we have a very simple mmfile structure.
return -1;
}
if (!xscr) {
return -1;
}
if (!xscr) {
- /* If this happens, it's a bug. */
+ /* If this happens, the changes are identical. */
xdl_free_env(&xe);
xdl_free_env(&xe);
- return -2;
+ m->mode = 4;
+ continue;
}
x = xscr;
m->i1 = xscr->i1 + i1;
}
x = xscr;
m->i1 = xscr->i1 + i1;
i1 = xscr1->i1 + xscr1->chg1;
i2 = xscr2->i1 + xscr2->chg1;
i1 = xscr1->i1 + xscr1->chg1;
i2 = xscr2->i1 + xscr2->chg1;
- if (i1 > i2) {
- xscr1->chg1 -= i1 - i2;
- xscr1->i1 = i2;
- xscr1->i2 += xscr1->chg2;
- xscr1->chg2 = 0;
+ if (i1 >= i2)
xscr2 = xscr2->next;
xscr2 = xscr2->next;
- } else if (i2 > i1) {
- xscr2->chg1 -= i2 - i1;
- xscr2->i1 = i1;
- xscr2->i2 += xscr2->chg2;
- xscr2->chg2 = 0;
+ if (i2 >= i1)
xscr1 = xscr1->next;
xscr1 = xscr1->next;
- } else {
- xscr1 = xscr1->next;
- xscr2 = xscr2->next;
- }
}
while (xscr1) {
if (!changes)
}
while (xscr1) {
if (!changes)