Skip to content

Commit

Permalink
format-patch: wrap cover-letter's shortlog sensibly
Browse files Browse the repository at this point in the history
Earlier, overly-long onelines would not be wrapped at all, and indented
with 6 spaces.

Instead, we now wrap around at 72 characters, with a first-line indent
of 2 spaces, and the rest with 4 spaces.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Johannes Schindelin authored and Junio C Hamano committed Mar 2, 2008
1 parent 5d02294 commit 859c4fb
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
4 changes: 4 additions & 0 deletions builtin-log.c
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,10 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
strbuf_release(&sb);

shortlog_init(&log);
log.wrap_lines = 1;
log.wrap = 72;
log.in1 = 2;
log.in2 = 4;
for (i = 0; i < nr; i++)
shortlog_add_commit(&log, list[i]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ Subject: [DIFFERENT_PREFIX 0/2] *** SUBJECT HERE ***
*** BLURB HERE ***

A U Thor (2):
Second
Third
Second
Third

dir/sub | 4 ++++
file0 | 3 +++
Expand Down
19 changes: 19 additions & 0 deletions t/t4014-format-patch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -211,4 +211,23 @@ test_expect_success 'cover-letter inherits diff options' '
grep "file => foo .* 0 *$" 0000-cover-letter.patch
'

cat > expect << EOF
This is an excessively long subject line for a message due to the
habit some projects have of not having a short, one-line subject at
the start of the commit message, but rather sticking a whole
paragraph right at the start as the only thing in the commit
message. It had better not become the filename for the patch.
foo
EOF

test_expect_success 'shortlog of cover-letter wraps overly-long onelines' '
git format-patch --cover-letter -2 &&
sed -e "1,/A U Thor/d" -e "/^$/q" < 0000-cover-letter.patch > output &&
git diff expect output
'

test_done

0 comments on commit 859c4fb

Please sign in to comment.