From: Junio C Hamano Date: Fri, 4 Mar 2011 23:02:27 +0000 (-0800) Subject: Merge branch 'jn/maint-commit-missing-template' X-Git-Tag: v1.7.5-rc0~97 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/5cb3c9b7dff15f762d63df0b6f2d6b4bf82565e9?hp=1538f21bfb33dcaa65fe84b9823a8963bf1e6443 Merge branch 'jn/maint-commit-missing-template' * jn/maint-commit-missing-template: commit: error out for missing commit message template --- diff --git a/builtin/commit.c b/builtin/commit.c index 355b2cbca7..d71e1e0c9c 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 d551b77ce6..5976f598fc 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.