]>
Commit | Line | Data |
---|---|---|
1 | #!/bin/sh | |
2 | ||
3 | test_description='GIT_EDITOR, core.editor, and stuff' | |
4 | ||
5 | . ./test-lib.sh | |
6 | ||
7 | OLD_TERM="$TERM" | |
8 | ||
9 | for i in GIT_EDITOR core_editor EDITOR VISUAL vi | |
10 | do | |
11 | cat >e-$i.sh <<-EOF | |
12 | echo "Edited by $i" >"\$1" | |
13 | EOF | |
14 | chmod +x e-$i.sh | |
15 | done | |
16 | unset vi | |
17 | mv e-vi.sh vi | |
18 | PATH=".:$PATH" | |
19 | unset EDITOR VISUAL GIT_EDITOR | |
20 | ||
21 | test_expect_success setup ' | |
22 | ||
23 | msg="Hand edited" && | |
24 | echo "$msg" >expect && | |
25 | git add vi && | |
26 | test_tick && | |
27 | git commit -m "$msg" && | |
28 | git show -s --pretty=oneline | | |
29 | sed -e "s/^[0-9a-f]* //" >actual && | |
30 | diff actual expect | |
31 | ||
32 | ' | |
33 | ||
34 | TERM=dumb | |
35 | export TERM | |
36 | test_expect_success 'dumb should error out when falling back on vi' ' | |
37 | ||
38 | if git commit --amend | |
39 | then | |
40 | echo "Oops?" | |
41 | exit 1 | |
42 | else | |
43 | : happy | |
44 | fi | |
45 | ' | |
46 | ||
47 | TERM=vt100 | |
48 | export TERM | |
49 | for i in vi EDITOR VISUAL core_editor GIT_EDITOR | |
50 | do | |
51 | echo "Edited by $i" >expect | |
52 | unset EDITOR VISUAL GIT_EDITOR | |
53 | git config --unset-all core.editor | |
54 | case "$i" in | |
55 | core_editor) | |
56 | git config core.editor ./e-core_editor.sh | |
57 | ;; | |
58 | [A-Z]*) | |
59 | eval "$i=./e-$i.sh" | |
60 | export $i | |
61 | ;; | |
62 | esac | |
63 | test_expect_success "Using $i" ' | |
64 | git commit --amend && | |
65 | git show -s --pretty=oneline | | |
66 | sed -e "s/^[0-9a-f]* //" >actual && | |
67 | diff actual expect | |
68 | ' | |
69 | done | |
70 | ||
71 | unset EDITOR VISUAL GIT_EDITOR | |
72 | git config --unset-all core.editor | |
73 | for i in vi EDITOR VISUAL core_editor GIT_EDITOR | |
74 | do | |
75 | echo "Edited by $i" >expect | |
76 | case "$i" in | |
77 | core_editor) | |
78 | git config core.editor ./e-core_editor.sh | |
79 | ;; | |
80 | [A-Z]*) | |
81 | eval "$i=./e-$i.sh" | |
82 | export $i | |
83 | ;; | |
84 | esac | |
85 | test_expect_success "Using $i (override)" ' | |
86 | git commit --amend && | |
87 | git show -s --pretty=oneline | | |
88 | sed -e "s/^[0-9a-f]* //" >actual && | |
89 | diff actual expect | |
90 | ' | |
91 | done | |
92 | ||
93 | TERM="$OLD_TERM" | |
94 | ||
95 | test_done |