From: Neil Brown Date: Tue, 8 May 2012 09:56:38 +0000 (+1000) Subject: merge: avoid including large Unmatched sections in a conflict. X-Git-Tag: v0.9~29 X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=cff4183fa585a1693293936e7f1035012fc0b4b0;p=wiggle.git merge: avoid including large Unmatched sections in a conflict. A large Unmatched section can just distract from the real conflict and doesn't give useful information. So if we can close the conflict before a big Unmatched, do so. Signed-off-by: NeilBrown --- diff --git a/merge2.c b/merge2.c index 20b0305..d87b89c 100644 --- a/merge2.c +++ b/merge2.c @@ -181,7 +181,7 @@ static int isolate_conflicts(struct file af, struct file bf, struct file cf, * it wasn't the first one. 'firstk' allows us * to track which newline we actually use */ - int firstk = m[j].al; + int firstk = m[j].al+1; if (words) { m[j].hi = m[j].al; break; @@ -192,7 +192,7 @@ static int isolate_conflicts(struct file af, struct file bf, struct file cf, */ for (k = m[j].al; k > 0; k--) if (ends_line(af.list[m[j].a+k-1])) { - if (firstk == m[j].al) + if (firstk >= m[j].al) firstk = k; newlines++; if (newlines >= 3) { @@ -251,10 +251,10 @@ static int isolate_conflicts(struct file af, struct file bf, struct file cf, * it wasn't the first one. 'firstk' allows us * to track which newline we actually use */ - int firstk = 0; + int firstk = -1; for (k = 0 ; k < m[j].al ; k++) if (ends_line(af.list[m[j].a+k])) { - if (firstk == 0) + if (firstk <= 0) firstk = k; newlines++; if (newlines >= 3) { @@ -262,6 +262,20 @@ static int isolate_conflicts(struct file af, struct file bf, struct file cf, break; } } + if (firstk >= 0 && + m[j+1].type == Unmatched) { + /* If this Unmatched exceeds 3 lines, just stop here */ + int p; + int nl = 0; + for (p = 0; p < m[j+1].al ; p++) + if (ends_line(af.list[m[j+1].a+p])) { + nl++; + if (nl > 3) + break; + } + if (nl > 3) + k = firstk; + } if (k < m[j].al) m[j].lo = k+1; else diff --git a/tests/linux/md-resync/merge b/tests/linux/md-resync/merge index 09928a2..fd18d0f 100644 --- a/tests/linux/md-resync/merge +++ b/tests/linux/md-resync/merge @@ -1499,6 +1499,19 @@ nomem: raid1_shrink_buffers(conf); return -ENOMEM; } +||||||| + if (!sector_nr) + if (init_resync(conf)) + return -ENOMEM; + /* +======= + if (sector_nr >= max_sector) { + close_sync(conf); + return 0; + } + + /* +>>>>>>> static void end_sync_read(struct buffer_head *bh, int uptodate) { @@ -1528,23 +1541,6 @@ static void end_sync_write(struct buffer_head *bh, int uptodate) raid1_free_buf(r1_bh); sync_request_done(sect, mddev_to_conf(mddev)); md_done_sync(mddev,size>>9, uptodate); -||||||| - if (!sector_nr) - if (init_resync(conf)) - return -ENOMEM; - /* - * If there is non-resync activity waiting for us then - * put in a delay to throttle resync. -======= - if (sector_nr >= max_sector) { - close_sync(conf); - return 0; - } - - /* - * If there is non-resync activity waiting for us then - * put in a delay to throttle resync. ->>>>>>> } }