From: Junio C Hamano <gitster@pobox.com>
To: "Kristoffer Haugsbakk" <kristofferhaugsbakk@fastmail.com>
Cc: "Josh Soref" <gitgitgadget@gmail.com>,
git@vger.kernel.org, "Eric Sunshine" <sunshine@sunshineco.com>,
"Elijah Newren" <newren@gmail.com>
Subject: Re* [PATCH v2] fast-import: disallow "." and ".." path components
Date: Wed, 27 Nov 2024 22:23:45 +0900 [thread overview]
Message-ID: <xmqq1pywvmhq.fsf_-_@gitster.g> (raw)
In-Reply-To: <79f6027b-123c-40a6-975b-1c6053b9391c@app.fastmail.com> (Kristoffer Haugsbakk's message of "Wed, 27 Nov 2024 09:28:03 +0100")
"Kristoffer Haugsbakk" <kristofferhaugsbakk@fastmail.com> writes:
>> + if (is_dot_or_dotdot(e->name->str_dat))
>> + die("path %s contains invalid component", p);
>
> Nit: single-quoting the path seems more common:
>
> $ git grep "\"path '%s'" ':!po/' | wc -l
> 17
> $ git grep "\"path %s" ':!po/' | wc -l
> 4
Ah, I missed that one. Thanks for catching.
We probably should write it down.
--- >8 ---
[PATCH] CodingGuidelines: a handful of error message guidelines
It is more efficient to have something in the coding guidelines
document to point at, when we want to review and comment on a new
message in the codebase to make sure it "fits" in the set of
existing messages.
Let's write down established best practice we are aware of.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
* I am writing what I think is the established practice from
memory; clarifications, corrections, and additions are all
welcome.
Documentation/CodingGuidelines | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git c/Documentation/CodingGuidelines w/Documentation/CodingGuidelines
index 87904791cb..0444391983 100644
--- c/Documentation/CodingGuidelines
+++ w/Documentation/CodingGuidelines
@@ -703,16 +703,22 @@ Program Output
Error Messages
- - Do not end error messages with a full stop.
+ - Do not end a single-sentence error message with a full stop.
- Do not capitalize the first word, only because it is the first word
- in the message ("unable to open %s", not "Unable to open %s"). But
+ in the message ("unable to open '%s'", not "Unable to open '%s'"). But
"SHA-3 not supported" is fine, because the reason the first word is
capitalized is not because it is at the beginning of the sentence,
but because the word would be spelled in capital letters even when
it appeared in the middle of the sentence.
- - Say what the error is first ("cannot open %s", not "%s: cannot open")
+ - Say what the error is first ("cannot open '%s'", not "%s: cannot open").
+
+ - Enclose the subject of an error inside a pair of single quotes,
+ e.g. `die(_("unable to open '%s'"), path)`.
+
+ - Unless there is a compelling reason not to, error messages should
+ be marked for `_("translation")`.
Externally Visible Names
next prev parent reply other threads:[~2024-11-27 13:23 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-25 17:58 [PATCH] fast-import: disallow "." and ".." path components Elijah Newren via GitGitGadget
2024-11-25 18:15 ` Eric Sunshine
2024-11-25 18:24 ` Elijah Newren
2024-11-25 19:00 ` [PATCH v2] " Elijah Newren via GitGitGadget
2024-11-26 6:57 ` Patrick Steinhardt
2024-11-27 14:24 ` Jeff King
2024-11-27 23:07 ` Junio C Hamano
2024-11-27 8:28 ` Kristoffer Haugsbakk
2024-11-27 13:23 ` Junio C Hamano [this message]
2024-11-27 19:41 ` Re* " Eric Sunshine
2024-11-28 0:36 ` [PATCH v2] CodingGuidelines: a handful of error message guidelines Junio C Hamano
2024-11-28 7:57 ` Eric Sunshine
2024-11-28 9:28 ` Junio C Hamano
2024-11-28 9:51 ` Eric Sunshine
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=xmqq1pywvmhq.fsf_-_@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=kristofferhaugsbakk@fastmail.com \
--cc=newren@gmail.com \
--cc=sunshine@sunshineco.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).