summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f448e24)
raw | patch | inline | side by side (parent: f448e24)
author | Jeff King <peff@peff.net> | |
Thu, 31 Jul 2008 07:36:09 +0000 (03:36 -0400) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Thu, 31 Jul 2008 18:20:13 +0000 (11:20 -0700) |
We recently let the user know explicitly that an empty
commit message will abort the commit. However, this adds yet
another line to the template; let's rephrase and re-wrap so
that this fits back on two lines.
This patch also makes the "fatal: empty commit message?"
warning a bit less scary, since this is now a "feature"
instead of an error. However, we retain the non-zero exit
status to indicate to callers that nothing was committed.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
commit message will abort the commit. However, this adds yet
another line to the template; let's rephrase and re-wrap so
that this fits back on two lines.
This patch also makes the "fatal: empty commit message?"
warning a bit less scary, since this is now a "feature"
instead of an error. However, we retain the non-zero exit
status to indicate to callers that nothing was committed.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-commit.c | patch | blob | history | |
t/t7502-commit.sh | patch | blob | history |
diff --git a/builtin-commit.c b/builtin-commit.c
index f7c053a0106c2e42833d0d7c7255b7b636d09a93..b783e6eb46d2603d61d3260420c5dff48913d182 100644 (file)
--- a/builtin-commit.c
+++ b/builtin-commit.c
fprintf(fp,
"\n"
- "# Please enter the commit message for your changes.\n"
- "# To abort the commit, use an empty commit message.\n"
- "# (Comment lines starting with '#' will ");
+ "# Please enter the commit message for your changes.");
if (cleanup_mode == CLEANUP_ALL)
- fprintf(fp, "not be included)\n");
+ fprintf(fp,
+ " Lines starting\n"
+ "# with '#' will be ignored, and an empty"
+ " message aborts the commit.\n");
else /* CLEANUP_SPACE, that is. */
- fprintf(fp, "be kept.\n"
- "# You can remove them yourself if you want to)\n");
+ fprintf(fp,
+ " Lines starting\n"
+ "# with '#' will be kept; you may remove them"
+ " yourself if you want to.\n"
+ "# An empty message aborts the commit.\n");
if (only_include_assumed)
fprintf(fp, "# %s\n", only_include_assumed);
stripspace(&sb, cleanup_mode == CLEANUP_ALL);
if (sb.len < header_len || message_is_empty(&sb, header_len)) {
rollback_index_files();
- die("no commit message? aborting commit.");
+ fprintf(stderr, "Aborting commit due to empty commit message.\n");
+ exit(1);
}
strbuf_addch(&sb, '\0');
if (is_encoding_utf8(git_commit_encoding) && !is_utf8(sb.buf))
diff --git a/t/t7502-commit.sh b/t/t7502-commit.sh
index f1112639b698faca38b2c8fc743e422d14dc15f6..3eb9faedcf75c7b8a535b369e5a19107c6e81026 100755 (executable)
--- a/t/t7502-commit.sh
+++ b/t/t7502-commit.sh
echo "sample
-# Please enter the commit message for your changes.
-# To abort the commit, use an empty commit message.
-# (Comment lines starting with '#' will not be included)" >expect
+# Please enter the commit message for your changes. Lines starting
+# with '#' will be ignored, and an empty message aborts the commit." >expect
test_expect_success 'cleanup commit messages (strip,-F,-e)' '
echo >>negative &&
{ echo;echo sample;echo; } >text &&
git commit -e -F text -a &&
- head -n 5 .git/COMMIT_EDITMSG >actual &&
+ head -n 4 .git/COMMIT_EDITMSG >actual &&
test_cmp expect actual
'
echo >>negative &&
git commit -e -m "sample"
- head -n 8 .git/COMMIT_EDITMSG >actual &&
+ head -n 7 .git/COMMIT_EDITMSG >actual &&
test_cmp expect actual
'
# must fail because there is no change
test_must_fail git commit -e -m "sample"
) &&
- head -n 9 .git/COMMIT_EDITMSG | \
+ head -n 8 .git/COMMIT_EDITMSG | \
sed "s/^# Committer: .*/# Committer:/" >actual &&
test_cmp expect actual
'