Skip to content

Commit 68f99b5

Browse files
Mroikgitster
authored andcommitted
format-patch: wrap generate_commit_list_cover()
While most conventions should not allow for the text lines in commit messages to get too long, when they do it could make emails harder to read. Teach generate_commit_list_cover() to wrap its commit lines if they happend to be too long. Signed-off-by: Mirko Faina <mroik@delayed.space> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 2f2c26d commit 68f99b5

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

builtin/log.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include "progress.h"
4141
#include "commit-slab.h"
4242
#include "advice.h"
43+
#include "utf8.h"
4344

4445
#include "commit-reach.h"
4546
#include "range-diff.h"
@@ -1364,6 +1365,7 @@ static void generate_commit_list_cover(FILE *cover_file, const char *format,
13641365
struct commit **list, int n)
13651366
{
13661367
struct strbuf commit_line = STRBUF_INIT;
1368+
struct strbuf wrapped_line = STRBUF_INIT;
13671369
struct pretty_print_context ctx = {0};
13681370
struct rev_info rev = REV_INFO_INIT;
13691371

@@ -1373,12 +1375,16 @@ static void generate_commit_list_cover(FILE *cover_file, const char *format,
13731375
rev.nr = i;
13741376
repo_format_commit_message(the_repository, list[n - i], format,
13751377
&commit_line, &ctx);
1376-
fprintf(cover_file, "%s\n", commit_line.buf);
1378+
strbuf_add_wrapped_text(&wrapped_line, commit_line.buf, 0, 0,
1379+
MAIL_DEFAULT_WRAP);
1380+
fprintf(cover_file, "%s\n", wrapped_line.buf);
13771381
strbuf_reset(&commit_line);
1382+
strbuf_reset(&wrapped_line);
13781383
}
13791384
fprintf(cover_file, "\n");
13801385

13811386
strbuf_release(&commit_line);
1387+
strbuf_release(&wrapped_line);
13821388
}
13831389

13841390
static void make_cover_letter(struct rev_info *rev, int use_separate_file,

0 commit comments

Comments
 (0)