{"thread":{"id":"38939","subject":"[PATCH] commit: add -f to force creation when no changes or an empty message","startedAt":"2015-03-29T15:34:19Z","lastAt":"2015-03-29T15:34:19Z","messageCount":1,"participants":["Ivan Ukhov"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"258655","messageId":"E2201BDB-4441-4BD0-B0ED-2F39A2838A7F@gmail.com","threadId":"38939","inReplyTo":null,"subject":"[PATCH] commit: add -f to force creation when no changes or an empty message","fromName":"Ivan Ukhov","fromEmail":"ivan.ukhov@gmail.com","sentAt":"2015-03-29T15:34:19Z","receivedAt":"2015-03-29T15:34:19Z","isPatch":true,"sender":{"key":"ivan.ukhov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/57440?v=4"},"body":"An attempt to commit gets rejected if there are no changes staged or there is no\nmessage given. In such a case, the --allow-empty and --allow-empty-message flags\ncan be used to force the action. The standard approach to force an action,\nhowever, is the -f/--force flag, as used in other built-ins.\n\nSigned-off-by: Ivan Ukhov <ivan.ukhov@gmail.com>\n---\n builtin/commit.c | 7 ++++++-\n 1 file changed, 6 insertions(+), 1 deletion(-)\n\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex da79ac4..fb76aee 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -113,7 +113,7 @@ static char *fixup_message, *squash_message;\n static int all, also, interactive, patch_interactive, only, amend, signoff;\n static int edit_flag = -1; /* unspecified */\n static int quiet, verbose, no_verify, allow_empty, dry_run, renew_authorship;\n-static int no_post_rewrite, allow_empty_message;\n+static int no_post_rewrite, allow_empty_message, force;\n static char *untracked_files_arg, *force_date, *ignore_submodule_arg;\n static char *sign_commit;\n\n@@ -1614,6 +1614,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)\n \t\tOPT_BOOL(0, \"amend\", &amend, N_(\"amend previous commit\")),\n \t\tOPT_BOOL(0, \"no-post-rewrite\", &no_post_rewrite, N_(\"bypass post-rewrite hook\")),\n \t\t{ OPTION_STRING, 'u', \"untracked-files\", &untracked_files_arg, N_(\"mode\"), N_(\"show untracked files, optional modes: all, normal, no. (Default: all)\"), PARSE_OPT_OPTARG, NULL, (intptr_t)\"all\" },\n+\t\tOPT__FORCE(&force, N_(\"force creation when no changes or an empty message\")),\n \t\t/* end commit contents options */\n\n \t\tOPT_HIDDEN_BOOL(0, \"allow-empty\", &allow_empty,\n@@ -1653,6 +1654,10 @@ int cmd_commit(int argc, const char **argv, const char *prefix)\n \targc = parse_and_validate_options(argc, argv, builtin_commit_options,\n \t\t\t\t\t  builtin_commit_usage,\n \t\t\t\t\t  prefix, current_head, &s);\n+\n+\tallow_empty += force;\n+\tallow_empty_message += force;\n+\n \tif (dry_run)\n \t\treturn dry_run_commit(argc, argv, prefix, current_head, &s);\n \tindex_file = prepare_index(argc, argv, prefix, current_head, 0);\n--\n2.3.4\n"}]}