3 test_description
='GIT_EDITOR, core.editor, and stuff'
7 unset EDITOR VISUAL GIT_EDITOR
9 test_expect_success
'determine default editor' '
11 vi=$(TERM=vt100 git var GIT_EDITOR) &&
16 if ! expr "$vi" : '[a-z]*$' >/dev
/null
21 for i
in GIT_EDITOR core_editor EDITOR VISUAL
$vi
25 echo "Edited by $i" >"\$1"
35 test_expect_success setup
'
39 echo "$msg" >expect &&
40 git show -s --format=%s > actual &&
41 test_cmp expect actual
47 test_expect_success
'dumb should error out when falling back on vi' '
58 test_expect_success
'dumb should prefer EDITOR to VISUAL' '
60 EDITOR=./e-EDITOR.sh &&
61 VISUAL=./e-VISUAL.sh &&
62 export EDITOR VISUAL &&
64 test "$(git show -s --format=%s)" = "Edited by EDITOR"
70 for i
in $vi EDITOR VISUAL core_editor GIT_EDITOR
72 echo "Edited by $i" >expect
73 unset EDITOR VISUAL GIT_EDITOR
74 git config
--unset-all core.editor
77 git config core.editor .
/e-core_editor.sh
84 test_expect_success
"Using $i" '
85 git --exec-path=. commit --amend &&
86 git show -s --pretty=oneline |
87 sed -e "s/^[0-9a-f]* //" >actual &&
88 test_cmp expect actual
92 unset EDITOR VISUAL GIT_EDITOR
93 git config
--unset-all core.editor
94 for i
in $vi EDITOR VISUAL core_editor GIT_EDITOR
96 echo "Edited by $i" >expect
99 git config core.editor .
/e-core_editor.sh
106 test_expect_success
"Using $i (override)" '
107 git --exec-path=. commit --amend &&
108 git show -s --pretty=oneline |
109 sed -e "s/^[0-9a-f]* //" >actual &&
110 test_cmp expect actual
114 test_expect_success
'editor with a space' '
115 echo "echo space >\$1" >"e space.sh" &&
116 chmod a+x "e space.sh" &&
117 GIT_EDITOR="./e\ space.sh" git commit --amend &&
118 test space = "$(git show -s --pretty=format:%s)"
123 test_expect_success
'core.editor with a space' '
125 git config core.editor \"./e\ space.sh\" &&
126 git commit --amend &&
127 test space = "$(git show -s --pretty=format:%s)"