git-show: do not segfault when showing a bad tag
[git/platforms.git] / t / t7005-editor.sh
blob2d919d69ef110408b820c76185d6b8da63ea183e
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 echo "Edited by $i" >"\$1"
11 EOF
12 chmod +x e-$i.sh
13 done
14 unset vi
15 mv e-vi.sh vi
16 unset EDITOR VISUAL GIT_EDITOR
18 test_expect_success setup '
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
31 TERM=dumb
32 export TERM
33 test_expect_success 'dumb should error out when falling back on vi' '
35 if git commit --amend
36 then
37 echo "Oops?"
38 false
39 else
40 : happy
44 TERM=vt100
45 export TERM
46 for i in vi EDITOR VISUAL core_editor GIT_EDITOR
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
55 [A-Z]*)
56 eval "$i=./e-$i.sh"
57 export $i
59 esac
60 test_expect_success "Using $i" '
61 git --exec-path=. commit --amend &&
62 git show -s --pretty=oneline |
63 sed -e "s/^[0-9a-f]* //" >actual &&
64 diff actual expect
66 done
68 unset EDITOR VISUAL GIT_EDITOR
69 git config --unset-all core.editor
70 for i in vi EDITOR VISUAL core_editor GIT_EDITOR
72 echo "Edited by $i" >expect
73 case "$i" in
74 core_editor)
75 git config core.editor ./e-core_editor.sh
77 [A-Z]*)
78 eval "$i=./e-$i.sh"
79 export $i
81 esac
82 test_expect_success "Using $i (override)" '
83 git --exec-path=. commit --amend &&
84 git show -s --pretty=oneline |
85 sed -e "s/^[0-9a-f]* //" >actual &&
86 diff actual expect
88 done
90 test_expect_success 'editor with a space' '
92 if echo "echo space > \"\$1\"" > "e space.sh"
93 then
94 chmod a+x "e space.sh" &&
95 GIT_EDITOR="./e\ space.sh" git commit --amend &&
96 test space = "$(git show -s --pretty=format:%s)"
97 else
98 say "Skipping; FS does not support spaces in filenames"
103 unset GIT_EDITOR
104 test_expect_success 'core.editor with a space' '
106 if test -f "e space.sh"
107 then
108 git config core.editor \"./e\ space.sh\" &&
109 git commit --amend &&
110 test space = "$(git show -s --pretty=format:%s)"
111 else
112 say "Skipping; FS does not support spaces in filenames"
117 test_done