@@ -1649,7 +1649,7 @@ const char *find_commit_header(const char *msg, const char *key, size_t *out_len
16491649}
16501650
16511651/*
1652- * Inspect sb and determine the true "end" of the log message, in
1652+ * Inspect the given string and determine the true "end" of the log message, in
16531653 * order to find where to put a new Signed-off-by: line. Ignored are
16541654 * trailing comment lines and blank lines, and also the traditional
16551655 * "Conflicts:" block that is not commented out, so that we can use
@@ -1659,37 +1659,37 @@ const char *find_commit_header(const char *msg, const char *key, size_t *out_len
16591659 * Returns the number of bytes from the tail to ignore, to be fed as
16601660 * the second parameter to append_signoff().
16611661 */
1662- int ignore_non_trailer (struct strbuf * sb )
1662+ int ignore_non_trailer (const char * buf , size_t len )
16631663{
16641664 int boc = 0 ;
16651665 int bol = 0 ;
16661666 int in_old_conflicts_block = 0 ;
16671667
1668- while (bol < sb -> len ) {
1669- char * next_line ;
1668+ while (bol < len ) {
1669+ const char * next_line = memchr ( buf + bol , '\n' , len - bol ) ;
16701670
1671- if (!( next_line = memchr ( sb -> buf + bol , '\n' , sb -> len - bol )) )
1672- next_line = sb -> buf + sb -> len ;
1671+ if (!next_line )
1672+ next_line = buf + len ;
16731673 else
16741674 next_line ++ ;
16751675
1676- if (sb -> buf [bol ] == comment_line_char || sb -> buf [bol ] == '\n' ) {
1676+ if (buf [bol ] == comment_line_char || buf [bol ] == '\n' ) {
16771677 /* is this the first of the run of comments? */
16781678 if (!boc )
16791679 boc = bol ;
16801680 /* otherwise, it is just continuing */
1681- } else if (starts_with (sb -> buf + bol , "Conflicts:\n" )) {
1681+ } else if (starts_with (buf + bol , "Conflicts:\n" )) {
16821682 in_old_conflicts_block = 1 ;
16831683 if (!boc )
16841684 boc = bol ;
1685- } else if (in_old_conflicts_block && sb -> buf [bol ] == '\t' ) {
1685+ } else if (in_old_conflicts_block && buf [bol ] == '\t' ) {
16861686 ; /* a pathname in the conflicts block */
16871687 } else if (boc ) {
16881688 /* the previous was not trailing comment */
16891689 boc = 0 ;
16901690 in_old_conflicts_block = 0 ;
16911691 }
1692- bol = next_line - sb -> buf ;
1692+ bol = next_line - buf ;
16931693 }
1694- return boc ? sb -> len - boc : 0 ;
1694+ return boc ? len - boc : 0 ;
16951695}
0 commit comments