pretty: factor out skip_empty_lines()

The patch after the next one will use it.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
René Scharfe 2008-12-27 01:32:49 +01:00 committed by Junio C Hamano
parent 8104ebfe82
commit a010966844

View File

@ -181,6 +181,20 @@ static int is_empty_line(const char *line, int *len_p)
return !len; return !len;
} }
static const char *skip_empty_lines(const char *msg)
{
for (;;) {
int linelen = get_one_line(msg);
int ll = linelen;
if (!linelen)
break;
if (!is_empty_line(msg, &ll))
break;
msg += linelen;
}
return msg;
}
static void add_merge_info(enum cmit_fmt fmt, struct strbuf *sb, static void add_merge_info(enum cmit_fmt fmt, struct strbuf *sb,
const struct commit *commit, int abbrev) const struct commit *commit, int abbrev)
{ {
@ -850,15 +864,7 @@ void pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit,
} }
/* Skip excess blank lines at the beginning of body, if any... */ /* Skip excess blank lines at the beginning of body, if any... */
for (;;) { msg = skip_empty_lines(msg);
int linelen = get_one_line(msg);
int ll = linelen;
if (!linelen)
break;
if (!is_empty_line(msg, &ll))
break;
msg += linelen;
}
/* These formats treat the title line specially. */ /* These formats treat the title line specially. */
if (fmt == CMIT_FMT_ONELINE || fmt == CMIT_FMT_EMAIL) if (fmt == CMIT_FMT_ONELINE || fmt == CMIT_FMT_EMAIL)