summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2024-12-13 16:33:37 +0100
committerJunio C Hamano <gitster@pobox.com>2024-12-13 16:33:37 +0100
commit5cbe030c866220cc85191cc25e99459d45d9a6ee (patch)
tree6f61f0e736787ed75ec4c9ec34654799940a963c
parentMerge branch 'jt/bundle-fsck' (diff)
parentCodingGuidelines: a handful of error message guidelines (diff)
downloadgit-5cbe030c866220cc85191cc25e99459d45d9a6ee.tar.xz
git-5cbe030c866220cc85191cc25e99459d45d9a6ee.zip
Merge branch 'jc/doc-error-message-guidelines'
Developer documentation update. * jc/doc-error-message-guidelines: CodingGuidelines: a handful of error message guidelines
-rw-r--r--Documentation/CodingGuidelines20
1 files changed, 17 insertions, 3 deletions
diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
index 87904791cb..1dc9a5e351 100644
--- a/Documentation/CodingGuidelines
+++ b/Documentation/CodingGuidelines
@@ -703,16 +703,30 @@ 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 from
+ porcelain commands should be marked for translation, e.g.
+ `die(_("bad revision %s"), revision)`.
+
+ - Error messages from the plumbing commands are sometimes meant for
+ machine consumption and should not be marked for translation,
+ e.g., `die("bad revision %s", revision)`.
+
+ - BUG("message") are for communicating the specific error to developers,
+ thus should not be translated.
Externally Visible Names