diff options
author | René Scharfe <rene.scharfe@lsrfire.ath.cx> | 2013-05-25 23:43:34 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-05-28 14:33:01 -0700 |
commit | 25206778aac776fc6cc4887653fdae476c7a9b5a (patch) | |
tree | 8e5d2d5caebaa9cf53e30381b9736e340ea7e5b3 /builtin | |
parent | 92758dd2a2de94c90c0697ef0e8174c3543a47f9 (diff) | |
download | git-25206778aac776fc6cc4887653fdae476c7a9b5a.tar.gz git-25206778aac776fc6cc4887653fdae476c7a9b5a.tar.xz |
commit: don't start editor if empty message is given with -m
If an empty message is specified with the option -m of git commit then
the editor is started. That's unexpected and unnecessary. Instead of
using the length of the message string for checking if the user
specified one, directly remember if the option -m was given.
Reported-by: Mislav Marohnić <mislav.marohnic@gmail.com>
Signed-off-by: René Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/commit.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/builtin/commit.c b/builtin/commit.c index d21d07a1a..8e26a422a 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -107,7 +107,7 @@ static const char *cleanup_arg; static enum commit_whence whence; static int use_editor = 1, include_status = 1; -static int show_ignored_in_status; +static int show_ignored_in_status, have_option_m; static const char *only_include_assumed; static struct strbuf message = STRBUF_INIT; @@ -121,9 +121,11 @@ static enum { static int opt_parse_m(const struct option *opt, const char *arg, int unset) { struct strbuf *buf = opt->value; - if (unset) + if (unset) { + have_option_m = 0; strbuf_setlen(buf, 0); - else { + } else { + have_option_m = 1; if (buf->len) strbuf_addch(buf, '\n'); strbuf_addstr(buf, arg); @@ -975,7 +977,7 @@ static int parse_and_validate_options(int argc, const char *argv[], if (force_author && renew_authorship) die(_("Using both --reset-author and --author does not make sense")); - if (logfile || message.len || use_message || fixup_message) + if (logfile || have_option_m || use_message || fixup_message) use_editor = 0; if (0 <= edit_flag) use_editor = edit_flag; |