[GSoC PATCH 2/2] t4074: add test for diffstat width when prefix contains ANSI chars
- From
LorenzoPegorari <lorenzo.pegorari2002@gmail.com>
- Date
- Feb 24, 2026, 01:20 UTC
- Message-ID
- <ce251505932712839dcaabffcd1762760439edff.1771895921.git.lorenzo.pegorari2002@gmail.com>
- In-Reply-To
- <cover.1771894207.git.lorenzo.pegorari2002@gmail.com>
Add test checking the calculation of the diffstat display width when the line_prefix contains ANSI characters.
Signed-off-by: LorenzoPegorari <lorenzo.pegorari2002@gmail.com> --- t/meson.build | 1 + t/t4074-diff-stat-width-with-line-prefix.sh | 42 +++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100755 t/t4074-diff-stat-width-with-line-prefix.sh
diff --git a/t/meson.build b/t/meson.build index f80e366cff..2867ba8a77 100644 --- a/t/meson.build +++ b/t/meson.build @@ -502,6 +502,7 @@ integration_tests = [ 't4071-diff-minimal.sh', 't4072-diff-max-depth.sh', 't4073-diff-stat-name-width.sh', + 't4074-diff-stat-width-with-line-prefix.sh', 't4100-apply-stat.sh', 't4101-apply-nonl.sh', 't4102-apply-rename.sh', diff --git a/t/t4074-diff-stat-width-with-line-prefix.sh b/t/t4074-diff-stat-width-with-line-prefix.sh new file mode 100755 index 0000000000..69ab85bf25 --- /dev/null +++ b/t/t4074-diff-stat-width-with-line-prefix.sh @@ -0,0 +1,42 @@ +#!/bin/sh + +test_description='git-diff check diffstat width when line_prefix is not empty' + +. ./test-lib.sh + + +# The terminal, during a test, should default to a width of 80 columns +FILE_MAX="filename-with-exact-length-to-take-the-max-amount-of-space-in-diffstat" +FILE_LONGER="...name-with-exact-length-to-take-the-max-amount-of-space-in-diffstat+" + +setup () { + rm -rf * ".git" && + git init && + git config color.diff always +} + +test_expect_success 'check width with max name-width' ' + setup && + touch "${FILE_MAX}" && + git add . && + git commit -m "init" && + echo "text" >"${FILE_MAX}" && + git add . && + git commit -m "text" && + git log --graph --stat >out && + grep "${FILE} | 1" out +' + +test_expect_success 'check width with longer name-width' ' + setup && + touch "${FILE_MAX}+" && + git add . && + git commit -m "init" && + echo "text" >"${FILE_MAX}+" && + git add . && + git commit -m "text" && + git log --graph --stat >out && + grep "${FILE_LONGER} | 1" out +' + +test_done
-- 2.43.0