Merge branch 'sg/completion-commit-cleanup' into maint
[gitweb.git] / wt-status.c
index 38cb165f124d610c789a8d82de42281c795111f7..078a4727435b0c6b98cdc600773cb90e850e9a7f 100644 (file)
@@ -823,10 +823,11 @@ void wt_status_truncate_message_at_cut_line(struct strbuf *buf)
        const char *p;
        struct strbuf pattern = STRBUF_INIT;
 
-       strbuf_addf(&pattern, "%c %s", comment_line_char, cut_line);
-       p = strstr(buf->buf, pattern.buf);
-       if (p && (p == buf->buf || p[-1] == '\n'))
-               strbuf_setlen(buf, p - buf->buf);
+       strbuf_addf(&pattern, "\n%c %s", comment_line_char, cut_line);
+       if (starts_with(buf->buf, pattern.buf + 1))
+               strbuf_setlen(buf, 0);
+       else if ((p = strstr(buf->buf, pattern.buf)))
+               strbuf_setlen(buf, p - buf->buf + 1);
        strbuf_release(&pattern);
 }