common progress display support
[gitweb.git] / xdiff / xmerge.c
index 352207e5168135f3c6306968f03a8d191d6ac2bb..b83b3348cc3aab66b13cb565a0a0fabaef4b689b 100644 (file)
@@ -166,6 +166,8 @@ static int xdl_fill_merge_buffer(xdfenv_t *xe1, const char *name1,
                        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,
@@ -190,6 +192,10 @@ static int xdl_refine_conflicts(xdfenv_t *xe1, xdfenv_t *xe2, xdmerge_t *m,
                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.
@@ -209,9 +215,10 @@ static int xdl_refine_conflicts(xdfenv_t *xe1, xdfenv_t *xe2, xdmerge_t *m,
                        return -1;
                }
                if (!xscr) {
-                       /* If this happens, it's a bug. */
+                       /* If this happens, the changes are identical. */
                        xdl_free_env(&xe);
-                       return -2;
+                       m->mode = 4;
+                       continue;
                }
                x = xscr;
                m->i1 = xscr->i1 + i1;