git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [Patch v2 2/2] add: test use of brackets when color is disabled

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
Jun 7, 2023, 15:31 UTC
Message-ID
<2143c98e-238b-8edc-a16c-be448a8b56e8@gmail.com>
In-Reply-To
<281431b8-af40-9de9-f4b4-c596c5dbb3af@github.com>
Hi Stolee
On 07/06/2023 14:44, Derrick Stolee wrote:
Show 22 quoted lines
>  From 02156b81bbb2cafb19d702c55d45714fcf224048 Mon Sep 17 00:00:00 2001
> From: Derrick Stolee <derrickstolee@github.com>
> Date: Wed, 7 Jun 2023 09:39:01 -0400
> Subject: [PATCH v2 2/2] add: test use of brackets when color is disabled
> 
> The interactive add command, 'git add -i', displays a menu of options
> using full words. When color is enabled, the first letter of each word
> is changed to a highlight color to signal that the first letter could be
> used as a command. Without color, brackets ("[]") are used around these
> first letters.
> 
> This behavior was not previously tested directly in t3701, so add a test
> for it now. Since we use 'git add -i >actual <input' without
> 'force_color', the color system recognizes that colors are not available
> on stdout and will be disabled by default.
> 
> This test would reproduce correctly with or without the fix in the
> previous commit to make sure that color.ui is respected in 'git add'.
> 
> Reported-by: Phillip Wood <phillip.wood@dunelm.org.uk>
> Signed-off-by: Derrick Stolee <derrickstolee@github.com>
> ---

Thanks for adding this, the patch looks good. Strictly speaking you don't need the "g" at the end of the sed expression as it only ever matches a single instance within each line but that's not worth worrying about.

Best Wishes
Phillip
Show 46 quoted lines
> Here is the patch to add this test on top of the previous change.
> 
> I've only validated this on my local computer, not through the
> GitGitGadget PR. If needed, I could send a v3 via GitGitGadget,
> but thought this would be a simple-enough addition here.
> 
> Thanks,
> -Stolee
> 
>   t/t3701-add-interactive.sh | 23 +++++++++++++++++++++++
>   1 file changed, 23 insertions(+)
> 
> diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh
> index a93fe54e2ad..df3e85fc8d6 100755
> --- a/t/t3701-add-interactive.sh
> +++ b/t/t3701-add-interactive.sh
> @@ -734,6 +734,29 @@ test_expect_success 'colors can be overridden' '
>   	test_cmp expect actual
>   '
>   
> +test_expect_success 'brackets appear without color' '
> +	git reset --hard &&
> +	test_when_finished "git rm -f bracket-test" &&
> +	test_write_lines context old more-context >bracket-test &&
> +	git add bracket-test &&
> +	test_write_lines context new more-context another-one >bracket-test &&
> +
> +	test_write_lines quit >input &&
> +	git add -i >actual <input &&
> +
> +	sed "s/^|//g" >expect <<-\EOF &&
> +	|           staged     unstaged path
> +	|  1:        +3/-0        +2/-1 bracket-test
> +	|
> +	|*** Commands ***
> +	|  1: [s]tatus	  2: [u]pdate	  3: [r]evert	  4: [a]dd untracked
> +	|  5: [p]atch	  6: [d]iff	  7: [q]uit	  8: [h]elp
> +	|What now> Bye.
> +	EOF
> +
> +	test_cmp expect actual
> +'
> +
>   test_expect_success 'colors can be skipped with color.ui=false' '
>   	git reset --hard &&
>   	test_when_finished "git rm -f color-test" &&
Previous: Derrick StoleeNext: Junio C Hamano
Message 11 of 12 in “add: check color.ui for interactive add”
  1. add: check color.ui for interactive addDerrick Stolee via GitGitGadget, Jun 5, 2023
  2. Junio C HamanoJun 6, 2023
  3. Junio C HamanoJun 6, 2023
  4. Jeff KingJun 6, 2023
  5. Derrick StoleeJun 6, 2023
  6. add: check color.ui for interactive addDerrick Stolee via GitGitGadget, Jun 6, 2023
  7. Phillip WoodJun 7, 2023
  8. Derrick StoleeJun 7, 2023
  9. Junio C HamanoJun 12, 2023
  10. 2/2 add: test use of brackets when color is disabledDerrick Stolee, Jun 7, 2023
  11. Phillip WoodJun 7, 2023
  12. Junio C HamanoJun 12, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.