]> git.ipfire.org Git - thirdparty/git.git/blame - t/t7005-editor.sh
Call 'say' outside test_expect_success
[thirdparty/git.git] / t / t7005-editor.sh
CommitLineData
ef0c2abf
AR
1#!/bin/sh
2
3test_description='GIT_EDITOR, core.editor, and stuff'
4
5. ./test-lib.sh
6
7for i in GIT_EDITOR core_editor EDITOR VISUAL vi
8do
9 cat >e-$i.sh <<-EOF
10 echo "Edited by $i" >"\$1"
11 EOF
12 chmod +x e-$i.sh
13done
14unset vi
15mv e-vi.sh vi
ef0c2abf
AR
16unset EDITOR VISUAL GIT_EDITOR
17
18test_expect_success setup '
19
20 msg="Hand edited" &&
21 echo "$msg" >expect &&
22 git add vi &&
23 test_tick &&
24 git commit -m "$msg" &&
25 git show -s --pretty=oneline |
26 sed -e "s/^[0-9a-f]* //" >actual &&
27 diff actual expect
28
29'
30
31TERM=dumb
32export TERM
33test_expect_success 'dumb should error out when falling back on vi' '
34
35 if git commit --amend
36 then
37 echo "Oops?"
72638812 38 false
ef0c2abf
AR
39 else
40 : happy
41 fi
42'
43
44TERM=vt100
45export TERM
46for i in vi EDITOR VISUAL core_editor GIT_EDITOR
47do
48 echo "Edited by $i" >expect
49 unset EDITOR VISUAL GIT_EDITOR
50 git config --unset-all core.editor
51 case "$i" in
52 core_editor)
53 git config core.editor ./e-core_editor.sh
54 ;;
55 [A-Z]*)
56 eval "$i=./e-$i.sh"
57 export $i
58 ;;
59 esac
60 test_expect_success "Using $i" '
e70f3202 61 git --exec-path=. commit --amend &&
ef0c2abf
AR
62 git show -s --pretty=oneline |
63 sed -e "s/^[0-9a-f]* //" >actual &&
64 diff actual expect
65 '
66done
67
68unset EDITOR VISUAL GIT_EDITOR
69git config --unset-all core.editor
70for i in vi EDITOR VISUAL core_editor GIT_EDITOR
71do
72 echo "Edited by $i" >expect
73 case "$i" in
74 core_editor)
75 git config core.editor ./e-core_editor.sh
76 ;;
77 [A-Z]*)
78 eval "$i=./e-$i.sh"
79 export $i
80 ;;
81 esac
82 test_expect_success "Using $i (override)" '
e70f3202 83 git --exec-path=. commit --amend &&
ef0c2abf
AR
84 git show -s --pretty=oneline |
85 sed -e "s/^[0-9a-f]* //" >actual &&
86 diff actual expect
87 '
88done
89
5b46a428
JS
90if ! echo 'echo space > "$1"' > "e space.sh"
91then
92 say "Skipping; FS does not support spaces in filenames"
93 test_done
94 exit
95fi
96
fc99469a
JS
97test_expect_success 'editor with a space' '
98
5b46a428
JS
99 chmod a+x "e space.sh" &&
100 GIT_EDITOR="./e\ space.sh" git commit --amend &&
101 test space = "$(git show -s --pretty=format:%s)"
fc99469a
JS
102
103'
104
105unset GIT_EDITOR
106test_expect_success 'core.editor with a space' '
107
5b46a428
JS
108 git config core.editor \"./e\ space.sh\" &&
109 git commit --amend &&
110 test space = "$(git show -s --pretty=format:%s)"
fc99469a
JS
111
112'
113
ef0c2abf 114test_done