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@xxxxxxxxx> --- t/meson.build | 1 + t/t8015-blame-format.sh | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100755 t/t8015-blame-format.sh diff --git a/t/meson.build b/t/meson.build index 780939d49f..da798fbc88 100644 --- a/t/meson.build +++ b/t/meson.build @@ -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', diff --git a/t/t8015-blame-format.sh b/t/t8015-blame-format.sh new file mode 100755 index 0000000000..8d05310d5d --- /dev/null +++ b/t/t8015-blame-format.sh @@ -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 -- 2.43.0