summaryrefslogtreecommitdiff
path: root/t/t4201-shortlog.sh
diff options
context:
space:
mode:
authorJonathan Nieder <jrnieder@gmail.com>2010-05-03 21:59:55 -0500
committerJunio C Hamano <gitster@pobox.com>2010-05-04 15:30:59 -0700
commit600372497c668045a365b9eab76987ee19405f7a (patch)
tree72d801386920eca2a7e145597eb5d395d2219f18 /t/t4201-shortlog.sh
parented715b5e393f922b7726460c348c8cb7eb7de49b (diff)
downloadgit-600372497c668045a365b9eab76987ee19405f7a.tar.gz
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>
Diffstat (limited to 't/t4201-shortlog.sh')
-rwxr-xr-xt/t4201-shortlog.sh53
1 files changed, 52 insertions, 1 deletions
diff --git a/t/t4201-shortlog.sh b/t/t4201-shortlog.sh
index 6bfd0c0582..13fdeb2653 100755
--- a/t/t4201-shortlog.sh
+++ b/t/t4201-shortlog.sh
@@ -39,7 +39,58 @@ test_expect_success 'setup' '
echo 6 >a1 &&
git commit --quiet -m "Commit by someone else" \
- --author="Someone else <not!me>" a1
+ --author="Someone else <not!me>" a1 &&
+
+ cat >expect.template <<-\EOF
+ A U Thor (5):
+ SUBJECT
+ SUBJECT
+ SUBJECT
+ SUBJECT
+ SUBJECT
+
+ Someone else (1):
+ SUBJECT
+
+ EOF
+'
+
+fuzz() {
+ file=$1 &&
+ sed "
+ s/$_x40/OBJECT_NAME/g
+ s/$_x05/OBJID/g
+ s/^ \{6\}[CTa].*/ SUBJECT/g
+ s/^ \{8\}[^ ].*/ CONTINUATION/g
+ " <"$file" >"$file.fuzzy" &&
+ sed "/CONTINUATION/ d" <"$file.fuzzy"
+}
+
+test_expect_success 'default output format' '
+ git shortlog HEAD >log &&
+ fuzz log >log.predictable &&
+ test_cmp expect.template log.predictable
+'
+
+test_expect_success 'pretty format' '
+ sed s/SUBJECT/OBJECT_NAME/ expect.template >expect &&
+ git shortlog --format="%H" HEAD >log &&
+ fuzz log >log.predictable &&
+ test_cmp expect log.predictable
+'
+
+test_expect_failure '--abbrev' '
+ sed s/SUBJECT/OBJID/ expect.template >expect &&
+ git shortlog --format="%h" --abbrev=5 HEAD >log &&
+ fuzz log >log.predictable &&
+ test_cmp expect log.predictable
+'
+
+test_expect_success 'output from user-defined format is re-wrapped' '
+ sed "s/SUBJECT/two lines/" expect.template >expect &&
+ git shortlog --format="two%nlines" HEAD >log &&
+ fuzz log >log.predictable &&
+ test_cmp expect log.predictable
'
test_expect_success 'shortlog wrapping' '