Add tests for git tag
[git/dscho.git] / t / t7005-editor.sh
blob01cc0c02b1c20afef664110389b88af702c52ef7
1 #!/bin/sh
3 test_description='GIT_EDITOR, core.editor, and stuff'
5 . ./test-lib.sh
7 OLD_TERM="$TERM"
9 for i in GIT_EDITOR core_editor EDITOR VISUAL vi
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
21 test_expect_success setup '
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
34 TERM=dumb
35 export TERM
36 test_expect_success 'dumb should error out when falling back on vi' '
38 if git commit --amend
39 then
40 echo "Oops?"
41 exit 1
42 else
43 : happy
47 TERM=vt100
48 export TERM
49 for i in vi EDITOR VISUAL core_editor GIT_EDITOR
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
58 [A-Z]*)
59 eval "$i=./e-$i.sh"
60 export $i
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
69 done
71 unset EDITOR VISUAL GIT_EDITOR
72 git config --unset-all core.editor
73 for i in vi EDITOR VISUAL core_editor GIT_EDITOR
75 echo "Edited by $i" >expect
76 case "$i" in
77 core_editor)
78 git config core.editor ./e-core_editor.sh
80 [A-Z]*)
81 eval "$i=./e-$i.sh"
82 export $i
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
91 done
93 TERM="$OLD_TERM"
95 test_done