format-patch: wrap cover-letter's shortlog sensibly
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>
Johannes Schindelin committed
Mar 2, 2008 at 15:53 UTC
859c4fbef589841585f8f21cc567b7016681df7a
3 files changed
+25
-2
builtin-log.c
+4
@@ -683,6 +683,10 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
683
strbuf_release(&sb);
684
685
shortlog_init(&log);
686
+ log.wrap_lines = 1;
687
+ log.wrap = 72;
688
+ log.in1 = 2;
689
+ log.in2 = 4;
690
for (i = 0; i < nr; i++)
691
shortlog_add_commit(&log, list[i]);
692
t/t4013/diff.format-patch_--stdout_--cover-letter_-n_initial..master^
+2
-2
@@ -7,8 +7,8 @@ Subject: [DIFFERENT_PREFIX 0/2] *** SUBJECT HERE ***
7
*** BLURB HERE ***
8
9
A U Thor (2):
10
- Second
11
- Third
10
+ Second
11
+ Third
12
13
dir/sub | 4 ++++
14
file0 | 3 +++
t/t4014-format-patch.sh
+19
@@ -211,4 +211,23 @@ test_expect_success 'cover-letter inherits diff options' '
211
grep "file => foo .* 0 *$" 0000-cover-letter.patch
212
213
'
214
+
215
+cat > expect << EOF
216
+ This is an excessively long subject line for a message due to the
217
+ habit some projects have of not having a short, one-line subject at
218
+ the start of the commit message, but rather sticking a whole
219
+ paragraph right at the start as the only thing in the commit
220
+ message. It had better not become the filename for the patch.
221
+ foo
222
+
223
+EOF
224
+
225
+test_expect_success 'shortlog of cover-letter wraps overly-long onelines' '
226
+
227
+ git format-patch --cover-letter -2 &&
228
+ sed -e "1,/A U Thor/d" -e "/^$/q" < 0000-cover-letter.patch > output &&
229
+ git diff expect output
230
+
231
+'
232
+
233
test_done