filter-branch: Test renaming directories in a tree-filter
[git/platforms.git] / t / t7005-editor.sh
blob6a74b3acfda6774d7996cf5787e9858654357328
1 #!/bin/sh
3 test_description='GIT_EDITOR, core.editor, and stuff'
5 . ./test-lib.sh
7 OLD_TERM="$TERM"
9 for i in GIT_EDITOR core_editor EDITOR VISUAL vi
11 cat >e-$i.sh <<-EOF
12 echo "Edited by $i" >"\$1"
13 EOF
14 chmod +x e-$i.sh
15 done
16 unset vi
17 mv e-vi.sh vi
18 unset EDITOR VISUAL GIT_EDITOR
20 test_expect_success setup '
22 msg="Hand edited" &&
23 echo "$msg" >expect &&
24 git add vi &&
25 test_tick &&
26 git commit -m "$msg" &&
27 git show -s --pretty=oneline |
28 sed -e "s/^[0-9a-f]* //" >actual &&
29 diff actual expect
33 TERM=dumb
34 export TERM
35 test_expect_success 'dumb should error out when falling back on vi' '
37 if git commit --amend
38 then
39 echo "Oops?"
40 false
41 else
42 : happy
46 TERM=vt100
47 export TERM
48 for i in vi EDITOR VISUAL core_editor GIT_EDITOR
50 echo "Edited by $i" >expect
51 unset EDITOR VISUAL GIT_EDITOR
52 git config --unset-all core.editor
53 case "$i" in
54 core_editor)
55 git config core.editor ./e-core_editor.sh
57 [A-Z]*)
58 eval "$i=./e-$i.sh"
59 export $i
61 esac
62 test_expect_success "Using $i" '
63 git --exec-path=. commit --amend &&
64 git show -s --pretty=oneline |
65 sed -e "s/^[0-9a-f]* //" >actual &&
66 diff actual expect
68 done
70 unset EDITOR VISUAL GIT_EDITOR
71 git config --unset-all core.editor
72 for i in vi EDITOR VISUAL core_editor GIT_EDITOR
74 echo "Edited by $i" >expect
75 case "$i" in
76 core_editor)
77 git config core.editor ./e-core_editor.sh
79 [A-Z]*)
80 eval "$i=./e-$i.sh"
81 export $i
83 esac
84 test_expect_success "Using $i (override)" '
85 git --exec-path=. commit --amend &&
86 git show -s --pretty=oneline |
87 sed -e "s/^[0-9a-f]* //" >actual &&
88 diff actual expect
90 done
92 test_expect_success 'editor with a space' '
94 if echo "echo space > \"\$1\"" > "e space.sh"
95 then
96 chmod a+x "e space.sh" &&
97 GIT_EDITOR="./e\ space.sh" git commit --amend &&
98 test space = "$(git show -s --pretty=format:%s)"
99 else
100 say "Skipping; FS does not support spaces in filenames"
105 unset GIT_EDITOR
106 test_expect_success 'core.editor with a space' '
108 if test -f "e space.sh"
109 then
110 git config core.editor \"./e\ space.sh\" &&
111 git commit --amend &&
112 test space = "$(git show -s --pretty=format:%s)"
113 else
114 say "Skipping; FS does not support spaces in filenames"
119 TERM="$OLD_TERM"
121 test_done