Skip to content

Commit 6f74648

Browse files
derrickstoleegitster
authored andcommitted
add: test use of brackets when color is disabled
From 02156b8 Mon Sep 17 00:00:00 2001 From: Derrick Stolee <[email protected]> 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 <[email protected]> Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7cf3b49 commit 6f74648

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

t/t3701-add-interactive.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,29 @@ test_expect_success 'colors can be overridden' '
738738
test_cmp expect actual
739739
'
740740

741+
test_expect_success 'brackets appear without color' '
742+
git reset --hard &&
743+
test_when_finished "git rm -f bracket-test" &&
744+
test_write_lines context old more-context >bracket-test &&
745+
git add bracket-test &&
746+
test_write_lines context new more-context another-one >bracket-test &&
747+
748+
test_write_lines quit >input &&
749+
git add -i >actual <input &&
750+
751+
sed "s/^|//" >expect <<-\EOF &&
752+
| staged unstaged path
753+
| 1: +3/-0 +2/-1 bracket-test
754+
|
755+
|*** Commands ***
756+
| 1: [s]tatus 2: [u]pdate 3: [r]evert 4: [a]dd untracked
757+
| 5: [p]atch 6: [d]iff 7: [q]uit 8: [h]elp
758+
|What now> Bye.
759+
EOF
760+
761+
test_cmp expect actual
762+
'
763+
741764
test_expect_success 'colors can be skipped with color.ui=false' '
742765
git reset --hard &&
743766
test_when_finished "git rm -f color-test" &&

0 commit comments

Comments
 (0)