git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] commit: don't use-editor when allow-empty-message

From
Antoine Pelisse <apelisse@gmail.com>
Date
May 27, 2013, 14:53 UTC
Message-ID
<CALWbr2zW7BKwkNd5gU8vyE8KvMkzUMf1zTOr5X0cxsO7_4KA=Q@mail.gmail.com>
In-Reply-To
<1369664419-16440-1-git-send-email-artagnon@gmail.com>

So now we have two fixes for the same issue, don't we ? You probably missed $gmane/225534.

On Mon, May 27, 2013 at 4:20 PM, Ramkumar Ramachandra <artagnon@gmail.com> wrote:

Show 55 quoted lines
> 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
>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous: Ramkumar RamachandraNext: Ramkumar Ramachandra
Message 6 of 7 in “Commit with an empty message broken since v1.8.2.1”
  1. Mislav MarohnićMay 25, 2013
  2. commit: don't start editor if empty message is given with -mRené Scharfe, May 25, 2013
  3. commit: don't use-editor when allow-empty-messageRamkumar Ramachandra, May 27, 2013
  4. Ramkumar RamachandraMay 27, 2013
  5. commit: don't use-editor when allow-empty-messageRamkumar Ramachandra, May 27, 2013
  6. Antoine PelisseMay 27, 2013
  7. Ramkumar RamachandraMay 27, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.