@@ -958,6 +958,7 @@ integration_tests = [
't8012-blame-colors.sh',
't8013-blame-ignore-revs.sh',
't8014-blame-ignore-fuzzy.sh',
+ 't8015-blame-format.sh',
't9001-send-email.sh',
't9002-column.sh',
't9003-help-autocorrect.sh',
new file mode 100755
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+test_description='git blame -F option'
+
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+ echo line1 >file &&
+ git add file &&
+ git commit -m commit1 &&
+ echo line2 >>file &&
+ git add file &&
+ git commit -m commit2 &&
+ shortId1=$(git rev-parse HEAD^ | cut -c 1-8) &&
+ shortId2=$(git rev-parse HEAD | cut -c 1-8)
+'
+
+test_expect_success 'empty format' '
+ echo "line1\nline2" >expect &&
+ git blame file -F "" >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'default format' '
+ echo "$shortId1 file (A U Thor 2005-04-01 13:14:15 +0200 1) line1" >expect &&
+ echo "$shortId2 file (A U Thor 2005-04-01 13:14:15 +0200 2) line2" >>expect &&
+ git blame file -F "%h %F (%an %ai %L) " >/tmp/actual &&
+ test_cmp expect /tmp/actual
+'
+
+test_expect_success 'blame.format config' '
+ echo "$shortId1 file (A U Thor 2005-04-01 13:14:15 +0200 1) line1" >expect &&
+ echo "$shortId2 file (A U Thor 2005-04-01 13:14:15 +0200 2) line2" >>expect &&
+ git config blame.format "%h %F (%an %ai %L) " &&
+ git blame file >/tmp/actual &&
+ test_cmp expect /tmp/actual
+'
+
+test_done
Include three tests, testing each facet of the implementation: - an empty format test to confirm that the flag is available and correctly hooked into git (respects empty format and does not emit any blame metadata) - a default format test to confirm that both the existing log specifiers and the new blame-specific specifiers %F and %L are expanded as expected - a config test to confirm that the blame.format config is available under the correct name and used by the program Signed-off-by: Aleks Todorov <aleks.todorov.1337@gmail.com> --- t/meson.build | 1 + t/t8015-blame-format.sh | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100755 t/t8015-blame-format.sh