From 6e0e28877988f8b98eb1e5cf4d4c5d29cc0b7f77 Mon Sep 17 00:00:00 2001 From: Charvi Mendiratta Date: Mon, 15 Mar 2021 13:24:31 +0530 Subject: sequencer: export and rename subject_length() This function can be used in other parts of git. Let's move the function to commit.c and also rename it to make the name of the function more generic. Mentored-by: Christian Couder Mentored-by: Phillip Wood Helped-by: Eric Sunshine Signed-off-by: Charvi Mendiratta Signed-off-by: Junio C Hamano --- sequencer.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) (limited to 'sequencer.c') diff --git a/sequencer.c b/sequencer.c index abc6d5cdfd..da7d54c7ce 100644 --- a/sequencer.c +++ b/sequencer.c @@ -1724,20 +1724,6 @@ enum todo_item_flags { TODO_EDIT_FIXUP_MSG = (1 << 2), }; -static size_t subject_length(const char *body) -{ - const char *p = body; - while (*p) { - const char *next = skip_blank_lines(p); - if (next != p) - break; - p = strchrnul(p, '\n'); - if (*p) - p++; - } - return p - body; -} - static const char first_commit_msg_str[] = N_("This is the 1st commit message:"); static const char nth_commit_msg_fmt[] = N_("This is the commit message #%d:"); static const char skip_first_commit_msg_str[] = N_("The 1st commit message will be skipped:"); @@ -1861,7 +1847,7 @@ static int append_squash_message(struct strbuf *buf, const char *body, if (starts_with(body, "amend!") || ((command == TODO_SQUASH || seen_squash(opts)) && (starts_with(body, "squash!") || starts_with(body, "fixup!")))) - commented_len = subject_length(body); + commented_len = commit_subject_length(body); strbuf_addf(buf, "\n%c ", comment_line_char); strbuf_addf(buf, _(nth_commit_msg_fmt), -- cgit v1.2.1