summaryrefslogtreecommitdiff
path: root/builtin/commit.c
diff options
context:
space:
mode:
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>2010-04-06 08:40:35 +0000
committerJunio C Hamano <gitster@pobox.com>2010-04-07 15:22:57 -0700
commitc9b5fde7593ac88b1c475bea51d21ba1a1d57d65 (patch)
tree51f4e4875024f41429762f2bf5fd6d8108e0ec9d /builtin/commit.c
parent537f6c7fb40257776a513128043112ea43b5cdb8 (diff)
downloadgit-c9b5fde7593ac88b1c475bea51d21ba1a1d57d65.tar.gz
Add option to git-commit to allow empty log messages
Change git-commit(1) to accept the --allow-empty-message option to allow a commit with an empty message. This is analogous to the existing --allow-empty option which allows a commit that records no changes. As these are mainly for interoperating with foreign SCM systems, and are not meant for normal use, ensure that "git commit -h" does not talk about them. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/commit.c')
-rw-r--r--builtin/commit.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/builtin/commit.c b/builtin/commit.c
index c5ab683d5b..821a49dac8 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -66,7 +66,7 @@ static char *edit_message, *use_message;
static char *author_name, *author_email, *author_date;
static int all, edit_flag, also, interactive, only, amend, signoff;
static int quiet, verbose, no_verify, allow_empty, dry_run, renew_authorship;
-static int no_post_rewrite;
+static int no_post_rewrite, allow_empty_message;
static char *untracked_files_arg, *force_date;
/*
* The default commit message cleanup mode will remove the lines
@@ -140,9 +140,15 @@ static struct option builtin_commit_options[] = {
OPT_BOOLEAN(0, "amend", &amend, "amend previous commit"),
OPT_BOOLEAN(0, "no-post-rewrite", &no_post_rewrite, "bypass post-rewrite hook"),
{ OPTION_STRING, 'u', "untracked-files", &untracked_files_arg, "mode", "show untracked files, optional modes: all, normal, no. (Default: all)", PARSE_OPT_OPTARG, NULL, (intptr_t)"all" },
- OPT_BOOLEAN(0, "allow-empty", &allow_empty, "ok to record an empty change"),
/* end commit contents options */
+ { OPTION_BOOLEAN, 0, "allow-empty", &allow_empty, NULL,
+ "ok to record an empty change",
+ PARSE_OPT_NOARG | PARSE_OPT_HIDDEN },
+ { OPTION_BOOLEAN, 0, "allow-empty-message", &allow_empty_message, NULL,
+ "ok to record a change with an empty message",
+ PARSE_OPT_NOARG | PARSE_OPT_HIDDEN },
+
OPT_END()
};
@@ -1293,7 +1299,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
if (cleanup_mode != CLEANUP_NONE)
stripspace(&sb, cleanup_mode == CLEANUP_ALL);
- if (message_is_empty(&sb)) {
+ if (message_is_empty(&sb) && !allow_empty_message) {
rollback_index_files();
fprintf(stderr, "Aborting commit due to empty commit message.\n");
exit(1);