@matheusbsbs / matheus-bagliano / commits / 600372497c
Fork 0

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 <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan Nieder committed May 3, 2010 at 21:59 UTC 600372497c668045a365b9eab76987ee19405f7a
2 files changed +60 -1
Documentation/git-shortlog.txt
+8
@@ -44,6 +44,14 @@ OPTIONS
44 --email::
45 Show the email address of each author.
46
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 +
55 -w[<width>[,<indent1>[,<indent2>]]]::
56 Linewrap the output by wrapping each line at `width`. The first
57 line of each entry is indented by `indent1` spaces, and the second
t/t4201-shortlog.sh
+52 -1
@@ -39,7 +39,58 @@ test_expect_success 'setup' '
39
40 echo 6 >a1 &&
41 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
94 '
95
96 test_expect_success 'shortlog wrapping' '