Johannes Schindelin | 3714e7c | 2006-12-22 22:15:59 +0100 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # Copyright (c) 2006 Johannes E. Schindelin |
| 4 | # |
| 5 | |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 6 | test_description='git shortlog |
Johannes Schindelin | 3714e7c | 2006-12-22 22:15:59 +0100 | [diff] [blame] | 7 | ' |
| 8 | |
Johannes Schindelin | 8f37854 | 2020-11-18 23:44:27 +0000 | [diff] [blame] | 9 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
Johannes Schindelin | 334afbc | 2020-11-18 23:44:19 +0000 | [diff] [blame] | 10 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
| 11 | |
Johannes Schindelin | 3714e7c | 2006-12-22 22:15:59 +0100 | [diff] [blame] | 12 | . ./test-lib.sh |
| 13 | |
Jonathan Nieder | ae00dc1 | 2010-05-03 21:57:36 -0500 | [diff] [blame] | 14 | test_expect_success 'setup' ' |
Charles Bailey | 5555a2a | 2017-11-12 15:25:23 +0000 | [diff] [blame] | 15 | test_tick && |
Jonathan Nieder | ae00dc1 | 2010-05-03 21:57:36 -0500 | [diff] [blame] | 16 | echo 1 >a1 && |
| 17 | git add a1 && |
| 18 | tree=$(git write-tree) && |
| 19 | commit=$(printf "%s\n" "Test" "" | git commit-tree "$tree") && |
| 20 | git update-ref HEAD "$commit" && |
Johannes Schindelin | 3714e7c | 2006-12-22 22:15:59 +0100 | [diff] [blame] | 21 | |
Jonathan Nieder | ae00dc1 | 2010-05-03 21:57:36 -0500 | [diff] [blame] | 22 | echo 2 >a1 && |
| 23 | git commit --quiet -m "This is a very, very long first line for the commit message to see if it is wrapped correctly" a1 && |
Johannes Schindelin | 3714e7c | 2006-12-22 22:15:59 +0100 | [diff] [blame] | 24 | |
Jonathan Nieder | ae00dc1 | 2010-05-03 21:57:36 -0500 | [diff] [blame] | 25 | # test if the wrapping is still valid |
| 26 | # when replacing all is by treble clefs. |
| 27 | echo 3 >a1 && |
| 28 | git commit --quiet -m "$( |
| 29 | echo "This is a very, very long first line for the commit message to see if it is wrapped correctly" | |
| 30 | sed "s/i/1234/g" | |
| 31 | tr 1234 "\360\235\204\236")" a1 && |
Johannes Schindelin | 3714e7c | 2006-12-22 22:15:59 +0100 | [diff] [blame] | 32 | |
Jonathan Nieder | ae00dc1 | 2010-05-03 21:57:36 -0500 | [diff] [blame] | 33 | # now fsck up the utf8 |
| 34 | git config i18n.commitencoding non-utf-8 && |
| 35 | echo 4 >a1 && |
| 36 | git commit --quiet -m "$( |
| 37 | echo "This is a very, very long first line for the commit message to see if it is wrapped correctly" | |
| 38 | sed "s/i/1234/g" | |
| 39 | tr 1234 "\370\235\204\236")" a1 && |
Johannes Schindelin | 3714e7c | 2006-12-22 22:15:59 +0100 | [diff] [blame] | 40 | |
Jonathan Nieder | ae00dc1 | 2010-05-03 21:57:36 -0500 | [diff] [blame] | 41 | echo 5 >a1 && |
Jonathan Nieder | a48fcd8 | 2010-10-30 20:46:54 -0500 | [diff] [blame] | 42 | git commit --quiet -m "a 12 34 56 78" a1 && |
Jonathan Nieder | ed715b5 | 2010-05-03 21:58:04 -0500 | [diff] [blame] | 43 | |
| 44 | echo 6 >a1 && |
| 45 | git commit --quiet -m "Commit by someone else" \ |
Jonathan Nieder | 6003724 | 2010-05-03 21:59:55 -0500 | [diff] [blame] | 46 | --author="Someone else <not!me>" a1 && |
| 47 | |
| 48 | cat >expect.template <<-\EOF |
| 49 | A U Thor (5): |
| 50 | SUBJECT |
| 51 | SUBJECT |
| 52 | SUBJECT |
| 53 | SUBJECT |
| 54 | SUBJECT |
| 55 | |
| 56 | Someone else (1): |
| 57 | SUBJECT |
| 58 | |
| 59 | EOF |
| 60 | ' |
| 61 | |
| 62 | fuzz() { |
| 63 | file=$1 && |
| 64 | sed " |
brian m. carlson | 2ece6ad | 2018-05-13 02:24:15 +0000 | [diff] [blame] | 65 | s/$OID_REGEX/OBJECT_NAME/g |
Charles Bailey | 5555a2a | 2017-11-12 15:25:23 +0000 | [diff] [blame] | 66 | s/$_x35/OBJID/g |
Jonathan Nieder | 6003724 | 2010-05-03 21:59:55 -0500 | [diff] [blame] | 67 | s/^ \{6\}[CTa].*/ SUBJECT/g |
| 68 | s/^ \{8\}[^ ].*/ CONTINUATION/g |
| 69 | " <"$file" >"$file.fuzzy" && |
| 70 | sed "/CONTINUATION/ d" <"$file.fuzzy" |
| 71 | } |
| 72 | |
| 73 | test_expect_success 'default output format' ' |
| 74 | git shortlog HEAD >log && |
| 75 | fuzz log >log.predictable && |
| 76 | test_cmp expect.template log.predictable |
| 77 | ' |
| 78 | |
| 79 | test_expect_success 'pretty format' ' |
| 80 | sed s/SUBJECT/OBJECT_NAME/ expect.template >expect && |
| 81 | git shortlog --format="%H" HEAD >log && |
| 82 | fuzz log >log.predictable && |
| 83 | test_cmp expect log.predictable |
| 84 | ' |
| 85 | |
Jeff King | 251554c | 2022-10-24 14:55:30 -0400 | [diff] [blame] | 86 | test_expect_success 'pretty format (with --date)' ' |
| 87 | sed "s/SUBJECT/2005-04-07 OBJECT_NAME/" expect.template >expect && |
| 88 | git shortlog --format="%ad %H" --date=short HEAD >log && |
| 89 | fuzz log >log.predictable && |
| 90 | test_cmp expect log.predictable |
| 91 | ' |
| 92 | |
Will Palmer | c197702 | 2010-05-03 22:18:57 -0500 | [diff] [blame] | 93 | test_expect_success '--abbrev' ' |
Jonathan Nieder | 6003724 | 2010-05-03 21:59:55 -0500 | [diff] [blame] | 94 | sed s/SUBJECT/OBJID/ expect.template >expect && |
Charles Bailey | 5555a2a | 2017-11-12 15:25:23 +0000 | [diff] [blame] | 95 | git shortlog --format="%h" --abbrev=35 HEAD >log && |
Jonathan Nieder | 6003724 | 2010-05-03 21:59:55 -0500 | [diff] [blame] | 96 | fuzz log >log.predictable && |
| 97 | test_cmp expect log.predictable |
| 98 | ' |
| 99 | |
| 100 | test_expect_success 'output from user-defined format is re-wrapped' ' |
| 101 | sed "s/SUBJECT/two lines/" expect.template >expect && |
| 102 | git shortlog --format="two%nlines" HEAD >log && |
| 103 | fuzz log >log.predictable && |
| 104 | test_cmp expect log.predictable |
Jonathan Nieder | ae00dc1 | 2010-05-03 21:57:36 -0500 | [diff] [blame] | 105 | ' |
Johannes Schindelin | 3714e7c | 2006-12-22 22:15:59 +0100 | [diff] [blame] | 106 | |
Junio C Hamano | f57a871 | 2014-07-21 15:09:27 -0700 | [diff] [blame] | 107 | test_expect_success !MINGW 'shortlog wrapping' ' |
Jonathan Nieder | ae00dc1 | 2010-05-03 21:57:36 -0500 | [diff] [blame] | 108 | cat >expect <<\EOF && |
Johannes Schindelin | 3714e7c | 2006-12-22 22:15:59 +0100 | [diff] [blame] | 109 | A U Thor (5): |
| 110 | Test |
| 111 | This is a very, very long first line for the commit message to see if |
| 112 | it is wrapped correctly |
| 113 | Thðs ðs a very, very long fðrst lðne for the commðt message to see ðf |
| 114 | ðt ðs wrapped correctly |
| 115 | Thøs øs a very, very long først løne for the commøt |
| 116 | message to see øf øt øs wrapped correctly |
| 117 | a 12 34 |
| 118 | 56 78 |
| 119 | |
Jonathan Nieder | ed715b5 | 2010-05-03 21:58:04 -0500 | [diff] [blame] | 120 | Someone else (1): |
| 121 | Commit by someone else |
| 122 | |
Johannes Schindelin | 3714e7c | 2006-12-22 22:15:59 +0100 | [diff] [blame] | 123 | EOF |
Jonathan Nieder | ae00dc1 | 2010-05-03 21:57:36 -0500 | [diff] [blame] | 124 | git shortlog -w HEAD >out && |
| 125 | test_cmp expect out |
| 126 | ' |
Johannes Schindelin | 3714e7c | 2006-12-22 22:15:59 +0100 | [diff] [blame] | 127 | |
Junio C Hamano | f57a871 | 2014-07-21 15:09:27 -0700 | [diff] [blame] | 128 | test_expect_success !MINGW 'shortlog from non-git directory' ' |
Junio C Hamano | 0893eec | 2016-03-29 15:49:24 -0700 | [diff] [blame] | 129 | git log --no-expand-tabs HEAD >log && |
Jonathan Nieder | ae00dc1 | 2010-05-03 21:57:36 -0500 | [diff] [blame] | 130 | GIT_DIR=non-existing git shortlog -w <log >out && |
| 131 | test_cmp expect out |
| 132 | ' |
Jonas Fonseca | abe549e | 2008-03-14 22:35:24 +0100 | [diff] [blame] | 133 | |
Jeff King | 5c3894c | 2016-01-18 15:02:40 -0500 | [diff] [blame] | 134 | test_expect_success !MINGW 'shortlog can read --format=raw output' ' |
| 135 | git log --format=raw HEAD >log && |
| 136 | GIT_DIR=non-existing git shortlog -w <log >out && |
| 137 | test_cmp expect out |
| 138 | ' |
| 139 | |
Martin Ågren | 4aa0161 | 2018-03-14 22:34:19 +0100 | [diff] [blame] | 140 | test_expect_success 'shortlog from non-git directory refuses extra arguments' ' |
| 141 | test_must_fail env GIT_DIR=non-existing git shortlog foo 2>out && |
Junio C Hamano | 6789275 | 2023-10-31 14:23:30 +0900 | [diff] [blame] | 142 | test_grep "too many arguments" out |
Martin Ågren | 4aa0161 | 2018-03-14 22:34:19 +0100 | [diff] [blame] | 143 | ' |
| 144 | |
Steffen Prohaska | 5b59708 | 2012-12-11 06:59:21 +0100 | [diff] [blame] | 145 | test_expect_success 'shortlog should add newline when input line matches wraplen' ' |
| 146 | cat >expect <<\EOF && |
| 147 | A U Thor (2): |
| 148 | bbbbbbbbbbbbbbbbbb: bbbbbbbb bbb bbbb bbbbbbb bb bbbb bbb bbbbb bbbbbb |
| 149 | aaaaaaaaaaaaaaaaaaaaaa: aaaaaa aaaaaaaaaa aaaa aaaaaaaa aa aaaa aa aaa |
| 150 | |
| 151 | EOF |
| 152 | git shortlog -w >out <<\EOF && |
| 153 | commit 0000000000000000000000000000000000000001 |
| 154 | Author: A U Thor <author@example.com> |
| 155 | Date: Thu Apr 7 15:14:13 2005 -0700 |
| 156 | |
| 157 | aaaaaaaaaaaaaaaaaaaaaa: aaaaaa aaaaaaaaaa aaaa aaaaaaaa aa aaaa aa aaa |
| 158 | |
| 159 | commit 0000000000000000000000000000000000000002 |
| 160 | Author: A U Thor <author@example.com> |
| 161 | Date: Thu Apr 7 15:14:13 2005 -0700 |
| 162 | |
| 163 | bbbbbbbbbbbbbbbbbb: bbbbbbbb bbb bbbb bbbbbbb bb bbbb bbb bbbbb bbbbbb |
| 164 | |
| 165 | EOF |
| 166 | test_cmp expect out |
| 167 | ' |
| 168 | |
Uwe Kleine-König | 79f7ca0 | 2009-11-25 20:33:28 +0100 | [diff] [blame] | 169 | iconvfromutf8toiso88591() { |
Brandon Casey | 3994e8a | 2009-12-03 11:52:45 -0600 | [diff] [blame] | 170 | printf "%s" "$*" | iconv -f UTF-8 -t ISO8859-1 |
Uwe Kleine-König | 79f7ca0 | 2009-11-25 20:33:28 +0100 | [diff] [blame] | 171 | } |
| 172 | |
| 173 | DSCHO="Jöhännës \"Dschö\" Schindëlin" |
| 174 | DSCHOE="$DSCHO <Johannes.Schindelin@gmx.de>" |
| 175 | MSG1="set a1 to 2 and some non-ASCII chars: ÃÃø" |
| 176 | MSG2="set a1 to 3 and some non-ASCII chars: áæï" |
| 177 | cat > expect << EOF |
| 178 | $DSCHO (2): |
| 179 | $MSG1 |
| 180 | $MSG2 |
| 181 | |
| 182 | EOF |
| 183 | |
Junio C Hamano | f57a871 | 2014-07-21 15:09:27 -0700 | [diff] [blame] | 184 | test_expect_success !MINGW 'shortlog encoding' ' |
Uwe Kleine-König | 79f7ca0 | 2009-11-25 20:33:28 +0100 | [diff] [blame] | 185 | git reset --hard "$commit" && |
| 186 | git config --unset i18n.commitencoding && |
| 187 | echo 2 > a1 && |
| 188 | git commit --quiet -m "$MSG1" --author="$DSCHOE" a1 && |
Brandon Casey | 3994e8a | 2009-12-03 11:52:45 -0600 | [diff] [blame] | 189 | git config i18n.commitencoding "ISO8859-1" && |
Uwe Kleine-König | 79f7ca0 | 2009-11-25 20:33:28 +0100 | [diff] [blame] | 190 | echo 3 > a1 && |
| 191 | git commit --quiet -m "$(iconvfromutf8toiso88591 "$MSG2")" \ |
| 192 | --author="$(iconvfromutf8toiso88591 "$DSCHOE")" a1 && |
| 193 | git config --unset i18n.commitencoding && |
| 194 | git shortlog HEAD~2.. > out && |
| 195 | test_cmp expect out' |
| 196 | |
Junio C Hamano | eb07774 | 2014-05-30 12:57:25 -0700 | [diff] [blame] | 197 | test_expect_success 'shortlog with revision pseudo options' ' |
| 198 | git shortlog --all && |
| 199 | git shortlog --branches && |
| 200 | git shortlog --exclude=refs/heads/m* --all |
| 201 | ' |
| 202 | |
Johannes Schindelin | 7f7d712 | 2016-06-22 17:02:07 +0200 | [diff] [blame] | 203 | test_expect_success 'shortlog with --output=<file>' ' |
Johannes Schindelin | 8f37854 | 2020-11-18 23:44:27 +0000 | [diff] [blame] | 204 | git shortlog --output=shortlog -1 main >output && |
SZEDER Gábor | f0dc593 | 2018-08-19 23:57:23 +0200 | [diff] [blame] | 205 | test_must_be_empty output && |
Johannes Schindelin | bac233f | 2016-07-11 15:11:37 +0200 | [diff] [blame] | 206 | test_line_count = 3 shortlog |
Johannes Schindelin | 7f7d712 | 2016-06-22 17:02:07 +0200 | [diff] [blame] | 207 | ' |
| 208 | |
Jeff King | 03f4082 | 2016-12-16 08:51:41 -0500 | [diff] [blame] | 209 | test_expect_success 'shortlog --committer (internal)' ' |
Junio C Hamano | bc44f93 | 2016-12-20 10:35:54 -0800 | [diff] [blame] | 210 | git checkout --orphan side && |
| 211 | git commit --allow-empty -m one && |
| 212 | git commit --allow-empty -m two && |
| 213 | GIT_COMMITTER_NAME="Sin Nombre" git commit --allow-empty -m three && |
| 214 | |
Jeff King | 03f4082 | 2016-12-16 08:51:41 -0500 | [diff] [blame] | 215 | cat >expect <<-\EOF && |
Junio C Hamano | bc44f93 | 2016-12-20 10:35:54 -0800 | [diff] [blame] | 216 | 2 C O Mitter |
| 217 | 1 Sin Nombre |
Jeff King | 03f4082 | 2016-12-16 08:51:41 -0500 | [diff] [blame] | 218 | EOF |
| 219 | git shortlog -nsc HEAD >actual && |
| 220 | test_cmp expect actual |
| 221 | ' |
| 222 | |
| 223 | test_expect_success 'shortlog --committer (external)' ' |
| 224 | git log --format=full | git shortlog -nsc >actual && |
| 225 | test_cmp expect actual |
| 226 | ' |
| 227 | |
Jeff King | 92338c4 | 2020-09-27 04:39:59 -0400 | [diff] [blame] | 228 | test_expect_success '--group=committer is the same as --committer' ' |
| 229 | git shortlog -ns --group=committer HEAD >actual && |
| 230 | test_cmp expect actual |
| 231 | ' |
| 232 | |
Jeff King | 47beb37 | 2020-09-27 04:40:04 -0400 | [diff] [blame] | 233 | test_expect_success 'shortlog --group=trailer:signed-off-by' ' |
| 234 | git commit --allow-empty -m foo -s && |
| 235 | GIT_COMMITTER_NAME="SOB One" \ |
| 236 | GIT_COMMITTER_EMAIL=sob@example.com \ |
| 237 | git commit --allow-empty -m foo -s && |
| 238 | git commit --allow-empty --amend --no-edit -s && |
| 239 | cat >expect <<-\EOF && |
| 240 | 2 C O Mitter <committer@example.com> |
| 241 | 1 SOB One <sob@example.com> |
| 242 | EOF |
Jeff King | 56d5dde | 2020-09-27 04:40:11 -0400 | [diff] [blame] | 243 | git shortlog -nse --group=trailer:signed-off-by HEAD >actual && |
| 244 | test_cmp expect actual |
| 245 | ' |
| 246 | |
Taylor Blau | 3dc95e0 | 2022-10-24 14:55:39 -0400 | [diff] [blame] | 247 | test_expect_success 'shortlog --group=format' ' |
| 248 | git shortlog -s --date="format:%Y" --group="format:%cN (%cd)" \ |
| 249 | HEAD >actual && |
| 250 | cat >expect <<-\EOF && |
| 251 | 4 C O Mitter (2005) |
| 252 | 1 Sin Nombre (2005) |
| 253 | EOF |
| 254 | test_cmp expect actual |
| 255 | ' |
| 256 | |
| 257 | test_expect_success 'shortlog --group=<format> DWIM' ' |
| 258 | git shortlog -s --date="format:%Y" --group="%cN (%cd)" HEAD >actual && |
| 259 | test_cmp expect actual |
| 260 | ' |
| 261 | |
| 262 | test_expect_success 'shortlog bogus --group' ' |
| 263 | test_must_fail git shortlog --group=bogus HEAD 2>err && |
| 264 | grep "unknown group type" err |
| 265 | ' |
| 266 | |
Jeff King | 56d5dde | 2020-09-27 04:40:11 -0400 | [diff] [blame] | 267 | test_expect_success 'trailer idents are split' ' |
| 268 | cat >expect <<-\EOF && |
| 269 | 2 C O Mitter |
| 270 | 1 SOB One |
| 271 | EOF |
Jeff King | 47beb37 | 2020-09-27 04:40:04 -0400 | [diff] [blame] | 272 | git shortlog -ns --group=trailer:signed-off-by HEAD >actual && |
| 273 | test_cmp expect actual |
| 274 | ' |
| 275 | |
Jeff King | 56d5dde | 2020-09-27 04:40:11 -0400 | [diff] [blame] | 276 | test_expect_success 'trailer idents are mailmapped' ' |
| 277 | cat >expect <<-\EOF && |
| 278 | 2 C O Mitter |
| 279 | 1 Another Name |
| 280 | EOF |
| 281 | echo "Another Name <sob@example.com>" >mail.map && |
| 282 | git -c mailmap.file=mail.map shortlog -ns \ |
| 283 | --group=trailer:signed-off-by HEAD >actual && |
| 284 | test_cmp expect actual |
| 285 | ' |
| 286 | |
Jeff King | f17b0b9 | 2020-09-27 04:40:07 -0400 | [diff] [blame] | 287 | test_expect_success 'shortlog de-duplicates trailers in a single commit' ' |
| 288 | git commit --allow-empty -F - <<-\EOF && |
| 289 | subject one |
| 290 | |
| 291 | this message has two distinct values, plus a repeat |
| 292 | |
| 293 | Repeated-trailer: Foo |
| 294 | Repeated-trailer: Bar |
| 295 | Repeated-trailer: Foo |
| 296 | EOF |
| 297 | |
| 298 | git commit --allow-empty -F - <<-\EOF && |
| 299 | subject two |
| 300 | |
| 301 | similar to the previous, but without the second distinct value |
| 302 | |
| 303 | Repeated-trailer: Foo |
| 304 | Repeated-trailer: Foo |
| 305 | EOF |
| 306 | |
| 307 | cat >expect <<-\EOF && |
| 308 | 2 Foo |
| 309 | 1 Bar |
| 310 | EOF |
| 311 | git shortlog -ns --group=trailer:repeated-trailer -2 HEAD >actual && |
| 312 | test_cmp expect actual |
| 313 | ' |
| 314 | |
Linus Arver | a082e28 | 2024-03-01 00:14:39 +0000 | [diff] [blame] | 315 | # Trailers that have unfolded (single line) and folded (multiline) values which |
| 316 | # are otherwise identical are treated as the same trailer for de-duplication. |
| 317 | test_expect_success 'shortlog de-duplicates trailers in a single commit (folded/unfolded values)' ' |
| 318 | git commit --allow-empty -F - <<-\EOF && |
| 319 | subject one |
| 320 | |
| 321 | this message has two distinct values, plus a repeat (folded) |
| 322 | |
| 323 | Repeated-trailer: Foo foo foo |
| 324 | Repeated-trailer: Bar |
| 325 | Repeated-trailer: Foo |
| 326 | foo foo |
| 327 | EOF |
| 328 | |
| 329 | git commit --allow-empty -F - <<-\EOF && |
| 330 | subject two |
| 331 | |
| 332 | similar to the previous, but without the second distinct value |
| 333 | |
| 334 | Repeated-trailer: Foo foo foo |
| 335 | Repeated-trailer: Foo |
| 336 | foo foo |
| 337 | EOF |
| 338 | |
| 339 | cat >expect <<-\EOF && |
| 340 | 2 Foo foo foo |
| 341 | 1 Bar |
| 342 | EOF |
| 343 | git shortlog -ns --group=trailer:repeated-trailer -2 HEAD >actual && |
| 344 | test_cmp expect actual |
| 345 | ' |
| 346 | |
Jeff King | 63d24fa | 2020-09-27 04:40:15 -0400 | [diff] [blame] | 347 | test_expect_success 'shortlog can match multiple groups' ' |
| 348 | git commit --allow-empty -F - <<-\EOF && |
| 349 | subject one |
| 350 | |
| 351 | this has two trailers that are distinct from the author; it will count |
| 352 | 3 times in the output |
| 353 | |
| 354 | Some-trailer: User A <a@example.com> |
| 355 | Another-trailer: User B <b@example.com> |
| 356 | EOF |
| 357 | |
| 358 | git commit --allow-empty -F - <<-\EOF && |
| 359 | subject two |
| 360 | |
| 361 | this one has two trailers, one of which is a duplicate with the author; |
| 362 | it will only be counted once for them |
| 363 | |
| 364 | Another-trailer: A U Thor <author@example.com> |
| 365 | Some-trailer: User B <b@example.com> |
| 366 | EOF |
| 367 | |
| 368 | cat >expect <<-\EOF && |
| 369 | 2 A U Thor |
| 370 | 2 User B |
| 371 | 1 User A |
| 372 | EOF |
| 373 | git shortlog -ns \ |
| 374 | --group=author \ |
| 375 | --group=trailer:some-trailer \ |
| 376 | --group=trailer:another-trailer \ |
| 377 | -2 HEAD >actual && |
| 378 | test_cmp expect actual |
| 379 | ' |
| 380 | |
Taylor Blau | 3dc95e0 | 2022-10-24 14:55:39 -0400 | [diff] [blame] | 381 | test_expect_success 'shortlog can match multiple format groups' ' |
| 382 | GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME" \ |
| 383 | git commit --allow-empty -m "identical names" && |
| 384 | test_tick && |
| 385 | cat >expect <<-\EOF && |
| 386 | 2 A U Thor |
| 387 | 1 C O Mitter |
| 388 | EOF |
| 389 | git shortlog -ns --group="%cn" --group="%an" -2 HEAD >actual && |
| 390 | test_cmp expect actual |
| 391 | ' |
| 392 | |
Jeff King | 63d24fa | 2020-09-27 04:40:15 -0400 | [diff] [blame] | 393 | test_expect_success 'set up option selection tests' ' |
| 394 | git commit --allow-empty -F - <<-\EOF |
| 395 | subject |
| 396 | |
| 397 | body |
| 398 | |
| 399 | Trailer-one: value-one |
| 400 | Trailer-two: value-two |
| 401 | EOF |
| 402 | ' |
| 403 | |
| 404 | test_expect_success '--no-group resets group list to author' ' |
| 405 | cat >expect <<-\EOF && |
| 406 | 1 A U Thor |
| 407 | EOF |
| 408 | git shortlog -ns \ |
| 409 | --group=committer \ |
| 410 | --group=trailer:trailer-one \ |
| 411 | --no-group \ |
| 412 | -1 HEAD >actual && |
| 413 | test_cmp expect actual |
| 414 | ' |
| 415 | |
| 416 | test_expect_success '--no-group resets trailer list' ' |
| 417 | cat >expect <<-\EOF && |
| 418 | 1 value-two |
| 419 | EOF |
| 420 | git shortlog -ns \ |
| 421 | --group=trailer:trailer-one \ |
| 422 | --no-group \ |
| 423 | --group=trailer:trailer-two \ |
| 424 | -1 HEAD >actual && |
| 425 | test_cmp expect actual |
| 426 | ' |
| 427 | |
| 428 | test_expect_success 'stdin with multiple groups reports error' ' |
| 429 | git log >log && |
| 430 | test_must_fail git shortlog --group=author --group=committer <log |
| 431 | ' |
| 432 | |
Johannes Schindelin | 3714e7c | 2006-12-22 22:15:59 +0100 | [diff] [blame] | 433 | test_done |