summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-03-16 23:47:26 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-03-16 23:47:26 (GMT)
commitafb497d472c22ba12c5b3313b6fdad132025468e (patch)
tree5451adb8378dd949795e96fe898463a06aadcf90
parent43c1b6efb86bc68220d28c90b9f6f2d9e278d390 (diff)
parent2140b14064ffe6b12ba6818b2894d1461a943fb9 (diff)
downloadgit-afb497d472c22ba12c5b3313b6fdad132025468e.zip
git-afb497d472c22ba12c5b3313b6fdad132025468e.tar.gz
git-afb497d472c22ba12c5b3313b6fdad132025468e.tar.bz2
Merge branch 'jn/maint-commit-missing-template' into maint
* jn/maint-commit-missing-template: commit: error out for missing commit message template
-rw-r--r--builtin/commit.c2
-rwxr-xr-xt/t7500-commit.sh14
2 files changed, 12 insertions, 4 deletions
diff --git a/builtin/commit.c b/builtin/commit.c
index 355b2cb..d71e1e0 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -634,7 +634,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
if (strbuf_read_file(&sb, git_path("SQUASH_MSG"), 0) < 0)
die_errno("could not read SQUASH_MSG");
hook_arg1 = "squash";
- } else if (template_file && !stat(template_file, &statbuf)) {
+ } else if (template_file) {
if (strbuf_read_file(&sb, template_file, 0) < 0)
die_errno("could not read '%s'", template_file);
hook_arg1 = "template";
diff --git a/t/t7500-commit.sh b/t/t7500-commit.sh
index d551b77..5976f59 100755
--- a/t/t7500-commit.sh
+++ b/t/t7500-commit.sh
@@ -28,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.