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