From: Ramkumar Ramachandra <artagnon@gmail.com>
To: "Mislav Marohnić" <mislav.marohnic@gmail.com>
Cc: Brandon Casey <drafnel@gmail.com>,
Jonathan Nieder <jrnieder@gmail.com>,
Git List <git@vger.kernel.org>
Subject: [PATCH v2] commit: don't use-editor when allow-empty-message
Date: Mon, 27 May 2013 19:50:19 +0530 [thread overview]
Message-ID: <1369664419-16440-1-git-send-email-artagnon@gmail.com> (raw)
In-Reply-To: <1369663431-2405-1-git-send-email-artagnon@gmail.com>
Commit a24a41e (git-commit: only append a newline to -m mesg if
necessary, 2013-02-18) introduced a regression: when
--allow-empty-message is used and an empty message is explicitly
specified with -m "", git commit still launches $EDITOR unnecessarily.
The commit (correctly) fixes opt_parse_m() to not fill in two newlines
into the message buffer unconditionally. The real problem is that
launching $EDITOR only depends on use_editor and whether message is
empty. Fix the problem by setting explicit_message in the codepath
where an explicit string is passed via -m, and then checking it before
launching $EDITOR.
Reported-by: Mislav Marohnić <mislav.marohnic@gmail.com>
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
Works?
builtin/commit.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/builtin/commit.c b/builtin/commit.c
index d2f30d9..7d72ba7 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -108,6 +108,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 explicit_message = 0;
static const char *only_include_assumed;
static struct strbuf message = STRBUF_INIT;
@@ -128,6 +129,7 @@ static int opt_parse_m(const struct option *opt, const char *arg, int unset)
strbuf_addch(buf, '\n');
strbuf_addstr(buf, arg);
strbuf_complete_line(buf);
+ explicit_message = 1;
}
return 0;
}
@@ -824,7 +826,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
git_path(commit_editmsg), hook_arg1, hook_arg2, NULL))
return 0;
- if (use_editor) {
+ if (use_editor && !explicit_message) {
char index[PATH_MAX];
const char *env[2] = { NULL };
env[0] = index;
--
1.8.3.1.g33669de.dirty
next prev parent reply other threads:[~2013-05-27 14:18 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-25 19:12 Commit with an empty message broken since v1.8.2.1 Mislav Marohnić
2013-05-25 21:43 ` [PATCH] commit: don't start editor if empty message is given with -m René Scharfe
2013-05-27 14:03 ` [PATCH] commit: don't use-editor when allow-empty-message Ramkumar Ramachandra
2013-05-27 14:07 ` Ramkumar Ramachandra
2013-05-27 14:20 ` Ramkumar Ramachandra [this message]
2013-05-27 14:53 ` [PATCH v2] " Antoine Pelisse
2013-05-27 17:57 ` Ramkumar Ramachandra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1369664419-16440-1-git-send-email-artagnon@gmail.com \
--to=artagnon@gmail.com \
--cc=drafnel@gmail.com \
--cc=git@vger.kernel.org \
--cc=jrnieder@gmail.com \
--cc=mislav.marohnic@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).