]> git.ipfire.org Git - thirdparty/git.git/blobdiff - t/t4205-log-pretty-formats.sh
log: add %S option (like --source) to log --format
[thirdparty/git.git] / t / t4205-log-pretty-formats.sh
index 978a8a66ff05055ad1967b5cc25f36880230a5e4..7df8c3d4ec04ef86e12277e5debfeb8f8f825521 100755 (executable)
@@ -621,4 +621,54 @@ test_expect_success 'trailer parsing not fooled by --- line' '
        test_cmp expect actual
 '
 
+test_expect_success 'set up %S tests' '
+       git checkout --orphan source-a &&
+       test_commit one &&
+       test_commit two &&
+       git checkout -b source-b HEAD^ &&
+       test_commit three
+'
+
+test_expect_success 'log --format=%S paints branch names' '
+       cat >expect <<-\EOF &&
+       source-b
+       source-a
+       source-b
+       EOF
+       git log --format=%S source-a source-b >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'log --format=%S paints tag names' '
+       git tag -m tagged source-tag &&
+       cat >expect <<-\EOF &&
+       source-tag
+       source-a
+       source-tag
+       EOF
+       git log --format=%S source-tag source-a >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'log --format=%S paints symmetric ranges' '
+       cat >expect <<-\EOF &&
+       source-b
+       source-a
+       EOF
+       git log --format=%S source-a...source-b >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success '%S in git log --format works with other placeholders (part 1)' '
+       git log --format="source-b %h" source-b >expect &&
+       git log --format="%S %h" source-b >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success '%S in git log --format works with other placeholders (part 2)' '
+       git log --format="%h source-b" source-b >expect &&
+       git log --format="%h %S" source-b >actual &&
+       test_cmp expect actual
+'
+
 test_done