aboutsummaryrefslogtreecommitdiff
path: root/pretty.c
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2016-06-22 22:20:16 +0200
committerJunio C Hamano <gitster@pobox.com>2016-06-22 13:23:56 -0700
commit77356122443039b4b65a7795d66b3d1fdeedcce8 (patch)
tree103dea05a387fe15c1851aa2edebb2bc67087a33 /pretty.c
parent765428699a5381f113d19974720bc91b5bfeaf1d (diff)
downloadgit-77356122443039b4b65a7795d66b3d1fdeedcce8.tar.gz
git-77356122443039b4b65a7795d66b3d1fdeedcce8.tar.xz
pretty: make the skip_blank_lines() function public
This function will be used also in the find_commit_subject() function. While at it, rename the function to reflect that it skips not only empty lines, but any lines consisting of only whitespace, too. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'pretty.c')
-rw-r--r--pretty.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/pretty.c b/pretty.c
index 7b4930418..0d40b1b0b 100644
--- a/pretty.c
+++ b/pretty.c
@@ -505,7 +505,7 @@ void pp_user_info(struct pretty_print_context *pp,
}
}
-static int is_empty_line(const char *line, int *len_p)
+static int is_blank_line(const char *line, int *len_p)
{
int len = *len_p;
while (len && isspace(line[len - 1]))
@@ -514,14 +514,14 @@ static int is_empty_line(const char *line, int *len_p)
return !len;
}
-static const char *skip_empty_lines(const char *msg)
+const char *skip_blank_lines(const char *msg)
{
for (;;) {
int linelen = get_one_line(msg);
int ll = linelen;
if (!linelen)
break;
- if (!is_empty_line(msg, &ll))
+ if (!is_blank_line(msg, &ll))
break;
msg += linelen;
}
@@ -872,7 +872,7 @@ const char *format_subject(struct strbuf *sb, const char *msg,
int linelen = get_one_line(line);
msg += linelen;
- if (!linelen || is_empty_line(line, &linelen))
+ if (!linelen || is_blank_line(line, &linelen))
break;
if (!sb)
@@ -891,11 +891,11 @@ static void parse_commit_message(struct format_commit_context *c)
const char *msg = c->message + c->message_off;
const char *start = c->message;
- msg = skip_empty_lines(msg);
+ msg = skip_blank_lines(msg);
c->subject_off = msg - start;
msg = format_subject(NULL, msg, NULL);
- msg = skip_empty_lines(msg);
+ msg = skip_blank_lines(msg);
c->body_off = msg - start;
c->commit_message_parsed = 1;
@@ -1642,7 +1642,7 @@ void pp_remainder(struct pretty_print_context *pp,
if (!linelen)
break;
- if (is_empty_line(line, &linelen)) {
+ if (is_blank_line(line, &linelen)) {
if (first)
continue;
if (pp->fmt == CMIT_FMT_SHORT)
@@ -1709,7 +1709,7 @@ void pretty_print_commit(struct pretty_print_context *pp,
}
/* Skip excess blank lines at the beginning of body, if any... */
- msg = skip_empty_lines(msg);
+ msg = skip_blank_lines(msg);
/* These formats treat the title line specially. */
if (pp->fmt == CMIT_FMT_ONELINE || pp->fmt == CMIT_FMT_EMAIL)