From ca1ba2010215acb305c7b5d9707e117b862067eb Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 6 Dec 2011 13:09:55 -0800 Subject: commit: honour --no-edit After making fixes to the contents to be committed, it is not unusual to update the current commit without rewording the message. Idioms to tell "commit --amend" that we do not need an editor have been: $ EDITOR=: git commit --amend $ git commit --amend -C HEAD but that was only because a more natural "--no-edit" option in $ git commit --amend --no-edit was not honoured. Signed-off-by: Junio C Hamano --- builtin/commit.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'builtin') diff --git a/builtin/commit.c b/builtin/commit.c index 8f2bebecf..48bea8f6e 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -81,7 +81,8 @@ static const char *template_file; static const char *author_message, *author_message_buffer; static char *edit_message, *use_message; static char *fixup_message, *squash_message; -static int all, edit_flag, also, interactive, patch_interactive, only, amend, signoff; +static int all, also, interactive, patch_interactive, only, amend, signoff; +static int edit_flag = -1; /* unspecified */ static int quiet, verbose, no_verify, allow_empty, dry_run, renew_authorship; static int no_post_rewrite, allow_empty_message; static char *untracked_files_arg, *force_date, *ignore_submodule_arg; @@ -141,7 +142,7 @@ static struct option builtin_commit_options[] = { OPT_BOOLEAN(0, "reset-author", &renew_authorship, "the commit is authored by me now (used with -C-c/--amend)"), OPT_BOOLEAN('s', "signoff", &signoff, "add Signed-off-by:"), OPT_FILENAME('t', "template", &template_file, "use specified template file"), - OPT_BOOLEAN('e', "edit", &edit_flag, "force edit of commit"), + OPT_BOOL('e', "edit", &edit_flag, "force edit of commit"), OPT_STRING(0, "cleanup", &cleanup_arg, "default", "how to strip spaces and #comments from message"), OPT_BOOLEAN(0, "status", &include_status, "include status in commit message template"), /* end commit message options */ @@ -1020,8 +1021,8 @@ static int parse_and_validate_options(int argc, const char *argv[], if (logfile || message.len || use_message || fixup_message) use_editor = 0; - if (edit_flag) - use_editor = 1; + if (0 <= edit_flag) + use_editor = edit_flag; if (!use_editor) setenv("GIT_EDITOR", ":", 1); -- cgit v1.2.1