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