Skip to content

Commit 6003724

Browse files
jrngitster
authored andcommitted
shortlog: Document and test --format option
Do not document the --pretty synonym, since it takes too long to explain the name to people. Signed-off-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ed715b5 commit 6003724

File tree

2 files changed

+60
-1
lines changed

2 files changed

+60
-1
lines changed

Documentation/git-shortlog.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ OPTIONS
4444
--email::
4545
Show the email address of each author.
4646

47+
--format[='<format>']::
48+
Instead of the commit subject, use some other information to
49+
describe each commit. '<format>' can be any string accepted
50+
by the `--format` option of 'git log', such as '{asterisk} [%h] %s'.
51+
(See the "PRETTY FORMATS" section of linkgit:git-log[1].)
52+
53+
Each pretty-printed commit will be rewrapped before it is shown.
54+
4755
-w[<width>[,<indent1>[,<indent2>]]]::
4856
Linewrap the output by wrapping each line at `width`. The first
4957
line of each entry is indented by `indent1` spaces, and the second

t/t4201-shortlog.sh

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,58 @@ test_expect_success 'setup' '
3939
4040
echo 6 >a1 &&
4141
git commit --quiet -m "Commit by someone else" \
42-
--author="Someone else <not!me>" a1
42+
--author="Someone else <not!me>" a1 &&
43+
44+
cat >expect.template <<-\EOF
45+
A U Thor (5):
46+
SUBJECT
47+
SUBJECT
48+
SUBJECT
49+
SUBJECT
50+
SUBJECT
51+
52+
Someone else (1):
53+
SUBJECT
54+
55+
EOF
56+
'
57+
58+
fuzz() {
59+
file=$1 &&
60+
sed "
61+
s/$_x40/OBJECT_NAME/g
62+
s/$_x05/OBJID/g
63+
s/^ \{6\}[CTa].*/ SUBJECT/g
64+
s/^ \{8\}[^ ].*/ CONTINUATION/g
65+
" <"$file" >"$file.fuzzy" &&
66+
sed "/CONTINUATION/ d" <"$file.fuzzy"
67+
}
68+
69+
test_expect_success 'default output format' '
70+
git shortlog HEAD >log &&
71+
fuzz log >log.predictable &&
72+
test_cmp expect.template log.predictable
73+
'
74+
75+
test_expect_success 'pretty format' '
76+
sed s/SUBJECT/OBJECT_NAME/ expect.template >expect &&
77+
git shortlog --format="%H" HEAD >log &&
78+
fuzz log >log.predictable &&
79+
test_cmp expect log.predictable
80+
'
81+
82+
test_expect_failure '--abbrev' '
83+
sed s/SUBJECT/OBJID/ expect.template >expect &&
84+
git shortlog --format="%h" --abbrev=5 HEAD >log &&
85+
fuzz log >log.predictable &&
86+
test_cmp expect log.predictable
87+
'
88+
89+
test_expect_success 'output from user-defined format is re-wrapped' '
90+
sed "s/SUBJECT/two lines/" expect.template >expect &&
91+
git shortlog --format="two%nlines" HEAD >log &&
92+
fuzz log >log.predictable &&
93+
test_cmp expect log.predictable
4394
'
4495

4596
test_expect_success 'shortlog wrapping' '

0 commit comments

Comments
 (0)