aboutsummaryrefslogtreecommitdiff
path: root/t/t7500-commit.sh
diff options
context:
space:
mode:
authorJonathan Nieder <jrnieder@gmail.com>2011-02-25 03:07:57 -0600
committerJunio C Hamano <gitster@pobox.com>2011-02-25 12:13:55 -0800
commit2140b14064ffe6b12ba6818b2894d1461a943fb9 (patch)
tree5686a2f43ce2edcfed88b706346733da8bbc4691 /t/t7500-commit.sh
parentda656f17d37fe96454645c08f21a24134f5aa900 (diff)
downloadgit-2140b14064ffe6b12ba6818b2894d1461a943fb9.tar.gz
git-2140b14064ffe6b12ba6818b2894d1461a943fb9.tar.xz
commit: error out for missing commit message template
When "git commit" was rewritten in C (v1.5.4-rc0~78^2~30, 2007-11-08), a subtle bug in --template was introduced. If the file named by a --template parameter is missing, previously git would error out with a message: Commit template file does not exist. but in the C version the --template parameter gets ignored and the default template is used. t7500 has two tests for this case which would have caught it, except that with the default $EDITOR, the commit message template is left unmodified, causing 'git commit' to error out and the test to succeed. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t7500-commit.sh')
-rwxr-xr-xt/t7500-commit.sh14
1 files changed, 11 insertions, 3 deletions
diff --git a/t/t7500-commit.sh b/t/t7500-commit.sh
index aa9c577e9..1590877c4 100755
--- a/t/t7500-commit.sh
+++ b/t/t7500-commit.sh
@@ -23,13 +23,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.