diff options
Diffstat (limited to 't/t7500-commit.sh')
-rwxr-xr-x | t/t7500-commit.sh | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/t/t7500-commit.sh b/t/t7500-commit.sh index 162527c211..bcdf0847d0 100755 --- a/t/t7500-commit.sh +++ b/t/t7500-commit.sh @@ -10,7 +10,12 @@ Tests for selected commit options.' . ./test-lib.sh commit_msg_is () { - test "`git log --pretty=format:%s%b -1`" = "$1" + expect=commit_msg_is.expect + actual=commit_msg_is.actual + + printf "%s" "$(git log --pretty=format:%s%b -1)" >$expect && + printf "%s" "$1" >$actual && + test_cmp $expect $actual } # A sanity check to see if commit is working at all. @@ -23,13 +28,21 @@ test_expect_success 'a basic commit in an empty tree should succeed' ' test_expect_success 'nonexistent template file should return error' ' echo changes >> foo && git add foo && - test_must_fail git commit --template "$PWD"/notexist + ( + GIT_EDITOR="echo hello >\"\$1\"" && + export GIT_EDITOR && + test_must_fail git commit --template "$PWD"/notexist + ) ' test_expect_success 'nonexistent template file in config should return error' ' git config commit.template "$PWD"/notexist && - test_must_fail git commit && - git config --unset commit.template + test_when_finished "git config --unset commit.template" && + ( + GIT_EDITOR="echo hello >\"\$1\"" && + export GIT_EDITOR && + test_must_fail git commit + ) ' # From now on we'll use a template file that exists. @@ -59,7 +72,7 @@ test_expect_success 'adding comments to a template should not commit' ' ) ' -test_expect_success 'adding real content to a template should commit' ' +test_expect_success C_LOCALE_OUTPUT 'adding real content to a template should commit' ' ( test_set_editor "$TEST_DIRECTORY"/t7500/add-content && git commit --template "$TEMPLATE" @@ -67,7 +80,7 @@ test_expect_success 'adding real content to a template should commit' ' commit_msg_is "template linecommit message" ' -test_expect_success '-t option should be short for --template' ' +test_expect_success C_LOCALE_OUTPUT '-t option should be short for --template' ' echo "short template" > "$TEMPLATE" && echo "new content" >> foo && git add foo && @@ -78,7 +91,7 @@ test_expect_success '-t option should be short for --template' ' commit_msg_is "short templatecommit message" ' -test_expect_success 'config-specified template should commit' ' +test_expect_success C_LOCALE_OUTPUT 'config-specified template should commit' ' echo "new template" > "$TEMPLATE" && git config commit.template "$TEMPLATE" && echo "more content" >> foo && @@ -277,7 +290,7 @@ test_expect_success 'commit --squash works with -c for same commit' ' commit_msg_is "squash! edited commit" ' -test_expect_success 'commit --squash works with editor' ' +test_expect_success C_LOCALE_OUTPUT 'commit --squash works with editor' ' commit_for_rebase_autosquash_setup && test_set_editor "$TEST_DIRECTORY"/t7500/add-content && git commit --squash HEAD~1 && |