]> git.ipfire.org Git - thirdparty/git.git/blobdiff - t/t4201-shortlog.sh
shortlog: support arbitrary commit format `--group`s
[thirdparty/git.git] / t / t4201-shortlog.sh
index 7547da539dbb641fca0a8ec67449db938a809573..8e4effebdb71c6d44f9c7d272ad5c3cd44d0b1e8 100755 (executable)
@@ -244,6 +244,26 @@ test_expect_success 'shortlog --group=trailer:signed-off-by' '
        test_cmp expect actual
 '
 
+test_expect_success 'shortlog --group=format' '
+       git shortlog -s --date="format:%Y" --group="format:%cN (%cd)" \
+               HEAD >actual &&
+       cat >expect <<-\EOF &&
+            4  C O Mitter (2005)
+            1  Sin Nombre (2005)
+       EOF
+       test_cmp expect actual
+'
+
+test_expect_success 'shortlog --group=<format> DWIM' '
+       git shortlog -s --date="format:%Y" --group="%cN (%cd)" HEAD >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'shortlog bogus --group' '
+       test_must_fail git shortlog --group=bogus HEAD 2>err &&
+       grep "unknown group type" err
+'
+
 test_expect_success 'trailer idents are split' '
        cat >expect <<-\EOF &&
             2  C O Mitter
@@ -326,6 +346,18 @@ test_expect_success 'shortlog can match multiple groups' '
        test_cmp expect actual
 '
 
+test_expect_success 'shortlog can match multiple format groups' '
+       GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME" \
+               git commit --allow-empty -m "identical names" &&
+       test_tick &&
+       cat >expect <<-\EOF &&
+            2  A U Thor
+            1  C O Mitter
+       EOF
+       git shortlog -ns --group="%cn" --group="%an" -2 HEAD >actual &&
+       test_cmp expect actual
+'
+
 test_expect_success 'set up option selection tests' '
        git commit --allow-empty -F - <<-\EOF
        subject