File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change 11
11
12
12
COMMIT_MSG_FILE=" $1 "
13
13
COMMIT_MSG_LINES=
14
+ HOOK_EDITOR=
14
15
SKIP_DISPLAY_WARNINGS=0
15
16
WARNINGS=
16
17
@@ -35,6 +36,18 @@ set_colors() {
35
36
fi
36
37
}
37
38
39
+ #
40
+ # Set the hook editor, using the same approach as git.
41
+ #
42
+
43
+ set_editor () {
44
+ HOOK_EDITOR=$GIT_EDITOR
45
+ test -z " ${HOOK_EDITOR} " && HOOK_EDITOR=$( git config --get core.editor)
46
+ test -z " ${HOOK_EDITOR} " && HOOK_EDITOR=$VISUAL
47
+ test -z " ${HOOK_EDITOR} " && HOOK_EDITOR=$EDITOR
48
+ test -z " ${HOOK_EDITOR} " && HOOK_EDITOR=' vi'
49
+ }
50
+
38
51
#
39
52
# Output prompt help information.
40
53
#
@@ -223,6 +236,8 @@ validate_commit_message() {
223
236
224
237
set_colors
225
238
239
+ set_editor
240
+
226
241
if tty > /dev/null 2>&1 ; then
227
242
TTY=$( tty)
228
243
else
@@ -248,7 +263,7 @@ while true; do
248
263
249
264
# Check if the reply is valid
250
265
case " $REPLY " in
251
- E* |e* ) $EDITOR " $COMMIT_MSG_FILE " < $TTY ; continue ;;
266
+ E* |e* ) $HOOK_EDITOR " $COMMIT_MSG_FILE " < $TTY ; continue ;;
252
267
Y* |y* ) exit 0 ;;
253
268
N* |n* ) exit 1 ;;
254
269
* ) SKIP_DISPLAY_WARNINGS=1; prompt_help; continue ;;
You can’t perform that action at this time.
0 commit comments