X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=t%2Ft7504-commit-msg-hook.sh;h=1f53ea8090355c9a351da1983388e1a49fd88ae3;hb=7325283987430f94712713313c5089e5143f2e17;hp=eff36aaee32200075f815de43af781cb115ea38e;hpb=6abf189506712a0e3c5ea796d136177b8f24ca22;p=git.git diff --git a/t/t7504-commit-msg-hook.sh b/t/t7504-commit-msg-hook.sh index eff36aaee..1f53ea809 100755 --- a/t/t7504-commit-msg-hook.sh +++ b/t/t7504-commit-msg-hook.sh @@ -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,12 +131,12 @@ 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 ' chmod -x "$HOOK" -test_expect_success 'with non-executable hook' ' +test_expect_success POSIXPERM 'with non-executable hook' ' echo "content" >> file && git add file && @@ -141,16 +144,16 @@ test_expect_success 'with non-executable hook' ' ' -test_expect_success 'with non-executable hook (editor)' ' +test_expect_success POSIXPERM '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" ' -test_expect_success '--no-verify with non-executable hook' ' +test_expect_success POSIXPERM '--no-verify with non-executable hook' ' echo "more content" >> file && git add file && @@ -158,12 +161,12 @@ test_expect_success '--no-verify with non-executable hook' ' ' -test_expect_success '--no-verify with non-executable hook (editor)' ' +test_expect_success POSIXPERM '--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" '