3 test_description
='help.autocorrect finding a match'
5 TEST_PASSES_SANITIZE_LEAK
=true
8 test_expect_success
'setup' '
10 git config alias.lgf "log --format=%s --first-parent" &&
12 # A random user-defined command
13 write_script git-distimdistim <<-EOF &&
14 echo distimdistim was called
20 git commit --allow-empty -m "a single log entry" &&
24 echo "a single log entry" >expect &&
25 test_cmp expect actual &&
27 git distimdistim >actual &&
28 echo "distimdistim was called" >expect &&
29 test_cmp expect actual
32 test_expect_success
'autocorrect showing candidates' '
33 git config help.autocorrect 0 &&
35 test_must_fail git lfg 2>actual &&
36 grep "^ lgf" actual &&
38 test_must_fail git distimdist 2>actual &&
39 grep "^ distimdistim" actual
42 for immediate
in -1 immediate
44 test_expect_success
'autocorrect running commands' '
45 git config help.autocorrect $immediate &&
48 echo "a single log entry" >expect &&
49 test_cmp expect actual &&
51 git distimdist >actual &&
52 echo "distimdistim was called" >expect &&
53 test_cmp expect actual
57 test_expect_success
'autocorrect can be declined altogether' '
58 git config help.autocorrect never &&
60 test_must_fail git lfg 2>actual &&
61 grep "is not a git command" actual &&
62 test_line_count = 1 actual
65 test_expect_success
'autocorrect works in work tree created from bare repo' '
66 git clone --bare . bare.git &&
67 git -C bare.git worktree add ../worktree &&
68 git -C worktree -c help.autocorrect=immediate stauts