True, but we could do a two-pass approach, perhaps? That is
* The first pass does exactly the same as what today's code does,
PLUS it prepares for the case where we thought the log message
ended because we saw "diff -" or "Index: " before seeing "---",
by scanning for the first "---"while running handle_patch().
If there is no such "oops, a 'diff -' in the log message fooled
us" event, we complete with what today's code does.
* But if we detect such a case during the first pass, we run
ourselves again with the same input and arguments, PLUS an extra,
new option, which tells us that "we know '---' exists in the
input and it *is* the patchbreak. This of course can be done
only when the standard input is seekable, but builtin/am.c does
store the mail in a file, so...