3 test_description
='GIT_EDITOR, core.editor, and stuff'
5 TEST_PASSES_SANITIZE_LEAK
=true
8 unset EDITOR VISUAL GIT_EDITOR
10 test_expect_success
'determine default editor' '
12 vi=$(TERM=vt100 git var GIT_EDITOR) &&
17 if ! expr "$vi" : '[a-z]*$' >/dev
/null
22 for i
in GIT_EDITOR core_editor EDITOR VISUAL
$vi
26 echo "Edited by $i" >"\$1"
36 test_expect_success setup
'
40 echo "$msg" >expect &&
41 git show -s --format=%s > actual &&
42 test_cmp expect actual
48 test_expect_success
'dumb should error out when falling back on vi' '
59 test_expect_success
'dumb should prefer EDITOR to VISUAL' '
61 EDITOR=./e-EDITOR.sh &&
62 VISUAL=./e-VISUAL.sh &&
63 export EDITOR VISUAL &&
65 test "$(git show -s --format=%s)" = "Edited by EDITOR"
71 for i
in $vi EDITOR VISUAL core_editor GIT_EDITOR
73 echo "Edited by $i" >expect
74 unset EDITOR VISUAL GIT_EDITOR
75 git config
--unset-all core.editor
78 git config core.editor .
/e-core_editor.sh
85 test_expect_success
"Using $i" '
86 git --exec-path=. commit --amend &&
87 git show -s --pretty=oneline |
88 sed -e "s/^[0-9a-f]* //" >actual &&
89 test_cmp expect actual
93 unset EDITOR VISUAL GIT_EDITOR
94 git config
--unset-all core.editor
95 for i
in $vi EDITOR VISUAL core_editor GIT_EDITOR
97 echo "Edited by $i" >expect
100 git config core.editor .
/e-core_editor.sh
107 test_expect_success
"Using $i (override)" '
108 git --exec-path=. commit --amend &&
109 git show -s --pretty=oneline |
110 sed -e "s/^[0-9a-f]* //" >actual &&
111 test_cmp expect actual
115 test_expect_success
'editor with a space' '
116 echo "echo space >\"\$1\"" >"e space.sh" &&
117 chmod a+x "e space.sh" &&
118 GIT_EDITOR="./e\ space.sh" git commit --amend &&
119 test space = "$(git show -s --pretty=format:%s)"
124 test_expect_success
'core.editor with a space' '
126 git config core.editor \"./e\ space.sh\" &&
127 git commit --amend &&
128 test space = "$(git show -s --pretty=format:%s)"