]> git.ipfire.org Git - thirdparty/git.git/blob - t/t9003-help-autocorrect.sh
The third batch
[thirdparty/git.git] / t / t9003-help-autocorrect.sh
1 #!/bin/sh
2
3 test_description='help.autocorrect finding a match'
4
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
7
8 test_expect_success 'setup' '
9 # An alias
10 git config alias.lgf "log --format=%s --first-parent" &&
11
12 # A random user-defined command
13 write_script git-distimdistim <<-EOF &&
14 echo distimdistim was called
15 EOF
16
17 PATH="$PATH:." &&
18 export PATH &&
19
20 git commit --allow-empty -m "a single log entry" &&
21
22 # Sanity check
23 git lgf >actual &&
24 echo "a single log entry" >expect &&
25 test_cmp expect actual &&
26
27 git distimdistim >actual &&
28 echo "distimdistim was called" >expect &&
29 test_cmp expect actual
30 '
31
32 test_expect_success 'autocorrect showing candidates' '
33 git config help.autocorrect 0 &&
34
35 test_must_fail git lfg 2>actual &&
36 grep "^ lgf" actual &&
37
38 test_must_fail git distimdist 2>actual &&
39 grep "^ distimdistim" actual
40 '
41
42 for immediate in -1 immediate
43 do
44 test_expect_success 'autocorrect running commands' '
45 git config help.autocorrect $immediate &&
46
47 git lfg >actual &&
48 echo "a single log entry" >expect &&
49 test_cmp expect actual &&
50
51 git distimdist >actual &&
52 echo "distimdistim was called" >expect &&
53 test_cmp expect actual
54 '
55 done
56
57 test_expect_success 'autocorrect can be declined altogether' '
58 git config help.autocorrect never &&
59
60 test_must_fail git lfg 2>actual &&
61 grep "is not a git command" actual &&
62 test_line_count = 1 actual
63 '
64
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
69 '
70
71 test_done