* jn/shortlog:
pretty: Respect --abbrev option
shortlog: Document and test --format option
t4201 (shortlog): Test output format with multiple authors
t4201 (shortlog): guard setup with test_expect_success
Documentation/shortlog: scripted users should not rely on implicit HEAD
git commit --quiet -m "This is a very, very long first line for the commit message to see if it is wrapped correctly" a1 &&
# test if the wrapping is still valid
# when replacing all is by treble clefs.
echo 3 >a1 &&
git commit --quiet -m "$(
echo "This is a very, very long first line for the commit message to see if it is wrapped correctly" |
sed "s/i/1234/g" |
tr 1234 "\360\235\204\236")" a1 &&
# now fsck up the utf8
git config i18n.commitencoding non-utf-8 &&
echo 4 >a1 &&
git commit --quiet -m "$(
echo "This is a very, very long first line for the commit message to see if it is wrapped correctly" |
sed "s/i/1234/g" |
tr 1234 "\370\235\204\236")" a1 &&
echo 5 >a1 &&
git commit --quiet -m "a 12 34 56 78" a1
echo 6 >a1 &&
git commit --quiet -m "Commit by someone else" \
--author="Someone else <not!me>" a1 &&
cat >expect.template <<-\EOF
A U Thor (5):
SUBJECT
SUBJECT
SUBJECT
SUBJECT
SUBJECT
Someone else (1):
SUBJECT
EOF
'
echo 2 > a1
git commit --quiet -m "This is a very, very long first line for the commit message to see if it is wrapped correctly" a1
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 if the wrapping is still valid when replacing all i's by treble clefs.
echo 3 > a1
git commit --quiet -m "$(echo "This is a very, very long first line for the commit message to see if it is wrapped correctly" | sed "s/i/1234/g" | tr 1234 '\360\235\204\236')" a1
test_expect_success 'default output format' '
git shortlog HEAD >log &&
fuzz log >log.predictable &&
test_cmp expect.template log.predictable
'
# now fsck up the utf8
git config i18n.commitencoding non-utf-8
echo 4 > a1
git commit --quiet -m "$(echo "This is a very, very long first line for the commit message to see if it is wrapped correctly" | sed "s/i/1234/g" | tr 1234 '\370\235\204\236')" a1
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
'
echo 5 > a1
git commit --quiet -m "a 12 34 56 78" a1
test_expect_success '--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
'
git shortlog -w HEAD > out
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
'
cat > expect << EOF
test_expect_success 'shortlog wrapping' '
cat >expect <<\EOF &&
A U Thor (5):
Test
This is a very, very long first line for the commit message to see if
@ -43,14 +106,19 @@ A U Thor (5):
@@ -43,14 +106,19 @@ A U Thor (5):
git log -1 --abbrev=5 --format="%h %h %h" HEAD >actual2 &&
git log -1 --abbrev=5 --format="%H %H %H" HEAD >actual3 &&
sed -e "s/$_x40/LONG/g" -e "s/$_x05/SHORT/g" <actual2 >fuzzy2 &&
sed -e "s/$_x40/LONG/g" -e "s/$_x05/SHORT/g" <actual3 >fuzzy3 &&
test_cmp expect2 fuzzy2 &&
test_cmp expect3 fuzzy3 &&
! test_cmp actual1 actual2
'
test_expect_success '%H is not affected by --abbrev-commit' '
git log -1 --format=%H --abbrev-commit --abbrev=20 HEAD >actual &&
len=$(wc -c <actual) &&
test $len = 41
'
test_expect_success '%h is not affected by --abbrev-commit' '
git log -1 --format=%h --abbrev-commit --abbrev=20 HEAD >actual &&
len=$(wc -c <actual) &&
test $len = 21
'
test_expect_success '"%h %gD: %gs" is same as git-reflog' '
git reflog >expect &&
git log -g --format="%h %gD: %gs" >actual &&
@ -203,6 +228,12 @@ test_expect_success '"%h %gD: %gs" is same as git-reflog (with date)' '
@@ -203,6 +228,12 @@ test_expect_success '"%h %gD: %gs" is same as git-reflog (with date)' '
test_cmp expect actual
'
test_expect_success '"%h %gD: %gs" is same as git-reflog (with --abbrev)' '