@@ -7,62 +7,45 @@ test_description='GIT_EDITOR, core.editor, and stuff'
7
7
unset EDITOR VISUAL GIT_EDITOR
8
8
9
9
test_expect_success ' determine default editor' '
10
-
11
10
vi=$(TERM=vt100 git var GIT_EDITOR) &&
12
11
test -n "$vi"
13
-
14
12
'
15
13
16
- if ! expr " $vi " : ' [a-z]*$' > /dev/null
17
- then
18
- vi=
19
- fi
20
-
21
- for i in GIT_EDITOR core_editor EDITOR VISUAL $vi
22
- do
23
- cat > e-$i .sh << -EOF
24
- #!$SHELL_PATH
25
- echo "Edited by $i " >"\$ 1"
26
- EOF
27
- chmod +x e-$i .sh
28
- done
14
+ test_expect_success setup '
15
+ if ! expr "$vi" : "[a-z]*$" >/dev/null
16
+ then
17
+ vi=
18
+ fi &&
29
19
30
- if ! test -z " $vi "
31
- then
32
- mv e-$vi .sh $vi
33
- fi
20
+ for i in GIT_EDITOR core_editor EDITOR VISUAL $vi
21
+ do
22
+ write_script e-$i.sh <<-EOF || return 1
23
+ echo "Edited by $i" >"\$1"
24
+ EOF
25
+ done &&
34
26
35
- test_expect_success setup '
27
+ if ! test -z "$vi"
28
+ then
29
+ mv e-$vi.sh $vi
30
+ fi &&
36
31
37
32
msg="Hand-edited" &&
38
33
test_commit "$msg" &&
39
- echo "$msg" >expect &&
40
- git show -s --format=%s > actual &&
41
- test_cmp expect actual
42
-
34
+ test_commit_message HEAD -m "$msg"
43
35
'
44
36
45
37
TERM=dumb
46
38
export TERM
47
39
test_expect_success ' dumb should error out when falling back on vi' '
48
-
49
- if git commit --amend
50
- then
51
- echo "Oops?"
52
- false
53
- else
54
- : happy
55
- fi
40
+ test_must_fail git commit --amend
56
41
'
57
42
58
43
test_expect_success ' dumb should prefer EDITOR to VISUAL' '
59
-
60
44
EDITOR=./e-EDITOR.sh &&
61
45
VISUAL=./e-VISUAL.sh &&
62
46
export EDITOR VISUAL &&
63
47
git commit --amend &&
64
- test "$(git show -s --format=%s)" = "Edited by EDITOR"
65
-
48
+ test_commit_message HEAD -m "Edited by EDITOR"
66
49
'
67
50
68
51
TERM=vt100
83
66
esac
84
67
test_expect_success " Using $i " '
85
68
git --exec-path=. commit --amend &&
86
- git show -s --pretty=oneline |
87
- sed -e "s/^[0-9a-f]* //" >actual &&
88
- test_cmp expect actual
69
+ test_commit_message HEAD expect
89
70
'
90
71
done
91
72
105
86
esac
106
87
test_expect_success " Using $i (override)" '
107
88
git --exec-path=. commit --amend &&
108
- git show -s --pretty=oneline |
109
- sed -e "s/^[0-9a-f]* //" >actual &&
110
- test_cmp expect actual
89
+ test_commit_message HEAD expect
111
90
'
112
91
done
113
92
114
93
test_expect_success ' editor with a space' '
115
94
echo "echo space >\"\$1\"" >"e space.sh" &&
116
95
chmod a+x "e space.sh" &&
117
96
GIT_EDITOR="./e\ space.sh" git commit --amend &&
118
- test space = "$(git show -s --pretty=format:%s)"
119
-
97
+ test_commit_message HEAD -m space
120
98
'
121
99
122
100
unset GIT_EDITOR
123
101
test_expect_success ' core.editor with a space' '
124
-
125
102
git config core.editor \"./e\ space.sh\" &&
126
103
git commit --amend &&
127
- test space = "$(git show -s --pretty=format:%s)"
128
-
104
+ test_commit_message HEAD -m space
129
105
'
130
106
131
107
test_done
0 commit comments