t / t4201-shortlog.shon commit Merge branch 'tc/test-locate-httpd' (f287c65)
   1#!/bin/sh
   2#
   3# Copyright (c) 2006 Johannes E. Schindelin
   4#
   5
   6test_description='git shortlog
   7'
   8
   9. ./test-lib.sh
  10
  11echo 1 > a1
  12git add a1
  13tree=$(git write-tree)
  14commit=$( (echo "Test"; echo) | git commit-tree $tree )
  15git update-ref HEAD $commit
  16
  17echo 2 > a1
  18git commit --quiet -m "This is a very, very long first line for the commit message to see if it is wrapped correctly" a1
  19
  20# test if the wrapping is still valid when replacing all i's by treble clefs.
  21echo 3 > a1
  22git 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
  23
  24# now fsck up the utf8
  25git config i18n.commitencoding non-utf-8
  26echo 4 > a1
  27git 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
  28
  29echo 5 > a1
  30git commit --quiet -m "a                                                                12      34      56      78" a1
  31
  32git shortlog -w HEAD > out
  33
  34cat > expect << EOF
  35A U Thor (5):
  36      Test
  37      This is a very, very long first line for the commit message to see if
  38         it is wrapped correctly
  39      Th𝄞s 𝄞s a very, very long f𝄞rst l𝄞ne for the comm𝄞t message to see 𝄞f
  40         𝄞t 𝄞s wrapped correctly
  41      Thø\9d\84\9es ø\9d\84\9es a very, very long fø\9d\84\9erst lø\9d\84\9ene for the commø\9d\84\9et
  42         message to see ø\9d\84\9ef ø\9d\84\9et ø\9d\84\9es wrapped correctly
  43      a                                                         12      34
  44         56     78
  45
  46EOF
  47
  48test_expect_success 'shortlog wrapping' 'test_cmp expect out'
  49
  50git log HEAD > log
  51GIT_DIR=non-existing git shortlog -w < log > out
  52
  53test_expect_success 'shortlog from non-git directory' 'test_cmp expect out'
  54
  55iconvfromutf8toiso88591() {
  56        printf "%s" "$*" | iconv -f UTF-8 -t ISO8859-1
  57}
  58
  59DSCHO="Jöhännës \"Dschö\" Schindëlin"
  60DSCHOE="$DSCHO <Johannes.Schindelin@gmx.de>"
  61MSG1="set a1 to 2 and some non-ASCII chars: Äßø"
  62MSG2="set a1 to 3 and some non-ASCII chars: áæï"
  63cat > expect << EOF
  64$DSCHO (2):
  65      $MSG1
  66      $MSG2
  67
  68EOF
  69
  70test_expect_success 'shortlog encoding' '
  71        git reset --hard "$commit" &&
  72        git config --unset i18n.commitencoding &&
  73        echo 2 > a1 &&
  74        git commit --quiet -m "$MSG1" --author="$DSCHOE" a1 &&
  75        git config i18n.commitencoding "ISO8859-1" &&
  76        echo 3 > a1 &&
  77        git commit --quiet -m "$(iconvfromutf8toiso88591 "$MSG2")" \
  78                --author="$(iconvfromutf8toiso88591 "$DSCHOE")" a1 &&
  79        git config --unset i18n.commitencoding &&
  80        git shortlog HEAD~2.. > out &&
  81test_cmp expect out'
  82
  83test_done