Code

Merge branch 'maint'
[git.git] / t / t7504-commit-msg-hook.sh
index eff36aaee32200075f815de43af781cb115ea38e..47680e6df41c2bc14f23514b010a8aefb3fedcd7 100755 (executable)
@@ -19,6 +19,9 @@ cp FAKE_MSG "$1"
 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
 
@@ -27,7 +30,7 @@ test_expect_success 'with no hook (editor)' '
        echo "more foo" >> file &&
        git add file &&
        echo "more foo" > FAKE_MSG &&
-       GIT_EDITOR="$FAKE_EDITOR" git commit
+       GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit
 
 '
 
@@ -44,7 +47,7 @@ test_expect_success '--no-verify with no hook (editor)' '
        echo "more bar" > file &&
        git add file &&
        echo "more bar" > FAKE_MSG &&
-       GIT_EDITOR="$FAKE_EDITOR" git commit --no-verify
+       GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit --no-verify
 
 '
 
@@ -71,7 +74,7 @@ test_expect_success 'with succeeding hook (editor)' '
        echo "more more" >> file &&
        git add file &&
        echo "more more" > FAKE_MSG &&
-       GIT_EDITOR="$FAKE_EDITOR" git commit
+       GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit
 
 '
 
@@ -88,7 +91,7 @@ test_expect_success '--no-verify with succeeding hook (editor)' '
        echo "even more more" >> file &&
        git add file &&
        echo "even more more" > FAKE_MSG &&
-       GIT_EDITOR="$FAKE_EDITOR" git commit --no-verify
+       GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit --no-verify
 
 '
 
@@ -102,7 +105,7 @@ test_expect_success 'with failing hook' '
 
        echo "another" >> file &&
        git add file &&
-       ! git commit -m "another"
+       test_must_fail git commit -m "another"
 
 '
 
@@ -111,7 +114,7 @@ test_expect_success 'with failing hook (editor)' '
        echo "more another" >> file &&
        git add file &&
        echo "more another" > FAKE_MSG &&
-       ! (GIT_EDITOR="$FAKE_EDITOR" git commit)
+       ! (GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit)
 
 '
 
@@ -128,7 +131,7 @@ test_expect_success '--no-verify with failing hook (editor)' '
        echo "more stuff" >> file &&
        git add file &&
        echo "more stuff" > FAKE_MSG &&
-       GIT_EDITOR="$FAKE_EDITOR" git commit --no-verify
+       GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit --no-verify
 
 '
 
@@ -146,7 +149,7 @@ test_expect_success 'with non-executable hook (editor)' '
        echo "content again" >> file &&
        git add file &&
        echo "content again" > FAKE_MSG &&
-       GIT_EDITOR="$FAKE_EDITOR" git commit -m "content again"
+       GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit -m "content again"
 
 '
 
@@ -163,7 +166,7 @@ test_expect_success '--no-verify with non-executable hook (editor)' '
        echo "even more content" >> file &&
        git add file &&
        echo "even more content" > FAKE_MSG &&
-       GIT_EDITOR="$FAKE_EDITOR" git commit --no-verify
+       GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit --no-verify
 
 '
 
@@ -193,7 +196,7 @@ test_expect_success 'hook edits commit message (editor)' '
        echo "additional content" >> file &&
        git add file &&
        echo "additional content" > FAKE_MSG &&
-       GIT_EDITOR="$FAKE_EDITOR" git commit &&
+       GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit &&
        commit_msg_is "new message"
 
 '
@@ -212,7 +215,7 @@ test_expect_success "hook doesn't edit commit message (editor)" '
        echo "more plus" >> file &&
        git add file &&
        echo "more plus" > FAKE_MSG &&
-       GIT_EDITOR="$FAKE_EDITOR" git commit --no-verify &&
+       GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit --no-verify &&
        commit_msg_is "more plus"
 
 '