checkout-index: fix --temp relative path mangling
[gitweb.git] / Documentation / CodingGuidelines
index ef67b53f721f28e5442c00273dec5f1582f555be..f4137c68ff80647644cc1f3d45d24457f505e2a0 100644 (file)
@@ -91,13 +91,13 @@ For shell scripts specifically (not exhaustive):
    E.g.: my_function () {
 
  - As to use of grep, stick to a subset of BRE (namely, no \{m,n\},
-   [::], [==], nor [..]) for portability.
+   [::], [==], or [..]) for portability.
 
    - We do not use \{m,n\};
 
    - We do not use -E;
 
-   - We do not use ? nor + (which are \{0,1\} and \{1,\}
+   - We do not use ? or + (which are \{0,1\} and \{1,\}
      respectively in BRE) but that goes without saying as these
      are ERE elements not BRE (note that \? and \+ are not even part
      of BRE -- making them accessible from BRE is a GNU extension).
@@ -126,6 +126,17 @@ For C programs:
    "char * string".  This makes it easier to understand code
    like "char *string, c;".
 
+ - Use whitespace around operators and keywords, but not inside
+   parentheses and not around functions. So:
+
+        while (condition)
+               func(bar + 1);
+
+   and not:
+
+        while( condition )
+               func (bar+1);
+
  - We avoid using braces unnecessarily.  I.e.
 
        if (bla) {
@@ -153,6 +164,16 @@ For C programs:
         * multi-line comment.
         */
 
+   Note however that a comment that explains a translatable string to
+   translators uses a convention of starting with a magic token
+   "TRANSLATORS: " immediately after the opening delimiter, even when
+   it spans multiple lines.  We do not add an asterisk at the beginning
+   of each line, either.  E.g.
+
+       /* TRANSLATORS: here is a comment that explains the string
+          to be translated, that follows immediately after it */
+       _("Here is a translatable string explained by the above.");
+
  - Double negation is often harder to understand than no negation
    at all.
 
@@ -243,6 +264,15 @@ For Python scripts:
    documentation for version 2.6 does not mention this prefix, it has
    been supported since version 2.6.0.
 
+Error Messages
+
+ - Do not end error messages with a full stop.
+
+ - Do not capitalize ("unable to open %s", not "Unable to open %s")
+
+ - Say what the error is first ("cannot open %s", not "%s: cannot open")
+
+
 Writing Documentation:
 
  Most (if not all) of the documentation pages are written in the