summaryrefslogtreecommitdiff
path: root/t/t9003-help-autocorrect.sh
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2020-11-25 21:01:45 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-11-25 21:02:15 (GMT)
commit644bb953ce3251f2868ece6b767949828fa32e44 (patch)
tree94c5c7e5b5ed2f7c1a49dec418da026f10ff8987 /t/t9003-help-autocorrect.sh
parente31aba42fb12bdeb0f850829e008e1e3f43af500 (diff)
downloadgit-644bb953ce3251f2868ece6b767949828fa32e44.zip
git-644bb953ce3251f2868ece6b767949828fa32e44.tar.gz
git-644bb953ce3251f2868ece6b767949828fa32e44.tar.bz2
help.c: help.autocorrect=never means "do not compute suggestions"
While help.autocorrect can be set to 0 to decline auto-execution of possibly mistyped commands, it still spends cycles to compute the suggestions, and it wastes screen real estate. Update help.autocorrect to accept the string "never" to just exit with error upon mistyped commands to help users who prefer to never see suggested corrections at all. While at it, introduce "immediate" as a more readable way to immediately execute the auto-corrected command, which can be done with negative value. Signed-off-by: Drew DeVault <sir@cmpwn.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t9003-help-autocorrect.sh')
-rwxr-xr-xt/t9003-help-autocorrect.sh30
1 files changed, 22 insertions, 8 deletions
diff --git a/t/t9003-help-autocorrect.sh b/t/t9003-help-autocorrect.sh
index b1c7919..03cd5c5 100755
--- a/t/t9003-help-autocorrect.sh
+++ b/t/t9003-help-autocorrect.sh
@@ -37,16 +37,30 @@ test_expect_success 'autocorrect showing candidates' '
grep "^ distimdistim" actual
'
-test_expect_success 'autocorrect running commands' '
- git config help.autocorrect -1 &&
+for immediate in -1 immediate
+do
+ test_expect_success 'autocorrect running commands' '
+ git config help.autocorrect $immediate &&
- git lfg >actual &&
- echo "a single log entry" >expect &&
- test_cmp expect actual &&
+ git lfg >actual &&
+ echo "a single log entry" >expect &&
+ test_cmp expect actual &&
- git distimdist >actual &&
- echo "distimdistim was called" >expect &&
- test_cmp expect actual
+ git distimdist >actual &&
+ echo "distimdistim was called" >expect &&
+ test_cmp expect actual
+ '
+done
+
+test_expect_success 'autocorrect can be declined altogether' '
+ git config help.autocorrect never &&
+
+ test_must_fail git lfg 2>actual &&
+ if test_have_prereq C_LOCALE_OUTPUT
+ then
+ grep "is not a git command" actual &&
+ test_line_count = 1 actual
+ fi
'
test_done