assertEquals(0, footers.size());
}
+ @Test
+ public void testNoFooters_noRawMsg_SingleLineNoHeaders() {
+ String noRawMsg = "commit message with no header lines\n";
+ List<FooterLine> footers = FooterLine.fromMessage(noRawMsg);
+ assertNotNull(footers);
+ assertEquals(0, footers.size());
+ }
+
+ @Test
+ public void testOneFooter_noRawMsg_MultiParagraphNoHeaders() {
+ String noRawMsg = "subject\n\n"
+ + "Not: footer\n\n"
+ + "Footer: value\n";
+ List<FooterLine> footers = FooterLine.fromMessage(noRawMsg);
+ assertNotNull(footers);
+ assertEquals(1, footers.size());
+ }
+
@Test
public void testSignedOffBy_OneUserNoLF() {
String msg = buildMessage("subject\n\nbody of commit\n" + "\n"
// Search for the beginning of last paragraph
int parStart = parEnd;
- for (; parStart > msgB && (raw[parStart - 1] != '\n' || raw[parStart - 2] != '\n'); --parStart) {
- // empty
+ for (; parStart > msgB; --parStart) {
+ if (parStart < 2) {
+ // Too close to beginning: this is not a raw message
+ parStart = 0;
+ break;
+ }
+ if (raw[parStart - 1] == '\n' && raw[parStart - 2] == '\n') {
+ break;
+ }
}
for (int ptr = parStart; ptr < parEnd;) {
}
// Skip over the ': *' at the end of the key before the value.
- int valStart, valEnd;
+ int valStart;
+ int valEnd;
for (valStart = keyEnd + 1; valStart < raw.length
&& raw[valStart] == ' '; ++valStart) {
// empty