Windows ANSI - hook write()
[git/mingw/4msysgit/peterh.git] / t / t7005-editor.sh
blobec166b21b13a588c147e3be4c94c7e17487b0e45
1 #!/bin/sh
3 test_description='GIT_EDITOR, core.editor, and stuff'
5 . ./test-lib.sh
7 for i in GIT_EDITOR core_editor EDITOR VISUAL vi
8 do
9 cat >e-$i.sh <<-EOF
10 #!/bin/sh
11 echo "Edited by $i" >"\$1"
12 EOF
13 chmod +x e-$i.sh
14 done
15 unset vi
16 mv e-vi.sh vi
17 unset EDITOR VISUAL GIT_EDITOR
19 test_expect_success setup '
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
32 TERM=dumb
33 export TERM
34 test_expect_success 'dumb should error out when falling back on vi' '
36 if git commit --amend
37 then
38 echo "Oops?"
39 false
40 else
41 : happy
45 TERM=vt100
46 export TERM
47 for i in vi EDITOR VISUAL core_editor GIT_EDITOR
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
56 [A-Z]*)
57 eval "$i=./e-$i.sh"
58 export $i
60 esac
61 test_expect_success "Using $i" '
62 git --exec-path=. commit --amend &&
63 git show -s --pretty=oneline |
64 sed -e "s/^[0-9a-f]* //" >actual &&
65 diff actual expect
67 done
69 unset EDITOR VISUAL GIT_EDITOR
70 git config --unset-all core.editor
71 for i in vi EDITOR VISUAL core_editor GIT_EDITOR
73 echo "Edited by $i" >expect
74 case "$i" in
75 core_editor)
76 git config core.editor ./e-core_editor.sh
78 [A-Z]*)
79 eval "$i=./e-$i.sh"
80 export $i
82 esac
83 test_expect_success "Using $i (override)" '
84 git --exec-path=. commit --amend &&
85 git show -s --pretty=oneline |
86 sed -e "s/^[0-9a-f]* //" >actual &&
87 diff actual expect
89 done
91 test_expect_success 'editor with a space' '
93 if echo "echo space > \"\$1\"" > "e space.sh"
94 then
95 chmod a+x "e space.sh" &&
96 GIT_EDITOR="./e\ space.sh" git commit --amend &&
97 test space = "$(git show -s --pretty=format:%s)"
98 else
99 say "Skipping; FS does not support spaces in filenames"
104 unset GIT_EDITOR
105 test_expect_success 'core.editor with a space' '
107 if test -f "e space.sh"
108 then
109 git config core.editor \"./e\ space.sh\" &&
110 git commit --amend &&
111 test space = "$(git show -s --pretty=format:%s)"
112 else
113 say "Skipping; FS does not support spaces in filenames"
118 test_done