From c65dc351f0ae184f69cbc0b6555ff19aacb70e01 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 30 Mar 2012 11:04:08 -0700 Subject: t7501: test the right kind of breakage These tests try to run "git commit" with various "forbidden" combinations of options and expect the command to fail, but they do so without having any change added to the index. We wouldn't be able to catch breakages that would allow these combinations by mistake with them because the command will fail with "nothing to commit" anyway. Make sure we have something added to the index before running the command. Signed-off-by: Junio C Hamano diff --git a/t/t7501-commit.sh b/t/t7501-commit.sh index 8bb3833..45446b1 100755 --- a/t/t7501-commit.sh +++ b/t/t7501-commit.sh @@ -30,10 +30,12 @@ test_expect_success 'setup: initial commit' ' ' test_expect_success '-m and -F do not mix' ' + git checkout HEAD file && echo >>file && git add file && test_must_fail git commit -m foo -m bar -F file ' test_expect_success '-m and -C do not mix' ' + git checkout HEAD file && echo >>file && git add file && test_must_fail git commit -C HEAD -m illegal ' -- cgit v0.10.2-6-g49f6 From 010c7dbcbe2e55c1dcc85f23fbe55be6d7e931f0 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 30 Mar 2012 11:30:59 -0700 Subject: commit: do not trigger bogus "has templated message edited" check When "-t template" and "-F msg" options are both given (or worse yet, there is "commit.template" configuration but a message is given in some other way), the documentation says that template is ignored. However, the "has the user edited the message?" check still used the contents of the template file as the basis of the emptyness check. Signed-off-by: Junio C Hamano diff --git a/builtin/commit.c b/builtin/commit.c index eba1377..7141766 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -1049,6 +1049,8 @@ static int parse_and_validate_options(int argc, const char *argv[], die(_("Only one of -c/-C/-F/--fixup can be used.")); if (message.len && f > 0) die((_("Option -m cannot be combined with -c/-C/-F/--fixup."))); + if (f || message.len) + template_file = NULL; if (edit_message) use_message = edit_message; if (amend && !use_message && !fixup_message) diff --git a/t/t7501-commit.sh b/t/t7501-commit.sh index 45446b1..e59cc4e 100755 --- a/t/t7501-commit.sh +++ b/t/t7501-commit.sh @@ -81,7 +81,13 @@ test_expect_success 'empty commit message' ' test_must_fail git commit -F msg -a ' +test_expect_success 'template "emptyness" check does not kick in with -F' ' + git checkout HEAD file && echo >>file && git add file && + git commit -t file -F file +' + test_expect_success 'setup: commit message from file' ' + git checkout HEAD file && echo >>file && git add file && echo this is the commit message, coming from a file >msg && git commit -F msg -a ' -- cgit v0.10.2-6-g49f6 From b2eda9bdfbacdd3bb52da2ebcb468415cf153940 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 30 Mar 2012 12:14:33 -0700 Subject: commit: rephrase the error when user did not touch templated log message When the user exited editor without editing the commit log template given by "git commit -t