blob: e0ff7b4909f96387415bfe9f471bc94b2f11925f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
#!/bin/sh -e
. t/common.sh
interactive
printf '%s\n' > file \
"${HEAD} ours" \
head \
"${TAIL}" \
tail \
"${END} theirs"
for editor in EDITOR VISUAL CORE_EDITOR REDIFF_EDITOR GIT_EDITOR; do
printf '%s\n' > "${editor}" \
'#!/bin/sh -e' \
'printf "%s\\n" "$(basename -- "$0")" > "$1"'
chmod +x -- "$editor"
done
printf '%s\n' \
'#!/bin/sh -e' \
'printf "%s\\n" vi > "$1"' > ./vi
chmod +x ./vi
(
interactive_marker "${HEAD} ours"
interactive_side head
interactive_marker "${TAIL}"
interactive_side tail
interactive_marker "${END} theirs"
interactive_prompt 1 1
) > output.expected
run_editor_test () {
printf '%s\n' "$1" > file.expected
shift 1
unset GIT_EDITOR VISUAL EDITOR
git config --local --unset-all core.editor || :
git config --local --unset-all rediff.editor || :
while test ! $# = 0; do
if test "$1" = VI; then
export PATH=".:${PATH}"
elif test "$1" = CORE_EDITOR; then
git config core.editor ./CORE_EDITOR
elif test "$1" = REDIFF_EDITOR; then
git config rediff.editor ./REDIFF_EDITOR
else
eval "export $1=./$1"
fi
shift 1
done
printf '%s' e > input
normal --interactive file 8<input 9>output
diff -u -- output.expected output >&2
again_command=''
}
run_editor_test vi VI
run_editor_test EDITOR EDITOR
run_editor_test VISUAL EDITOR VISUAL
run_editor_test CORE_EDITOR EDITOR VISUAL CORE_EDITOR
run_editor_test REDIFF_EDITOR EDITOR VISUAL CORE_EDITOR REDIFF_EDITOR
run_editor_test GIT_EDITOR EDITOR VISUAL CORE_EDITOR REDIFF_EDITOR GIT_EDITOR
|