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 --- commit.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'commit.c') diff --git a/commit.c b/commit.c index bab8d5ab07..199c7e274c 100644 --- a/commit.c +++ b/commit.c @@ -535,6 +535,20 @@ int find_commit_subject(const char *commit_buffer, const char **subject) return eol - p; } +size_t commit_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; +} + struct commit_list *commit_list_insert(struct commit *item, struct commit_list **list_p) { struct commit_list *new_list = xmalloc(sizeof(struct commit_list)); -- cgit v1.2.3