git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Kaartic Sivaraam <kaarticsivaraam91196@gmail.com>
Cc: git@vger.kernel.org, me@ikke.info
Subject: Re: [PATCH] commit & merge: modularize the empty message validator
Date: Tue, 11 Jul 2017 13:22:54 -0700	[thread overview]
Message-ID: <xmqq8tju3eqp.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20170711141254.7747-1-kaarticsivaraam91196@gmail.com> (Kaartic Sivaraam's message of "Tue, 11 Jul 2017 19:42:54 +0530")

Kaartic Sivaraam <kaarticsivaraam91196@gmail.com> writes:

> In the context of "git merge" the meaning of an "empty message"
> is one that contains no line of text. This is not in line with
> "git commit" where an "empty message" is one that contains only
> whitespaces and/or signed-off-by lines. This could cause surprises
> to users who are accustomed to the meaning of an "empty message"
> of "git commit".
>
> Prevent such surprises by ensuring the meaning of an empty 'merge
> message' to be in line with that of an empty 'commit message'. This
> is done by separating the empty message validator from 'commit' and
> making it stand-alone.
>
> Signed-off-by: Kaartic Sivaraam <kaarticsivaraam91196@gmail.com>
> ---
>  I have made an attempt to solve the issue by separating the concerned
>  function as I found no reason against it.
>
>  I've tried to name them with what felt appropriate and concise to me.
>  Let me know if it's alright.

I probably would have avoided a pair of new files just to house a
single function.  I anticipate that the last helper function in
commit.c at the top-level would become relevant to this topic, and
because of that, I would have added this function at the end of the
file if I were doing this patch.

> @@ -772,7 +773,7 @@ static void prepare_to_commit(struct commit_list *remoteheads)
>  	}
>  	read_merge_msg(&msg);
>  	strbuf_stripspace(&msg, 0 < option_edit);
> -	if (!msg.len)
> +	if (!msg.len || message_is_empty(&msg, 0))

I do not see much point in checking !msg.len here.  The function
immediately returns by hitting the termination condition of the
outermost loop and this is not a performance-critical codepath.

I think the "validation" done with the rest_is_empty() is somewhat
bogus.  Why should we reject a commit without a message and a
trailer block with only signed-off-by lines, while accepting a
commit without a message and a trailer block as long as the trailer
block has something equally meaningless by itself, like
"Helped-by:"?  I think we should inspect the proposed commit log
message taken from the editor, find its tail ignoring the trailing
comment using ignore_non_trailer, and further separate the result
into (<message>, <trailers>, <junk at the tail>) using the same
logic used by the interpret-trailers tool, and then complain when
<message> turns out to be empty, to be truly useful and consistent.

And for that eventual future, merging the logic used in commit and
merge might be a good first step.

Having said all that, I am not sure "Prevent such surprises" is a
problem that is realistic to begin with.  When a user sees the
editor buffer in "git merge", it is pre-populated with at least a
single line of message "Merge branch 'foo'", possibly followed by
the summary of the side branch being merged, so unless the user
deliberately removes everything and then add a sign-off line
(because we do not usually add one), there is no room for "such
surprises" in the first place.  It does not _hurt_ to diagnose such
a crazy case, but it feels a bit lower priority.

So from the point of "let's improve what merge does", this change
looks to me a borderline "Meh"; but to improve the "why sign-off is
so special and behave differently from helped-by when deciding if
there is any log?" situation, having a separate helper function that
is shared across multiple codepaths that accept edited result may be
a good idea.


  parent reply	other threads:[~2017-07-11 20:23 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-02 12:03 Why doesn't merge fail if message has only sign-off? Kaartic Sivaraam
2017-07-03 17:21 ` Junio C Hamano
2017-07-04 20:03   ` Kaartic Sivaraam
2017-07-06  3:31   ` [PATCH] merge-message: change meaning of "empty merge message" Kaartic Sivaraam
2017-07-06  4:46     ` Kevin Daudt
2017-07-06 12:20       ` Kaartic Sivaraam
2017-07-11 14:12       ` [PATCH] commit & merge: modularize the empty message validator Kaartic Sivaraam
2017-07-11 14:41         ` [PATCH/RFC] " Kaartic Sivaraam
2017-07-11 20:22         ` Junio C Hamano [this message]
2017-07-13 13:00           ` [PATCH] " Kaartic Sivaraam
2017-07-13 17:58             ` Junio C Hamano
2017-07-14 13:31               ` Kaartic Sivaraam
2017-07-17  9:08               ` Christian Brabandt
2017-07-17 17:16                 ` Junio C Hamano
2017-07-13 18:15           ` Kaartic Sivaraam
2017-07-13 19:23             ` Junio C Hamano
2017-07-14 17:49               ` Kaartic Sivaraam
2017-07-15  8:33                 ` Kaartic Sivaraam
2017-08-21 13:34                   ` [PATCH v2] branch: change the error messages to be more meaningful Kaartic Sivaraam
2017-08-21 13:52                     ` Kaartic Sivaraam
2017-08-21 14:05                   ` [PATCH v2/RFC] commit: change the meaning of an empty commit message Kaartic Sivaraam
2017-08-24 20:19                     ` Junio C Hamano
2017-08-31 13:36                       ` Kaartic Sivaraam
2017-10-02 17:20                         ` Kaartic Sivaraam

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=xmqq8tju3eqp.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=kaarticsivaraam91196@gmail.com \
    --cc=me@ikke.info \
    /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).