+/*
+ * Inspect sb and determine the true "end" of the log message, in
+ * order to find where to put a new Signed-off-by: line. Ignored are
+ * trailing "Conflict:" block.
+ *
+ * Returns the number of bytes from the tail to ignore, to be fed as
+ * the second parameter to append_signoff().
+ */
+static int ignore_non_trailer(struct strbuf *sb)
+{
+ int ignore_footer = 0;
+ int i, eol, previous = 0;
+ const char *nl;
+
+ for (i = 0; i < sb->len; i++) {
+ nl = memchr(sb->buf + i, '\n', sb->len - i);
+ if (nl)
+ eol = nl - sb->buf;
+ else
+ eol = sb->len;
+ if (!prefixcmp(sb->buf + previous, "\nConflicts:\n")) {
+ ignore_footer = sb->len - previous;
+ break;
+ }
+ while (i < eol)
+ i++;
+ previous = eol;
+ }
+ return ignore_footer;
+}
+