Skip to content

Commit dc7accd

Browse files
committed
Merge branch 'nd/format-patch-cover-letter-stat-width'
"git format-patch --stat=<width>" can be used to specify the width used by the diffstat (shown in the cover letter). * nd/format-patch-cover-letter-stat-width: format-patch: respect --stat in cover letter's diffstat
2 parents 1373999 + 284aeb7 commit dc7accd

File tree

2 files changed

+33
-17
lines changed

2 files changed

+33
-17
lines changed

builtin/log.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,8 +1011,6 @@ static void show_diffstat(struct rev_info *rev,
10111011

10121012
memcpy(&opts, &rev->diffopt, sizeof(opts));
10131013
opts.output_format = DIFF_FORMAT_SUMMARY | DIFF_FORMAT_DIFFSTAT;
1014-
opts.stat_width = MAIL_DEFAULT_WRAP;
1015-
10161014
diff_setup_done(&opts);
10171015

10181016
diff_tree_oid(get_commit_tree_oid(origin),

t/t4052-stat-output.sh

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,42 +44,50 @@ show --stat
4444
log -1 --stat
4545
EOF
4646

47-
while read cmd args
47+
cat >expect.60 <<-'EOF'
48+
...aaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1 +
49+
EOF
50+
cat >expect.6030 <<-'EOF'
51+
...aaaaaaaaaaaaaaaaaaaaaaaaaaa | 1 +
52+
EOF
53+
cat >expect2.60 <<-'EOF'
54+
...aaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1 +
55+
...aaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1 +
56+
EOF
57+
cat >expect2.6030 <<-'EOF'
58+
...aaaaaaaaaaaaaaaaaaaaaaaaaaa | 1 +
59+
...aaaaaaaaaaaaaaaaaaaaaaaaaaa | 1 +
60+
EOF
61+
while read expect cmd args
4862
do
49-
cat >expect <<-'EOF'
50-
...aaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1 +
51-
EOF
5263
test_expect_success "$cmd --stat=width: a long name is given more room when the bar is short" '
5364
git $cmd $args --stat=40 >output &&
5465
grep " | " output >actual &&
55-
test_cmp expect actual
66+
test_cmp $expect.60 actual
5667
'
5768

5869
test_expect_success "$cmd --stat-width=width with long name" '
5970
git $cmd $args --stat-width=40 >output &&
6071
grep " | " output >actual &&
61-
test_cmp expect actual
72+
test_cmp $expect.60 actual
6273
'
6374

64-
cat >expect <<-'EOF'
65-
...aaaaaaaaaaaaaaaaaaaaaaaaaaa | 1 +
66-
EOF
6775
test_expect_success "$cmd --stat=...,name-width with long name" '
6876
git $cmd $args --stat=60,30 >output &&
6977
grep " | " output >actual &&
70-
test_cmp expect actual
78+
test_cmp $expect.6030 actual
7179
'
7280

7381
test_expect_success "$cmd --stat-name-width with long name" '
7482
git $cmd $args --stat-name-width=30 >output &&
7583
grep " | " output >actual &&
76-
test_cmp expect actual
84+
test_cmp $expect.6030 actual
7785
'
7886
done <<\EOF
79-
format-patch -1 --stdout
80-
diff HEAD^ HEAD --stat
81-
show --stat
82-
log -1 --stat
87+
expect2 format-patch --cover-letter -1 --stdout
88+
expect diff HEAD^ HEAD --stat
89+
expect show --stat
90+
expect log -1 --stat
8391
EOF
8492

8593

@@ -95,6 +103,16 @@ test_expect_success 'preparation for big change tests' '
95103
git commit -m message abcd
96104
'
97105

106+
cat >expect72 <<'EOF'
107+
abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
108+
abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
109+
EOF
110+
test_expect_success "format-patch --cover-letter ignores COLUMNS (big change)" '
111+
COLUMNS=200 git format-patch -1 --stdout --cover-letter >output &&
112+
grep " | " output >actual &&
113+
test_cmp expect72 actual
114+
'
115+
98116
cat >expect72 <<'EOF'
99117
abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
100118
EOF

0 commit comments

Comments
 (0)