bundle: use OPT_PASSTHRU_ARGV
[git/debian.git] / t / t9003-help-autocorrect.sh
blob14a704d0a8c311ff776f65313178073e70b0a38f
1 #!/bin/sh
3 test_description='help.autocorrect finding a match'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
8 test_expect_success 'setup' '
9 # An alias
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
15 EOF
17 PATH="$PATH:." &&
18 export PATH &&
20 git commit --allow-empty -m "a single log entry" &&
22 # Sanity check
23 git lgf >actual &&
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 &&
47 git lfg >actual &&
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
55 done
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
71 test_done