t / t4203-mailmap.shon commit revert: fix off by one read when searching the end of a commit subject (2c048a3)
   1#!/bin/sh
   2
   3test_description='.mailmap configurations'
   4
   5. ./test-lib.sh
   6
   7test_expect_success setup '
   8        echo one >one &&
   9        git add one &&
  10        test_tick &&
  11        git commit -m initial &&
  12        echo two >>one &&
  13        git add one &&
  14        git commit --author "nick1 <bugs@company.xx>" -m second
  15'
  16
  17cat >expect <<\EOF
  18A U Thor (1):
  19      initial
  20
  21nick1 (1):
  22      second
  23
  24EOF
  25
  26test_expect_success 'No mailmap' '
  27        git shortlog HEAD >actual &&
  28        test_cmp expect actual
  29'
  30
  31cat >expect <<\EOF
  32Repo Guy (1):
  33      initial
  34
  35nick1 (1):
  36      second
  37
  38EOF
  39
  40test_expect_success 'default .mailmap' '
  41        echo "Repo Guy <author@example.com>" > .mailmap &&
  42        git shortlog HEAD >actual &&
  43        test_cmp expect actual
  44'
  45
  46# Using a mailmap file in a subdirectory of the repo here, but
  47# could just as well have been a file outside of the repository
  48cat >expect <<\EOF
  49Internal Guy (1):
  50      second
  51
  52Repo Guy (1):
  53      initial
  54
  55EOF
  56test_expect_success 'mailmap.file set' '
  57        mkdir internal_mailmap &&
  58        echo "Internal Guy <bugs@company.xx>" > internal_mailmap/.mailmap &&
  59        git config mailmap.file internal_mailmap/.mailmap &&
  60        git shortlog HEAD >actual &&
  61        test_cmp expect actual
  62'
  63
  64cat >expect <<\EOF
  65External Guy (1):
  66      initial
  67
  68Internal Guy (1):
  69      second
  70
  71EOF
  72test_expect_success 'mailmap.file override' '
  73        echo "External Guy <author@example.com>" >> internal_mailmap/.mailmap &&
  74        git config mailmap.file internal_mailmap/.mailmap &&
  75        git shortlog HEAD >actual &&
  76        test_cmp expect actual
  77'
  78
  79cat >expect <<\EOF
  80Repo Guy (1):
  81      initial
  82
  83nick1 (1):
  84      second
  85
  86EOF
  87
  88test_expect_success 'mailmap.file non-existant' '
  89        rm internal_mailmap/.mailmap &&
  90        rmdir internal_mailmap &&
  91        git shortlog HEAD >actual &&
  92        test_cmp expect actual
  93'
  94
  95cat >expect <<\EOF
  96A U Thor (1):
  97      initial
  98
  99nick1 (1):
 100      second
 101
 102EOF
 103test_expect_success 'No mailmap files, but configured' '
 104        rm .mailmap &&
 105        git shortlog HEAD >actual &&
 106        test_cmp expect actual
 107'
 108
 109# Extended mailmap configurations should give us the following output for shortlog
 110cat >expect <<\EOF
 111A U Thor <author@example.com> (1):
 112      initial
 113
 114CTO <cto@company.xx> (1):
 115      seventh
 116
 117Other Author <other@author.xx> (2):
 118      third
 119      fourth
 120
 121Santa Claus <santa.claus@northpole.xx> (2):
 122      fifth
 123      sixth
 124
 125Some Dude <some@dude.xx> (1):
 126      second
 127
 128EOF
 129
 130test_expect_success 'Shortlog output (complex mapping)' '
 131        echo three >>one &&
 132        git add one &&
 133        test_tick &&
 134        git commit --author "nick2 <bugs@company.xx>" -m third &&
 135
 136        echo four >>one &&
 137        git add one &&
 138        test_tick &&
 139        git commit --author "nick2 <nick2@company.xx>" -m fourth &&
 140
 141        echo five >>one &&
 142        git add one &&
 143        test_tick &&
 144        git commit --author "santa <me@company.xx>" -m fifth &&
 145
 146        echo six >>one &&
 147        git add one &&
 148        test_tick &&
 149        git commit --author "claus <me@company.xx>" -m sixth &&
 150
 151        echo seven >>one &&
 152        git add one &&
 153        test_tick &&
 154        git commit --author "CTO <cto@coompany.xx>" -m seventh &&
 155
 156        mkdir internal_mailmap &&
 157        echo "Committed <committer@example.com>" > internal_mailmap/.mailmap &&
 158        echo "<cto@company.xx>                       <cto@coompany.xx>" >> internal_mailmap/.mailmap &&
 159        echo "Some Dude <some@dude.xx>         nick1 <bugs@company.xx>" >> internal_mailmap/.mailmap &&
 160        echo "Other Author <other@author.xx>   nick2 <bugs@company.xx>" >> internal_mailmap/.mailmap &&
 161        echo "Other Author <other@author.xx>         <nick2@company.xx>" >> internal_mailmap/.mailmap &&
 162        echo "Santa Claus <santa.claus@northpole.xx> <me@company.xx>" >> internal_mailmap/.mailmap &&
 163        echo "Santa Claus <santa.claus@northpole.xx> <me@company.xx>" >> internal_mailmap/.mailmap &&
 164
 165        git shortlog -e HEAD >actual &&
 166        test_cmp expect actual
 167
 168'
 169
 170# git log with --pretty format which uses the name and email mailmap placemarkers
 171cat >expect <<\EOF
 172Author CTO <cto@coompany.xx> maps to CTO <cto@company.xx>
 173Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com>
 174
 175Author claus <me@company.xx> maps to Santa Claus <santa.claus@northpole.xx>
 176Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com>
 177
 178Author santa <me@company.xx> maps to Santa Claus <santa.claus@northpole.xx>
 179Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com>
 180
 181Author nick2 <nick2@company.xx> maps to Other Author <other@author.xx>
 182Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com>
 183
 184Author nick2 <bugs@company.xx> maps to Other Author <other@author.xx>
 185Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com>
 186
 187Author nick1 <bugs@company.xx> maps to Some Dude <some@dude.xx>
 188Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com>
 189
 190Author A U Thor <author@example.com> maps to A U Thor <author@example.com>
 191Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com>
 192EOF
 193
 194test_expect_success 'Log output (complex mapping)' '
 195        git log --pretty=format:"Author %an <%ae> maps to %aN <%aE>%nCommitter %cn <%ce> maps to %cN <%cE>%n" >actual &&
 196        test_cmp expect actual
 197'
 198
 199# git blame
 200cat >expect <<\EOF
 201^3a2fdcb (A U Thor     2005-04-07 15:13:13 -0700 1) one
 2027de6f99b (Some Dude    2005-04-07 15:13:13 -0700 2) two
 2035815879d (Other Author 2005-04-07 15:14:13 -0700 3) three
 204ff859d96 (Other Author 2005-04-07 15:15:13 -0700 4) four
 2055ab6d4fa (Santa Claus  2005-04-07 15:16:13 -0700 5) five
 20638a42d8b (Santa Claus  2005-04-07 15:17:13 -0700 6) six
 2078ddc0386 (CTO          2005-04-07 15:18:13 -0700 7) seven
 208EOF
 209
 210test_expect_success 'Blame output (complex mapping)' '
 211        git blame one >actual &&
 212        test_cmp expect actual
 213'
 214
 215test_done