Fix StackOverflowError during cherry-pick submit

Using a regex pattern of "^(\n|.)*\n..." causes the Java regex package
to recurse for each consideration of the first alternation, creating a
very deep stack for a relatively short commit message.  If the message
is large enough, the thread stack overflows, and an exception is thrown.

Instead we use a more customized parser, to examine the message end and
determine if an LF should be appended, or not.

Bug: GERRIT-207
Signed-off-by: Shawn O. Pearce <sop@google.com>
1 file changed