exit 0
EOF
chmod +x fake-editor
+
+## Not using test_set_editor here so we can easily ensure the editor variable
+## is only set for the editor tests
FAKE_EDITOR="$(pwd)/fake-editor"
export FAKE_EDITOR
HOOKDIR="$(git rev-parse --git-dir)/hooks"
HOOK="$HOOKDIR/prepare-commit-msg"
mkdir -p "$HOOKDIR"
-cat > "$HOOK" <<'EOF'
-#!/bin/sh
+echo "#!$SHELL_PATH" > "$HOOK"
+cat >> "$HOOK" <<'EOF'
+
if test "$2" = commit; then
source=$(git-rev-parse "$3")
else
echo "more" >> file &&
git add file &&
- GIT_EDITOR="$FAKE_EDITOR" git commit -e -m "more more" &&
+ GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit -e -m "more more" &&
test "`git log -1 --pretty=format:%s`" = message
'
echo "more" >> file &&
git add file &&
- (echo more more | GIT_EDITOR="$FAKE_EDITOR" git commit -e -F -) &&
+ (echo more more | GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit -e -F -) &&
test "`git log -1 --pretty=format:%s`" = message
'
echo "more more" >> file &&
git add file &&
- GIT_EDITOR="$FAKE_EDITOR" git commit &&
+ GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit &&
test "`git log -1 --pretty=format:%s`" = default
'
head=`git rev-parse HEAD` &&
echo "more" >> file &&
git add file &&
- GIT_EDITOR="$FAKE_EDITOR" git commit --amend &&
+ GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit --amend &&
test "`git log -1 --pretty=format:%s`" = "$head"
'
head=`git rev-parse HEAD` &&
echo "more" >> file &&
git add file &&
- GIT_EDITOR="$FAKE_EDITOR" git commit -c $head &&
+ GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit -c $head &&
test "`git log -1 --pretty=format:%s`" = "$head"
'
head=`git rev-parse HEAD` &&
echo "more" >> file &&
git add file &&
- ! GIT_EDITOR="$FAKE_EDITOR" git commit -c $head
+ ! GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit -c $head
'
head=`git rev-parse HEAD` &&
echo "more" >> file &&
git add file &&
- ! GIT_EDITOR="$FAKE_EDITOR" git commit --no-verify -c $head
+ ! GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit --no-verify -c $head
'