git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Rubén Justo" <rjusto@gmail.com>
Cc: Isoken June Ibizugbe <isokenjune@gmail.com>,
	 git@vger.kernel.org, christian.couder@gmail.com
Subject: Re: [PATCH v2] builtin/branch.c: adjust error messages to coding guidelines
Date: Fri, 20 Oct 2023 10:31:18 -0700	[thread overview]
Message-ID: <xmqqwmvhqjyx.fsf@gitster.g> (raw)
In-Reply-To: <331e1ab3-2e8c-497d-a05d-ef197d664188@gmail.com> ("Rubén Justo"'s message of "Thu, 19 Oct 2023 21:20:24 +0200")

Rubén Justo <rjusto@gmail.com> writes:

> On 19-oct-2023 09:40:51, Isoken June Ibizugbe wrote:
>
>> As per the CodingGuidelines document, it is recommended that a single-line
>> message provided to error messages such as die(), error() and warning(),
>
> This is confusing; some multi-line messages are fixed in this series.
>
>> should start with a lowercase letter and should not end with a period.
>> Also this patch fixes the tests broken by the changes.

"Also this patch fixes the tests broken by the changes" -> "Adjust
tests to match updated messages".

> Well done, describing why the tests are touched.

Nicely reviewed.  But it is unclear to me how we want to mention
updates to multi-line messages.  Do we have a good reference in the
guidelines we can copy?

The general desire is for a single-liner to look like so:

    error: the branch 'foo' is not fully merged

and an untold assumption is that we strongly prefer a single
sentence in a single-liner error message---a full-stop to separate
multiple sentences can be omitted for brevity.

But we have follow-up sentences that are not strictly "errors" in
some messages, e.g.,

>> -		error(_("The branch '%s' is not fully merged.\n"
>> +		error(_("the branch '%s' is not fully merged.\n"
>>  		      "If you are sure you want to delete it, "
>> -		      "run 'git branch -D %s'."), branchname, branchname);
>> +		      "run 'git branch -D %s'"), branchname, branchname);

In a modern codebase with facilities from advice.c, we would
probably do "a single-liner error message, optionally followed by a
hint message", i.e.

    error: the branch 'foo' is not fully merged
    hint: If you are sure you want to delete it,
    hint: run "git branch -D foo".

but this message apparently predates wide use of the advice_if() and
friends.

But rewriting this error message to use advice is probably outside
the scope of this patch.  But for completeness it would probably
look something like this (with necessary ADVICE_FOO defined):

	error(_("the branch '%s' is not fully merged"), branchname);
	advice_if_enabled(ADVICE_DELETE_BRANCH,
                	  _("If you are sure you want to delete it,"
			    "run 'git branch -D %s'."));

If I were doing this patch, I'd probably just add

	/* NEEDSWORK: turn the remainder ofthe message into advice */

in front of the existing error() call for this one without touching
the message itself, as it will have to be touched again when such a
change happens.

Thanks.

  reply	other threads:[~2023-10-20 17:31 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-18  5:12 [Outreachy][PATCH] branch.c: adjust error messages to coding guidelines Isoken June Ibizugbe
2023-10-18 18:19 ` Rubén Justo
2023-10-18 18:44   ` Junio C Hamano
2023-10-19  8:40   ` [PATCH v2] builtin/branch.c: " Isoken June Ibizugbe
2023-10-19 19:20     ` Rubén Justo
2023-10-20 17:31       ` Junio C Hamano [this message]
2023-10-20 17:59         ` Isoken Ibizugbe
2023-10-21 10:31         ` Rubén Justo
2023-10-21 10:27       ` Rubén Justo
2023-10-20  4:26     ` Isoken Ibizugbe
2023-10-20  9:41       ` Christian Couder
2023-10-20 17:10         ` Junio C Hamano

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqwmvhqjyx.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=isokenjune@gmail.com \
    --cc=rjusto@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.
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 NNTP newsgroup(s).