tests: add 'merge' test for linux/raid5

We had the orig and the patch, but no actual tests here.
Strange.

Signed-off-by: NeilBrown <neilb@suse.de>
vpatch: fix browse of three-file merge.

Due to a flag problem, it was ignoring the second and third files.

Signed-off-by: NeilBrown <neilb@suse.de>
merge: Remove noise from --show-wiggles output.

When --show-wiggles is used with whole files (current, orig, new) and
extraneous text in orig/new (Which isn't a change, so should be
ignored) is treated as a wiggle and causes a conflict to be shown.
Obviously not good.

So insist that any show-wiggle conflict contains at leas a Changed or
a Conflict.  Also allow Changed and Unmatched to be 'near' each other,
not only on the same line, to signal a wiggle.  Current 'near' measure
is 3 lines.

Signed-off-by: NeilBrown <neilb@suse.de>
Remove duplicate definition of "csl_join"

We really only need one of these.

Signed-off-by: NeilBrown <neilb@suse.de>
vpatch: restructure draw_mside.

We have the end-of-line handing code in the middle of
a 'while', and the only return from the function is at
the end of the eol handling.  And there is nothing after the "while".

So move the eol handling code out of the while, and just put
a "break" in place of it.

No functionality change.

Signed-off-by: NeilBrown <neilb@suse.de>
discard ends_mline, just use ends_line

There is no important difference between ends_mline and ends_line (any
more), so just discard the former.

Signed-off-by: NeilBrown <neilb@suse.de>
Allow a word to have an unmatched prefix and suffix.

i.e. The part of a word that is tested for matching is
shorted than the whole word that is printed.  There can
be a prefix and a suffix.  In a future patch, an option
will be availble to include most spaces as prefix or suffix
of nearby non-space.

Signed-off-by: NeilBrown <neilb@suse.de>
vpatch: allow a word to have text before the newline.

Previously we don't print out ends_line() words at all.
But soon a word might have some content plus a newline at
the end.
So restructure the display to print non-newline characters
from any word.
Note that we cannot have characters *after* a newline.
Doing that would break too much of wiggle's formating
assumptions.

Signed-off-by: NeilBrown <neilb@suse.de>
Add --ignore-blanks option.

This can be useful when people re-flow you text or otherwise
introduce space-damange that just really isn't interesting.

Suggested-by: Tom Scogland <tom.scogland@vt.edu>
Signed-off-by: NeilBrown <neilb@suse.de>
vpatch: restore display for  hunk header where appropriate.

Recent patch broke this.

Signed-off-by: NeilBrown <neilb@suse.de>
merge: tidy up isolation of conflicts.

We want to isolate (and these count) wiggles much
like we do conflicts, but the conflict isolating
code is just confusing.

So try to make it a bit cleaner, and defined clearly
the various states.

Signed-off-by: NeilBrown <neilb@suse.de>
merge: calculate number of wiggles more accurately.

Assess wiggles the same way that we assess conflict,
and then count the number of each.
This gives more meaningful counts.

Signed-off-by: NeilBrown <neilb@suse.de>
csl_join should merge adjacent matches.

When diffing against a patch we treat each hunk separately
and join the result.
This joining doesn't merge adjacent matches so it doesn't really
tell the full story of where the matches are and how big
they are.  This can confuse other code, particularly when
examining hunk headers to create the merger.

So add detection for adjacent matches.

Signed-off-by: NeilBrown <neilb@suse.de>
merge: be more careful about aligning hunk-headers with newlines.

When matching a diff to a file, it would be very confusing.
if the last match from one hunk were on the same line of the
original as the first match of the next hunk.
So we try to align hunk-headers with newlines.

In particular, we often find Unmatched and Extraneous
sections together.  There can be encoded in any order.
If the Extraneous section contains a hunk-header,
we want to make sure that if there is a newline anywhere
in the unmatched section, then the Unmatched that is placed
before the hunk-headers Extraneous ends on a newline.

There was code the attempted this, but it was too simplistic
and would sometimes move outside the regions that it should
have been examine, which would lead to various bugs.

The tests case which demonstrated this is added to the
test suite.

Reported-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: NeilBrown <neilb@suse.de>