{"thread":{"id":"65064","subject":"[GSoC PATCH 0/2] diff: handle ANSI chars in prefix when calculating diffstat width","startedAt":"2026-02-24T01:09:50Z","lastAt":"2026-02-27T21:48:39Z","messageCount":14,"participants":["LorenzoPegorari","Junio C Hamano","Lorenzo Pegorari"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"536895","messageId":"cover.1771894207.git.lorenzo.pegorari2002@gmail.com","threadId":"65064","inReplyTo":null,"subject":"[GSoC PATCH 0/2] diff: handle ANSI chars in prefix when calculating diffstat width","fromName":"LorenzoPegorari","fromEmail":"lorenzo.pegorari2002@gmail.com","sentAt":"2026-02-24T01:09:46Z","receivedAt":"2026-02-24T01:09:50Z","isPatch":true,"sender":{"key":"lorenzo.pegorari2002@gmail.com","avatar":"https://avatars.githubusercontent.com/u/132087553?v=4"},"body":"This patch aims to fix a bug where the calculation of the diffstat width\nincorrectly uses the strlen() of line_prefix instead of its actual\ndisplay width.\n\nThis patch addresses the NEEDSWORK item added by ce8529b2 (diff: leave\nNEEDWORK notes in show_stats() function, 2022-10-21).\n\nAlso, this bug was reported and suggested to me by Junio C Hamano here:\nhttps://lore.kernel.org/git/xmqqikd3ermt.fsf@gitster.g/\n\nJunio, do you wish to be included in this patch by a Reported-by and/or\nSuggested-by tag?\n\nLorenzoPegorari (2):\n  diff: handle ANSI chars in prefix when calculating diffstat width\n  t4074: add test for diffstat width when prefix contains ANSI chars\n\n diff.c                                      | 12 ++----\n t/t4074-diff-stat-width-with-line-prefix.sh | 42 +++++++++++++++++++++\n 2 files changed, 46 insertions(+), 8 deletions(-)\n create mode 100755 t/t4074-diff-stat-width-with-line-prefix.sh\n\n-- \n2.43.0\n\n"},{"id":"536896","messageId":"a798eda511c23ce15df1280a73861ac951459315.1771894207.git.lorenzo.pegorari2002@gmail.com","threadId":"65064","inReplyTo":"cover.1771894207.git.lorenzo.pegorari2002@gmail.com","subject":"[GSoC PATCH 1/2] diff: handle ANSI chars in prefix when calculating diffstat width","fromName":"LorenzoPegorari","fromEmail":"lorenzo.pegorari2002@gmail.com","sentAt":"2026-02-24T01:11:16Z","receivedAt":"2026-02-24T01:11:20Z","isPatch":true,"sender":{"key":"lorenzo.pegorari2002@gmail.com","avatar":"https://avatars.githubusercontent.com/u/132087553?v=4"},"body":"The diffstat width is calculated by taking the terminal width and\nincorrectly subtracting the strlen() of line_prefix, instead of the\nactual display width of line_prefix (which may contain ANSI chars).\n\nUtilize the display width instead, obtained via utf8_strnwidth() with\nthe flag to skip ANSI chars.\n\nSigned-off-by: LorenzoPegorari <lorenzo.pegorari2002@gmail.com>\n---\n diff.c | 12 ++++--------\n 1 file changed, 4 insertions(+), 8 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 35b903a9a0..de1db28714 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -2749,7 +2749,9 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)\n \tcount = i; /* where we can stop scanning in data->files[] */\n \n \t/*\n-\t * We have width = stat_width or term_columns() columns total.\n+\t * We have width = stat_width or term_columns() columns total\n+\t * minus the length of line_prefix skipping ANSI chars to get the\n+\t * display width (e.g., to skip ANSI-colored strings in \"log --graph\").\n \t * We want a maximum of min(max_len, stat_name_width) for the name part.\n \t * We want a maximum of min(max_change, stat_graph_width) for the +- part.\n \t * We also need 1 for \" \" and 4 + decimal_width(max_change)\n@@ -2776,14 +2778,8 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)\n \t * separators and this message, this message will \"overflow\"\n \t * making the line longer than the maximum width.\n \t */\n-\n-\t/*\n-\t * NEEDSWORK: line_prefix is often used for \"log --graph\" output\n-\t * and contains ANSI-colored string.  utf8_strnwidth() should be\n-\t * used to correctly count the display width instead of strlen().\n-\t */\n \tif (options->stat_width == -1)\n-\t\twidth = term_columns() - strlen(line_prefix);\n+\t\twidth = term_columns() - utf8_strnwidth(line_prefix, strlen(line_prefix), 1);\n \telse\n \t\twidth = options->stat_width ? options->stat_width : 80;\n \tnumber_width = decimal_width(max_change) > number_width ?\n-- \n2.43.0\n\n"},{"id":"536897","messageId":"ce251505932712839dcaabffcd1762760439edff.1771895921.git.lorenzo.pegorari2002@gmail.com","threadId":"65064","inReplyTo":"cover.1771894207.git.lorenzo.pegorari2002@gmail.com","subject":"[GSoC PATCH 2/2] t4074: add test for diffstat width when prefix contains ANSI chars","fromName":"LorenzoPegorari","fromEmail":"lorenzo.pegorari2002@gmail.com","sentAt":"2026-02-24T01:20:30Z","receivedAt":"2026-02-24T01:20:34Z","isPatch":true,"sender":{"key":"lorenzo.pegorari2002@gmail.com","avatar":"https://avatars.githubusercontent.com/u/132087553?v=4"},"body":"Add test checking the calculation of the diffstat display width when\nthe line_prefix contains ANSI characters.\n\nSigned-off-by: LorenzoPegorari <lorenzo.pegorari2002@gmail.com>\n---\n t/meson.build                               |  1 +\n t/t4074-diff-stat-width-with-line-prefix.sh | 42 +++++++++++++++++++++\n 2 files changed, 43 insertions(+)\n create mode 100755 t/t4074-diff-stat-width-with-line-prefix.sh\n\ndiff --git a/t/meson.build b/t/meson.build\nindex f80e366cff..2867ba8a77 100644\n--- a/t/meson.build\n+++ b/t/meson.build\n@@ -502,6 +502,7 @@ integration_tests = [\n   't4071-diff-minimal.sh',\n   't4072-diff-max-depth.sh',\n   't4073-diff-stat-name-width.sh',\n+  't4074-diff-stat-width-with-line-prefix.sh',\n   't4100-apply-stat.sh',\n   't4101-apply-nonl.sh',\n   't4102-apply-rename.sh',\ndiff --git a/t/t4074-diff-stat-width-with-line-prefix.sh b/t/t4074-diff-stat-width-with-line-prefix.sh\nnew file mode 100755\nindex 0000000000..69ab85bf25\n--- /dev/null\n+++ b/t/t4074-diff-stat-width-with-line-prefix.sh\n@@ -0,0 +1,42 @@\n+#!/bin/sh\n+\n+test_description='git-diff check diffstat width when line_prefix is not empty'\n+\n+. ./test-lib.sh\n+\n+\n+# The terminal, during a test, should default to a width of 80 columns\n+FILE_MAX=\"filename-with-exact-length-to-take-the-max-amount-of-space-in-diffstat\"\n+FILE_LONGER=\"...name-with-exact-length-to-take-the-max-amount-of-space-in-diffstat+\"\n+\n+setup () {\n+\trm -rf * \".git\" &&\n+\tgit init &&\n+\tgit config color.diff always\n+}\n+\n+test_expect_success 'check width with max name-width' '\n+\tsetup &&\n+\ttouch \"${FILE_MAX}\" &&\n+\tgit add . &&\n+\tgit commit -m \"init\" &&\n+\techo \"text\" >\"${FILE_MAX}\" &&\n+\tgit add . &&\n+\tgit commit -m \"text\" &&\n+\tgit log --graph --stat >out &&\n+\tgrep \"${FILE} | 1\" out\n+'\n+\n+test_expect_success 'check width with longer name-width' '\n+\tsetup &&\n+\ttouch \"${FILE_MAX}+\" &&\n+\tgit add . &&\n+\tgit commit -m \"init\" &&\n+\techo \"text\" >\"${FILE_MAX}+\" &&\n+\tgit add . &&\n+\tgit commit -m \"text\" &&\n+\tgit log --graph --stat >out &&\n+\tgrep \"${FILE_LONGER} | 1\" out\n+'\n+\n+test_done\n-- \n2.43.0\n\n"},{"id":"536911","messageId":"xmqqwm02k9e0.fsf@gitster.g","threadId":"65064","inReplyTo":"cover.1771894207.git.lorenzo.pegorari2002@gmail.com","subject":"Re: [GSoC PATCH 0/2] diff: handle ANSI chars in prefix when calculating diffstat width","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-02-24T05:17:43Z","receivedAt":"2026-02-24T05:17:45Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"LorenzoPegorari <lorenzo.pegorari2002@gmail.com> writes:\n\n> This patch aims to fix a bug where the calculation of the diffstat width\n> incorrectly uses the strlen() of line_prefix instead of its actual\n> display width.\n>\n> This patch addresses the NEEDSWORK item added by ce8529b2 (diff: leave\n> NEEDWORK notes in show_stats() function, 2022-10-21).\n>\n> Also, this bug was reported and suggested to me by Junio C Hamano here:\n> https://lore.kernel.org/git/xmqqikd3ermt.fsf@gitster.g/\n>\n> Junio, do you wish to be included in this patch by a Reported-by and/or\n> Suggested-by tag?\n\nNeither.  I didn't report or suggest anything recently.  I merely\npointed at one out of the two NEEDSWORK comments that was written\nlong time ago when you addressed the other one.\n\n>   diff: handle ANSI chars in prefix when calculating diffstat width\n>   t4074: add test for diffstat width when prefix contains ANSI chars\n\n\"ANSI chars\" is a phrase that was hard to understand, as the theme\nof this was paged out of my working memory a long time ago ;-).  I\nthink the issue is that strings with ANSI color escape sequences are\nused in \"log --graph\" and other output, and in order to measure how\nmany display columns these strings occupy, we must not be using\nstrlen() but utr8_strnwidth() that knows how to count UTF-8 chars\n(whose display widths do not match the number of bytes) as well as\nthat these color escape sequences do not occupy any display width?\n\nAnyway, thanks for working on these patches.\n"},{"id":"536914","messageId":"xmqqikbmk86b.fsf@gitster.g","threadId":"65064","inReplyTo":"ce251505932712839dcaabffcd1762760439edff.1771895921.git.lorenzo.pegorari2002@gmail.com","subject":"Re: [GSoC PATCH 2/2] t4074: add test for diffstat width when prefix contains ANSI chars","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-02-24T05:43:56Z","receivedAt":"2026-02-24T05:43:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"LorenzoPegorari <lorenzo.pegorari2002@gmail.com> writes:\n\n> Add test checking the calculation of the diffstat display width when\n> the line_prefix contains ANSI characters.\n\nHmph, who stuffs the \"line_prefix\" and with what?\n\n> Signed-off-by: LorenzoPegorari <lorenzo.pegorari2002@gmail.com>\n> ---\n>  t/meson.build                               |  1 +\n>  t/t4074-diff-stat-width-with-line-prefix.sh | 42 +++++++++++++++++++++\n>  2 files changed, 43 insertions(+)\n>  create mode 100755 t/t4074-diff-stat-width-with-line-prefix.sh\n\nDo we need a brand new test script only to host just two tests?  Is\nit too cumbersome to modify existing test scripts that already test\n\"git log --graph\"?\n\n> +setup () {\n> +\trm -rf * \".git\" &&\n> +\tgit init &&\n> +\tgit config color.diff always\n> +}\n\nWhy?\n\n> +test_expect_success 'check width with max name-width' '\n> +\tsetup &&\n\nWhy?  Shouldn't something like\n\n\ttest_config color.diff always &&\n\nbe sufficient?\n\n> +\ttouch \"${FILE_MAX}\" &&\n\nUse of \"touch\" when you do not care about the timestamp of the\nresulting file is misleading.  If you only care about its existence,\ndo something like\n\n\t>\"${FILE_MAX}\" &&\n\ninstead.\n\n> +\tgit add . &&\n> +\tgit commit -m \"init\" &&\n> +\techo \"text\" >\"${FILE_MAX}\" &&\n> +\tgit add . &&\n> +\tgit commit -m \"text\" &&\n\nOK, so we have two commits, one adds an empty file, followed by\nanother that adds one line of \"text\" to the file.\n\n> +\tgit log --graph --stat >out &&\n> +\tgrep \"${FILE} | 1\" out\n> +'\n\nUse \"test_grep\" instead of \"grep\" to make it easier to debug when\nthings break, perhaps?\n\nIt is unclear what we are exactly looking for.  What's the failure\nmode and how the miscounting of the width of the line-prefix\ncontribute to that failure?\n\nWe have two commits, \"log\" without \"--reverse\" would give the\ncreation of an empty file i.e., \"file | 0\" first and then one line\naddition to the file i.e., \"file | 1 +\" next.  We only care about\n\"${FILE} | 1\" existing in the output and we do not bother checking\nwhat comes at the beginning of the line before \"${FILE}\" or what\ncomes on the line fter \"| 1\", because we can detect the breakage we\nexpect to see only by looking at the middle of the line?  How would\nthat work?  The test deserves a bit more comment to help readers who\nwonder about these things.\n\n\tSide note.  I think I know the answer to these questions,\n\tbut this project is not about me ;-) but other future\n\tcontributors also would need help when they encounter this\n\ttest and want to learn what it is testing.\n\n> +test_expect_success 'check width with longer name-width' '\n> +\tsetup &&\n> +\ttouch \"${FILE_MAX}+\" &&\n> +\tgit add . &&\n> +\tgit commit -m \"init\" &&\n> +\techo \"text\" >\"${FILE_MAX}+\" &&\n> +\tgit add . &&\n> +\tgit commit -m \"text\" &&\n> +\tgit log --graph --stat >out &&\n> +\tgrep \"${FILE_LONGER} | 1\" out\n> +'\n> +\n> +test_done\n\nInstead of doing the repository construction twice, you can see the\nsame effect by running \"git log --graph --stat\" on the same history\nwith different values exported on COLUMNS environment variable,\nwhich I think would be easier to see and simpler to debug.\n\nSomething along the lines of ...\n\n    COLUMNS=80 git log --graph --stat >out &&\n    test_decode_color out >out.decoded &&\n    test_grep \"^<RED>|<RESET> ${FILE_MAX} | 1 <GREEN>+<RESET>$\" out.decoded &&\n\n    COLUMNS=79 git log --graph --stat >out &&\n    test_decode_color out >out.decoded &&\n    test_grep \"^<RED>|<RESET> ${FILE_TRUNCATED} | 1 <GREEN>+<RESET>$\" out.decoded\n\n... perhaps?\n\n> +# The terminal, during a test, should default to a width of 80 columns\n> +FILE_MAX=\"filename-with-exact-length-to-take-the-max-amount-of-space-in-diffstat\"\n> +FILE_LONGER=\"...name-with-exact-length-to-take-the-max-amount-of-space-in-diffstat+\"\n"},{"id":"537063","messageId":"aZ5b5spGgHdMPmH-@lorenzo-VM","threadId":"65064","inReplyTo":"xmqqikbmk86b.fsf@gitster.g","subject":"Re: [GSoC PATCH 2/2] t4074: add test for diffstat width when prefix contains ANSI chars","fromName":"Lorenzo Pegorari","fromEmail":"lorenzo.pegorari2002@gmail.com","sentAt":"2026-02-25T02:18:14Z","receivedAt":"2026-02-25T02:18:18Z","isPatch":true,"sender":{"key":"lorenzo.pegorari2002@gmail.com","avatar":"https://avatars.githubusercontent.com/u/132087553?v=4"},"body":"On Mon, Feb 23, 2026 at 09:43:56PM -0800, Junio C Hamano wrote:\n> LorenzoPegorari <lorenzo.pegorari2002@gmail.com> writes:\n> \n> > Add test checking the calculation of the diffstat display width when\n> > the line_prefix contains ANSI characters.\n>\n> Hmph, who stuffs the \"line_prefix\" and with what?\n\nYeah, I should make the commit description clearer. Will improve that.\n\n> > Signed-off-by: LorenzoPegorari <lorenzo.pegorari2002@gmail.com>\n> > ---\n> >  t/meson.build                               |  1 +\n> >  t/t4074-diff-stat-width-with-line-prefix.sh | 42 +++++++++++++++++++++\n> >  2 files changed, 43 insertions(+)\n> >  create mode 100755 t/t4074-diff-stat-width-with-line-prefix.sh\n>\n> Do we need a brand new test script only to host just two tests?  Is\n> it too cumbersome to modify existing test scripts that already test\n> \"git log --graph\"?\n\nMmh I guess the test could be added to \"t4052-stat-output.sh\", which\n\"tests --stat output of various commands\". Do you agree that this the\ncorrect place? (btw, t4052 seems to me like a quite messy test...)\n\n> > +setup () {\n> > +   rm -rf * \".git\" &&\n> > +   git init &&\n> > +   git config color.diff always\n> > +}\n>\n> Why?\n>\n> > +test_expect_success 'check width with max name-width' '\n> > +   setup &&\n>\n> Why?  Shouldn't something like\n>\n>       test_config color.diff always &&\n>\n> be sufficient?\n\nThis is sufficient, and the setup() func makes no sense now that I know\nthis. Thanks for pointing that out!\n\n> > +   touch \"${FILE_MAX}\" &&\n>\n> Use of \"touch\" when you do not care about the timestamp of the\n> resulting file is misleading.  If you only care about its existence,\n> do something like\n>\n>       >\"${FILE_MAX}\" &&\n>\n> instead.\n\nAck.\n\n> > +   git add . &&\n> > +   git commit -m \"init\" &&\n> > +   echo \"text\" >\"${FILE_MAX}\" &&\n> > +   git add . &&\n> > +   git commit -m \"text\" &&\n>\n> OK, so we have two commits, one adds an empty file, followed by\n> another that adds one line of \"text\" to the file.\n\nYes, these are just placeholder commits. We need at least 2 commits to\ncreate a graph with \"log --graph\". I will make them \"--allow-empty\" and\n\"--allow-empty-message\" emphasize that they are placeholders.\n\n> > +   git log --graph --stat >out &&\n> > +   grep \"${FILE} | 1\" out\n> > +'\n>\n> Use \"test_grep\" instead of \"grep\" to make it easier to debug when\n> things break, perhaps?\n\nAck.\n\n\n> It is unclear what we are exactly looking for.  What's the failure\n> mode and how the miscounting of the width of the line-prefix\n> contribute to that failure?\n>\n> We have two commits, \"log\" without \"--reverse\" would give the\n> creation of an empty file i.e., \"file | 0\" first and then one line\n> addition to the file i.e., \"file | 1 +\" next.  We only care about\n> \"${FILE} | 1\" existing in the output and we do not bother checking\n> what comes at the beginning of the line before \"${FILE}\" or what\n> comes on the line fter \"| 1\", because we can detect the breakage we\n> expect to see only by looking at the middle of the line?  How would\n> that work?  The test deserves a bit more comment to help readers who\n> wonder about these things.\n\nI will add comments to explain the test better.\nThe goal is to have a file with name that is just the exact length so\nthat the line in the git-log output which includes the diffstat will\ntake all the available space in the terminal (if the diffstat width is\ncalculated correctly).\nThen we test the diffstat width calculation with the terminal being the\ncorrect size for the file name, and then 1 column short.\nIf the file name is fully displayed first, and is then shortened by only\n1 character, it means that the diffstat width was correctly calculated.\n\n>       Side note.  I think I know the answer to these questions,\n>       but this project is not about me ;-) but other future\n>       contributors also would need help when they encounter this\n>       test and want to learn what it is testing.\n\nThank you so much for helping me out without just giving me the\nsolution. It must have taken longer :-)\n\n> > +test_expect_success 'check width with longer name-width' '\n> > +   setup &&\n> > +   touch \"${FILE_MAX}+\" &&\n> > +   git add . &&\n> > +   git commit -m \"init\" &&\n> > +   echo \"text\" >\"${FILE_MAX}+\" &&\n> > +   git add . &&\n> > +   git commit -m \"text\" &&\n> > +   git log --graph --stat >out &&\n> > +   grep \"${FILE_LONGER} | 1\" out\n> > +'\n> > +\n> > +test_done\n>\n> Instead of doing the repository construction twice, you can see the\n> same effect by running \"git log --graph --stat\" on the same history\n> with different values exported on COLUMNS environment variable,\n> which I think would be easier to see and simpler to debug.\n>\n> Something along the lines of ...\n>\n>     COLUMNS=80 git log --graph --stat >out &&\n>     test_decode_color out >out.decoded &&\n>     test_grep \"^<RED>|<RESET> ${FILE_MAX} | 1 <GREEN>+<RESET>$\" out.decoded &&\n>\n>     COLUMNS=79 git log --graph --stat >out &&\n>     test_decode_color out >out.decoded &&\n>     test_grep \"^<RED>|<RESET> ${FILE_TRUNCATED} | 1 <GREEN>+<RESET>$\" out.decoded\n>\n> ... perhaps?\n\nDidn't know about this. Will use it for sure.\n\nAgain, thanks a lot for the through review Junio. Just let me know if\nt4052 (described above) is the correct place for the test!\n\n(Sorry for the double email Junio... why does mutt not automatically add\nthe mailing list to CC while replying... :'[ )\n\n"},{"id":"537297","messageId":"cover.1772136203.git.lorenzo.pegorari2002@gmail.com","threadId":"65064","inReplyTo":"cover.1771894207.git.lorenzo.pegorari2002@gmail.com","subject":"[GSoC PATCH v2 0/2] diff: handle UTF-8 chars in prefix when calculating diffstat width","fromName":"LorenzoPegorari","fromEmail":"lorenzo.pegorari2002@gmail.com","sentAt":"2026-02-27T16:01:07Z","receivedAt":"2026-02-27T16:01:17Z","isPatch":true,"sender":{"key":"lorenzo.pegorari2002@gmail.com","avatar":"https://avatars.githubusercontent.com/u/132087553?v=4"},"body":"This patch aims to fix a bug where the calculation of the diffstat width\nincorrectly uses the strlen() of line_prefix instead of its actual\ndisplay width.\n\nThis patch addresses the NEEDSWORK item added by ce8529b2 (diff: leave\nNEEDWORK notes in show_stats() function, 2022-10-21).\n\nV2 DIFF:\n* Changed references from \"ANSI char\" to \"UTF-8 char\"\n* Compacted the 2 test scripts in a single script, that I placed in the\n  already existing test file t4052, which \"tests --stat output for\n  various commands\"\n* Added many of the changes suggested to me by Junio C Hamano [1], in\n  order to make the test easier to read and to debug\n* Added a descriptive comment for the test script, and a more complete\n  commit message to describe the goal of the test\n\n[1]: https://lore.kernel.org/git/xmqqikbmk86b.fsf@gitster.g/\n\nLorenzoPegorari (2):\n  diff: handle UTF-8 chars in prefix when calculating diffstat width\n  t4052: add test for diffstat width when prefix contains UTF-8 chars\n\n diff.c                 | 12 ++++--------\n t/b                    |  0\n t/t4052-stat-output.sh | 30 ++++++++++++++++++++++++++++++\n 3 files changed, 34 insertions(+), 8 deletions(-)\n create mode 100644 t/b\n\nRange-diff against v1:\n1:  a798eda511 ! 1:  9e8161a700 diff: handle ANSI chars in prefix when calculating diffstat width\n    @@ Metadata\n     Author: LorenzoPegorari <lorenzo.pegorari2002@gmail.com>\n     \n      ## Commit message ##\n    -    diff: handle ANSI chars in prefix when calculating diffstat width\n    +    diff: handle UTF-8 chars in prefix when calculating diffstat width\n     \n         The diffstat width is calculated by taking the terminal width and\n    -    incorrectly subtracting the strlen() of line_prefix, instead of the\n    -    actual display width of line_prefix (which may contain ANSI chars).\n    +    incorrectly subtracting the `strlen()` of `line_prefix`, instead of the\n    +    actual display width of `line_prefix`, which may contain UTF-8\n    +    characters (e.g., ANSI-colored strings in `log --graph --stat`).\n     \n    -    Utilize the display width instead, obtained via utf8_strnwidth() with\n    -    the flag to skip ANSI chars.\n    +    Utilize the display width instead, obtained via `utf8_strnwidth()` with\n    +    the flag `skip_ansi`.\n     \n         Signed-off-by: LorenzoPegorari <lorenzo.pegorari2002@gmail.com>\n     \n    @@ diff.c: static void show_stats(struct diffstat_t *data, struct diff_options *opt\n      \n      \t/*\n     -\t * We have width = stat_width or term_columns() columns total.\n    -+\t * We have width = stat_width or term_columns() columns total\n    -+\t * minus the length of line_prefix skipping ANSI chars to get the\n    -+\t * display width (e.g., to skip ANSI-colored strings in \"log --graph\").\n    ++\t * We have width = stat_width or term_columns() columns total minus the\n    ++\t * length of line_prefix skipping UTF-8 chars to get the display width\n    ++\t * (e.g., to skip ANSI-colored strings in \"log --graph --stat\").\n      \t * We want a maximum of min(max_len, stat_name_width) for the name part.\n      \t * We want a maximum of min(max_change, stat_graph_width) for the +- part.\n      \t * We also need 1 for \" \" and 4 + decimal_width(max_change)\n2:  ce25150593 < -:  ---------- t4074: add test for diffstat width when prefix contains ANSI chars\n-:  ---------- > 2:  984fa10d72 t4052: add test for diffstat width when prefix contains UTF-8 chars\n-- \n2.43.0\n\n"},{"id":"537298","messageId":"9e8161a7009e270c76a7cc4411b1977837ee7d19.1772136203.git.lorenzo.pegorari2002@gmail.com","threadId":"65064","inReplyTo":"cover.1772136203.git.lorenzo.pegorari2002@gmail.com","subject":"[GSoC PATCH v2 1/2] diff: handle UTF-8 chars in prefix when calculating diffstat width","fromName":"LorenzoPegorari","fromEmail":"lorenzo.pegorari2002@gmail.com","sentAt":"2026-02-27T16:04:04Z","receivedAt":"2026-02-27T16:04:09Z","isPatch":true,"sender":{"key":"lorenzo.pegorari2002@gmail.com","avatar":"https://avatars.githubusercontent.com/u/132087553?v=4"},"body":"The diffstat width is calculated by taking the terminal width and\nincorrectly subtracting the `strlen()` of `line_prefix`, instead of the\nactual display width of `line_prefix`, which may contain UTF-8\ncharacters (e.g., ANSI-colored strings in `log --graph --stat`).\n\nUtilize the display width instead, obtained via `utf8_strnwidth()` with\nthe flag `skip_ansi`.\n\nSigned-off-by: LorenzoPegorari <lorenzo.pegorari2002@gmail.com>\n---\n diff.c | 12 ++++--------\n 1 file changed, 4 insertions(+), 8 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 35b903a9a0..395cb464f4 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -2749,7 +2749,9 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)\n \tcount = i; /* where we can stop scanning in data->files[] */\n \n \t/*\n-\t * We have width = stat_width or term_columns() columns total.\n+\t * We have width = stat_width or term_columns() columns total minus the\n+\t * length of line_prefix skipping UTF-8 chars to get the display width\n+\t * (e.g., to skip ANSI-colored strings in \"log --graph --stat\").\n \t * We want a maximum of min(max_len, stat_name_width) for the name part.\n \t * We want a maximum of min(max_change, stat_graph_width) for the +- part.\n \t * We also need 1 for \" \" and 4 + decimal_width(max_change)\n@@ -2776,14 +2778,8 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)\n \t * separators and this message, this message will \"overflow\"\n \t * making the line longer than the maximum width.\n \t */\n-\n-\t/*\n-\t * NEEDSWORK: line_prefix is often used for \"log --graph\" output\n-\t * and contains ANSI-colored string.  utf8_strnwidth() should be\n-\t * used to correctly count the display width instead of strlen().\n-\t */\n \tif (options->stat_width == -1)\n-\t\twidth = term_columns() - strlen(line_prefix);\n+\t\twidth = term_columns() - utf8_strnwidth(line_prefix, strlen(line_prefix), 1);\n \telse\n \t\twidth = options->stat_width ? options->stat_width : 80;\n \tnumber_width = decimal_width(max_change) > number_width ?\n-- \n2.43.0\n\n"},{"id":"537299","messageId":"984fa10d728aad049d0430472e85f1ed0e5ea4de.1772136203.git.lorenzo.pegorari2002@gmail.com","threadId":"65064","inReplyTo":"cover.1772136203.git.lorenzo.pegorari2002@gmail.com","subject":"[GSoC PATCH v2 2/2] t4052: add test for diffstat width when prefix contains UTF-8 chars","fromName":"LorenzoPegorari","fromEmail":"lorenzo.pegorari2002@gmail.com","sentAt":"2026-02-27T16:08:12Z","receivedAt":"2026-02-27T16:08:16Z","isPatch":true,"sender":{"key":"lorenzo.pegorari2002@gmail.com","avatar":"https://avatars.githubusercontent.com/u/132087553?v=4"},"body":"Add test checking the calculation of the diffstat display width when the\n`line_prefix`, which is text that goes before the diffstat, contains\nUTF-8 characters.\n\nThis situation happens, for example, when `git log --stat --graph` is\nexecuted:\n* `--stat` will create a diffstat for each commit\n* `--graph` will stuff `line_prefix` with the graph portion of the log,\n  which contains UTF-8 characters (ANSI escape codes to color the text)\n\nSigned-off-by: LorenzoPegorari <lorenzo.pegorari2002@gmail.com>\n---\n t/b                    |  0\n t/t4052-stat-output.sh | 30 ++++++++++++++++++++++++++++++\n 2 files changed, 30 insertions(+)\n create mode 100644 t/b\n\ndiff --git a/t/b b/t/b\nnew file mode 100644\nindex 0000000000..e69de29bb2\ndiff --git a/t/t4052-stat-output.sh b/t/t4052-stat-output.sh\nindex 740bb97091..cc4665047d 100755\n--- a/t/t4052-stat-output.sh\n+++ b/t/t4052-stat-output.sh\n@@ -413,4 +413,34 @@ test_expect_success 'merge --stat respects COLUMNS with long name' '\n \ttest_cmp expect actual\n '\n \n+# git-log will print only 1 commit containing a single branch graph and a diffstat.\n+# The diffstat will be only one file, with a placeholder FILENAME, that, with\n+# enough terminal display width, will contain the following line:\n+#     \"<RED>|<RESET>  ${FILENAME} | 0\"\n+# where \"<RED>\" and \"<RESET>\" are ANSI escape codes to color the text.\n+# To calculate the minimium terminal display width MIN_TERM_WIDTH so that the\n+# FILENAME in the diffstat will not be shortened, we take the FILENAME length\n+# and add 9 to it.\n+# To check if the diffstat width, when the line_prefix (the \"<RED>|<RESET>\" of\n+# the graph) contains UTF-8 characters (the ANSI escape codes), is calculated\n+# correctly, we:\n+#     1. check if it contains the line defined before when using MIN_TERM_WIDTH\n+#     2. check if it contains the line defined before, but with the FILENAME\n+#        shortened by only one character, when using MIN_TERM_WIDTH - 1\n+\n+test_expect_success 'diffstat where line_prefix contains UTF-8 chars is correct width' '\n+\tFILENAME=\"placeholder-text-placeholder-text\" &&\n+\tFILENAME_TRIMMED=\"...eholder-text-placeholder-text\" &&\n+\tMIN_TERM_WIDTH=$((${#FILENAME} + 9)) &&\n+\ttest_config color.diff always &&\n+\tgit commit --allow-empty --allow-empty-message &&\n+\t>${FILENAME} &&\n+\tgit add ${FILENAME} &&\n+\tgit commit --allow-empty-message &&\n+\tCOLUMNS=$((MIN_TERM_WIDTH)) git log --graph --stat -n1 | test_decode_color >out &&\n+\ttest_grep \"<RED>|<RESET>  ${FILENAME} | 0\" out &&\n+\tCOLUMNS=$((MIN_TERM_WIDTH - 1)) git log --graph --stat -n1 | test_decode_color >out &&\n+\ttest_grep \"<RED>|<RESET>  ${FILENAME_TRIMMED} | 0\" out\n+'\n+\n test_done\n-- \n2.43.0\n\n"},{"id":"537311","messageId":"xmqq5x7irrjq.fsf@gitster.g","threadId":"65064","inReplyTo":"cover.1772136203.git.lorenzo.pegorari2002@gmail.com","subject":"Re: [GSoC PATCH v2 0/2] diff: handle UTF-8 chars in prefix when calculating diffstat width","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-02-27T18:04:57Z","receivedAt":"2026-02-27T18:04:59Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"LorenzoPegorari <lorenzo.pegorari2002@gmail.com> writes:\n\n> This patch aims to fix a bug where the calculation of the diffstat width\n> incorrectly uses the strlen() of line_prefix instead of its actual\n> display width.\n>\n> This patch addresses the NEEDSWORK item added by ce8529b2 (diff: leave\n> NEEDWORK notes in show_stats() function, 2022-10-21).\n>\n> V2 DIFF:\n> * Changed references from \"ANSI char\" to \"UTF-8 char\"\n\nIs that correct?  I thought these references are mostly about the\nANSI color escape sequences that are used to paint strings in color\ne.g.,\n\n    printf \"This is shown in \\033[31mRED\\033[0m color\\012\"\n\nuses \"\\033[31m\" (use RED as the foreground color) and \"\\033[0m\"\n(reset all styles and colors).  The problem the NEEDSWORK comment\ntalks about is that the code uses strlen() but these two sequences\nin the above example are 0-width as far as the terminal display\nwidth computation is concerned.  And that is why we want to use\nutf8_strnwidth() with SKIP_ANSI bit on.\n\n>  diff.c                 | 12 ++++--------\n>  t/b                    |  0\n>  t/t4052-stat-output.sh | 30 ++++++++++++++++++++++++++++++\n>  3 files changed, 34 insertions(+), 8 deletions(-)\n>  create mode 100644 t/b\n\nI doubt you meant to add a new file there ;-)\n"},{"id":"537312","messageId":"xmqq1pi6rrdk.fsf@gitster.g","threadId":"65064","inReplyTo":"984fa10d728aad049d0430472e85f1ed0e5ea4de.1772136203.git.lorenzo.pegorari2002@gmail.com","subject":"Re: [GSoC PATCH v2 2/2] t4052: add test for diffstat width when prefix contains UTF-8 chars","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-02-27T18:08:39Z","receivedAt":"2026-02-27T18:08:41Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"LorenzoPegorari <lorenzo.pegorari2002@gmail.com> writes:\n\n> Add test checking the calculation of the diffstat display width when the\n> `line_prefix`, which is text that goes before the diffstat, contains\n> UTF-8 characters.\n\nThis does not want to say UTF-8 for two reasons.  US-ASCII is a\nsubset of UTF-8, and more importantly, most of the problems\nmiscounting the display width of the line-prefix part comes from the\nfact that ANSI color escapes are 0-width but consumes strlen() bytes.\n\nCuriously ...\n\n> +# git-log will print only 1 commit containing a single branch graph and a diffstat.\n> +# The diffstat will be only one file, with a placeholder FILENAME, that, with\n> +# enough terminal display width, will contain the following line:\n> +#     \"<RED>|<RESET>  ${FILENAME} | 0\"\n> +# where \"<RED>\" and \"<RESET>\" are ANSI escape codes to color the text.\n\n... this does say \"ANSI escape codes to color the text\", which is\nexactly what we want to say ;-)\n\n"},{"id":"537340","messageId":"cover.1772226209.git.lorenzo.pegorari2002@gmail.com","threadId":"65064","inReplyTo":"cover.1772136203.git.lorenzo.pegorari2002@gmail.com","subject":"[GSoC PATCH v3 0/2] diff: handle ANSI escape codes in prefix when calculating diffstat width","fromName":"LorenzoPegorari","fromEmail":"lorenzo.pegorari2002@gmail.com","sentAt":"2026-02-27T21:43:14Z","receivedAt":"2026-02-27T21:43:18Z","isPatch":true,"sender":{"key":"lorenzo.pegorari2002@gmail.com","avatar":"https://avatars.githubusercontent.com/u/132087553?v=4"},"body":"This patch aims to fix a bug where the calculation of the diffstat width\nincorrectly uses the strlen() of line_prefix instead of its actual\ndisplay width.\n\nThis patch addresses the NEEDSWORK item added by ce8529b2 (diff: leave\nNEEDWORK notes in show_stats() function, 2022-10-21).\n\nThanks Junio for you guidance.\n\nV3 DIFF:\n* Changed references from \"UTF-8 char\" to \"ANSI escape codes\"\n* Removed mistakenly added empty file\n* Slightly improved the test script comment\n\nLorenzoPegorari (2):\n  diff: handle ANSI escape codes in prefix when calculating diffstat\n    width\n  t4052: test for diffstat width when prefix contains ANSI escape codes\n\n diff.c                 | 12 ++++--------\n t/t4052-stat-output.sh | 32 ++++++++++++++++++++++++++++++++\n 2 files changed, 36 insertions(+), 8 deletions(-)\n\nRange-diff against v2:\n1:  9e8161a700 ! 1:  f75d6d779e diff: handle UTF-8 chars in prefix when calculating diffstat width\n    @@ Metadata\n     Author: LorenzoPegorari <lorenzo.pegorari2002@gmail.com>\n     \n      ## Commit message ##\n    -    diff: handle UTF-8 chars in prefix when calculating diffstat width\n    +    diff: handle ANSI escape codes in prefix when calculating diffstat width\n     \n         The diffstat width is calculated by taking the terminal width and\n         incorrectly subtracting the `strlen()` of `line_prefix`, instead of the\n    -    actual display width of `line_prefix`, which may contain UTF-8\n    -    characters (e.g., ANSI-colored strings in `log --graph --stat`).\n    +    actual display width of `line_prefix`, which may contain ANSI escape\n    +    codes (e.g., ANSI-colored strings in `log --graph --stat`).\n     \n         Utilize the display width instead, obtained via `utf8_strnwidth()` with\n         the flag `skip_ansi`.\n    @@ diff.c: static void show_stats(struct diffstat_t *data, struct diff_options *opt\n      \t/*\n     -\t * We have width = stat_width or term_columns() columns total.\n     +\t * We have width = stat_width or term_columns() columns total minus the\n    -+\t * length of line_prefix skipping UTF-8 chars to get the display width\n    -+\t * (e.g., to skip ANSI-colored strings in \"log --graph --stat\").\n    ++\t * length of line_prefix skipping ANSI escape codes to get the display\n    ++\t * width (e.g., skip ANSI-colored strings in \"log --graph --stat\").\n      \t * We want a maximum of min(max_len, stat_name_width) for the name part.\n      \t * We want a maximum of min(max_change, stat_graph_width) for the +- part.\n      \t * We also need 1 for \" \" and 4 + decimal_width(max_change)\n2:  984fa10d72 ! 2:  1d55bff06e t4052: add test for diffstat width when prefix contains UTF-8 chars\n    @@ Metadata\n     Author: LorenzoPegorari <lorenzo.pegorari2002@gmail.com>\n     \n      ## Commit message ##\n    -    t4052: add test for diffstat width when prefix contains UTF-8 chars\n    +    t4052: test for diffstat width when prefix contains ANSI escape codes\n     \n         Add test checking the calculation of the diffstat display width when the\n         `line_prefix`, which is text that goes before the diffstat, contains\n    -    UTF-8 characters.\n    +    ANSI escape codes.\n     \n         This situation happens, for example, when `git log --stat --graph` is\n         executed:\n         * `--stat` will create a diffstat for each commit\n         * `--graph` will stuff `line_prefix` with the graph portion of the log,\n    -      which contains UTF-8 characters (ANSI escape codes to color the text)\n    +      which contains ANSI escape codes to color the text\n     \n         Signed-off-by: LorenzoPegorari <lorenzo.pegorari2002@gmail.com>\n     \n    - ## t/b (new) ##\n    -\n      ## t/t4052-stat-output.sh ##\n     @@ t/t4052-stat-output.sh: test_expect_success 'merge --stat respects COLUMNS with long name' '\n      \ttest_cmp expect actual\n      '\n      \n    -+# git-log will print only 1 commit containing a single branch graph and a diffstat.\n    ++# We want git-log to print only 1 commit containing a single branch graph and a\n    ++# diffstat (the diffstat display width, when not manually set through the\n    ++# option \"--stat-width\", will be automatically calculated).\n     +# The diffstat will be only one file, with a placeholder FILENAME, that, with\n     +# enough terminal display width, will contain the following line:\n     +#     \"<RED>|<RESET>  ${FILENAME} | 0\"\n    @@ t/t4052-stat-output.sh: test_expect_success 'merge --stat respects COLUMNS with\n     +# FILENAME in the diffstat will not be shortened, we take the FILENAME length\n     +# and add 9 to it.\n     +# To check if the diffstat width, when the line_prefix (the \"<RED>|<RESET>\" of\n    -+# the graph) contains UTF-8 characters (the ANSI escape codes), is calculated\n    -+# correctly, we:\n    ++# the graph) contains ANSI escape codes (the ANSI escape codes to color the\n    ++# text), is calculated correctly, we:\n     +#     1. check if it contains the line defined before when using MIN_TERM_WIDTH\n     +#     2. check if it contains the line defined before, but with the FILENAME\n     +#        shortened by only one character, when using MIN_TERM_WIDTH - 1\n     +\n    -+test_expect_success 'diffstat where line_prefix contains UTF-8 chars is correct width' '\n    ++test_expect_success 'diffstat where line_prefix contains ANSI escape codes is correct width' '\n     +\tFILENAME=\"placeholder-text-placeholder-text\" &&\n     +\tFILENAME_TRIMMED=\"...eholder-text-placeholder-text\" &&\n     +\tMIN_TERM_WIDTH=$((${#FILENAME} + 9)) &&\n-- \n2.43.0\n\n"},{"id":"537341","messageId":"f75d6d779e893c47665fea0162fff6f35dea1b49.1772226209.git.lorenzo.pegorari2002@gmail.com","threadId":"65064","inReplyTo":"cover.1772226209.git.lorenzo.pegorari2002@gmail.com","subject":"[GSoC PATCH v3 1/2] diff: handle ANSI escape codes in prefix when calculating diffstat width","fromName":"LorenzoPegorari","fromEmail":"lorenzo.pegorari2002@gmail.com","sentAt":"2026-02-27T21:45:19Z","receivedAt":"2026-02-27T21:45:23Z","isPatch":true,"sender":{"key":"lorenzo.pegorari2002@gmail.com","avatar":"https://avatars.githubusercontent.com/u/132087553?v=4"},"body":"The diffstat width is calculated by taking the terminal width and\nincorrectly subtracting the `strlen()` of `line_prefix`, instead of the\nactual display width of `line_prefix`, which may contain ANSI escape\ncodes (e.g., ANSI-colored strings in `log --graph --stat`).\n\nUtilize the display width instead, obtained via `utf8_strnwidth()` with\nthe flag `skip_ansi`.\n\nSigned-off-by: LorenzoPegorari <lorenzo.pegorari2002@gmail.com>\n---\n diff.c | 12 ++++--------\n 1 file changed, 4 insertions(+), 8 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 35b903a9a0..6eaf40fe2e 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -2749,7 +2749,9 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)\n \tcount = i; /* where we can stop scanning in data->files[] */\n \n \t/*\n-\t * We have width = stat_width or term_columns() columns total.\n+\t * We have width = stat_width or term_columns() columns total minus the\n+\t * length of line_prefix skipping ANSI escape codes to get the display\n+\t * width (e.g., skip ANSI-colored strings in \"log --graph --stat\").\n \t * We want a maximum of min(max_len, stat_name_width) for the name part.\n \t * We want a maximum of min(max_change, stat_graph_width) for the +- part.\n \t * We also need 1 for \" \" and 4 + decimal_width(max_change)\n@@ -2776,14 +2778,8 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)\n \t * separators and this message, this message will \"overflow\"\n \t * making the line longer than the maximum width.\n \t */\n-\n-\t/*\n-\t * NEEDSWORK: line_prefix is often used for \"log --graph\" output\n-\t * and contains ANSI-colored string.  utf8_strnwidth() should be\n-\t * used to correctly count the display width instead of strlen().\n-\t */\n \tif (options->stat_width == -1)\n-\t\twidth = term_columns() - strlen(line_prefix);\n+\t\twidth = term_columns() - utf8_strnwidth(line_prefix, strlen(line_prefix), 1);\n \telse\n \t\twidth = options->stat_width ? options->stat_width : 80;\n \tnumber_width = decimal_width(max_change) > number_width ?\n-- \n2.43.0\n\n"},{"id":"537342","messageId":"1d55bff06ed3ec046d26ac99650d74d3c4fa50b8.1772226209.git.lorenzo.pegorari2002@gmail.com","threadId":"65064","inReplyTo":"cover.1772226209.git.lorenzo.pegorari2002@gmail.com","subject":"[GSoC PATCH v3 2/2] t4052: test for diffstat width when prefix contains ANSI escape codes","fromName":"LorenzoPegorari","fromEmail":"lorenzo.pegorari2002@gmail.com","sentAt":"2026-02-27T21:48:35Z","receivedAt":"2026-02-27T21:48:39Z","isPatch":true,"sender":{"key":"lorenzo.pegorari2002@gmail.com","avatar":"https://avatars.githubusercontent.com/u/132087553?v=4"},"body":"Add test checking the calculation of the diffstat display width when the\n`line_prefix`, which is text that goes before the diffstat, contains\nANSI escape codes.\n\nThis situation happens, for example, when `git log --stat --graph` is\nexecuted:\n* `--stat` will create a diffstat for each commit\n* `--graph` will stuff `line_prefix` with the graph portion of the log,\n  which contains ANSI escape codes to color the text\n\nSigned-off-by: LorenzoPegorari <lorenzo.pegorari2002@gmail.com>\n---\n t/t4052-stat-output.sh | 32 ++++++++++++++++++++++++++++++++\n 1 file changed, 32 insertions(+)\n\ndiff --git a/t/t4052-stat-output.sh b/t/t4052-stat-output.sh\nindex 740bb97091..7c749062e2 100755\n--- a/t/t4052-stat-output.sh\n+++ b/t/t4052-stat-output.sh\n@@ -413,4 +413,36 @@ test_expect_success 'merge --stat respects COLUMNS with long name' '\n \ttest_cmp expect actual\n '\n \n+# We want git-log to print only 1 commit containing a single branch graph and a\n+# diffstat (the diffstat display width, when not manually set through the\n+# option \"--stat-width\", will be automatically calculated).\n+# The diffstat will be only one file, with a placeholder FILENAME, that, with\n+# enough terminal display width, will contain the following line:\n+#     \"<RED>|<RESET>  ${FILENAME} | 0\"\n+# where \"<RED>\" and \"<RESET>\" are ANSI escape codes to color the text.\n+# To calculate the minimium terminal display width MIN_TERM_WIDTH so that the\n+# FILENAME in the diffstat will not be shortened, we take the FILENAME length\n+# and add 9 to it.\n+# To check if the diffstat width, when the line_prefix (the \"<RED>|<RESET>\" of\n+# the graph) contains ANSI escape codes (the ANSI escape codes to color the\n+# text), is calculated correctly, we:\n+#     1. check if it contains the line defined before when using MIN_TERM_WIDTH\n+#     2. check if it contains the line defined before, but with the FILENAME\n+#        shortened by only one character, when using MIN_TERM_WIDTH - 1\n+\n+test_expect_success 'diffstat where line_prefix contains ANSI escape codes is correct width' '\n+\tFILENAME=\"placeholder-text-placeholder-text\" &&\n+\tFILENAME_TRIMMED=\"...eholder-text-placeholder-text\" &&\n+\tMIN_TERM_WIDTH=$((${#FILENAME} + 9)) &&\n+\ttest_config color.diff always &&\n+\tgit commit --allow-empty --allow-empty-message &&\n+\t>${FILENAME} &&\n+\tgit add ${FILENAME} &&\n+\tgit commit --allow-empty-message &&\n+\tCOLUMNS=$((MIN_TERM_WIDTH)) git log --graph --stat -n1 | test_decode_color >out &&\n+\ttest_grep \"<RED>|<RESET>  ${FILENAME} | 0\" out &&\n+\tCOLUMNS=$((MIN_TERM_WIDTH - 1)) git log --graph --stat -n1 | test_decode_color >out &&\n+\ttest_grep \"<RED>|<RESET>  ${FILENAME_TRIMMED} | 0\" out\n+'\n+\n test_done\n-- \n2.43.0\n\n"}]}