# [PATCH] Document conding style

4 messages from 2008-02-27 to 2008-02-28. Participants: Martin Koegler, David Symonds, Johannes Schindelin, Jean-Luc Herren.
Thread: https://gitlist.dev/t/12340

## Martin Koegler, 2008-02-27 08:13

Subject: [PATCH] Document conding style
Message-ID: <12041000101604-git-send-email-mkoegler@auto.tuwien.ac.at>
URL: https://gitlist.dev/e/12041000101604-git-send-email-mkoegler%40auto.tuwien.ac.at

```
Signed-off-by: Martin Koegler <mkoegler@auto.tuwien.ac.at>
---
Documentation/CodingGuidelines |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
index 3b042db..e1b5d78 100644
--- a/Documentation/CodingGuidelines
+++ b/Documentation/CodingGuidelines
@@ -77,6 +77,30 @@ For C programs:
    of "else if" statements, it can make sense to add braces to
    single line blocks.
 
+ - Avoid trailing whitespaces
+
+ - Pointer to struct foo type is (struct foo *), not (struct foo*)
+
+ - One space each around comparison operator "=="
+
+ - One space around assignment operator "="
+
+ - One space after "if", "while", "switch" and friends before "("
+
+ - No space between function name and "("
+
+ - A function without parameter is "static void foo(void)", not
+   "static void foo()"
+
+ - Don't do any declaration after a statement.
+
+ - Multi-line comment is:
+
+        /*
+         * This is multi line comment
+         * and this is its second line.
+         */
+
  - Try to make your code understandable.  You may put comments
    in, but comments invariably tend to stale out when the code
    they were describing changes.  Often splitting a function
@@ -105,6 +129,9 @@ For C programs:
    changed and discussed.  Many git commands started out like
    that, and a few are still scripts.
 
+ - Consider checking your patches with checkpatch from the linux 
+   kernel. It helps you to spot trivial formating errors.
+
  - Avoid introducing a new dependency into git. This means you
    usually should stay away from scripting languages not already
    used in the git core command set (unless your command is clearly
-- 
1.5.4.3.ga3d8

```

## David Symonds, 2008-02-27 08:36

Subject: Re: [PATCH] Document conding style
Message-ID: <ee77f5c20802270036o7e792feqd110b7ea96a3b75c@mail.gmail.com>
URL: https://gitlist.dev/e/ee77f5c20802270036o7e792feqd110b7ea96a3b75c%40mail.gmail.com
In-Reply-To: <12041000101604-git-send-email-mkoegler@auto.tuwien.ac.at>

```
On Wed, Feb 27, 2008 at 7:13 PM, Martin Koegler
<mkoegler@auto.tuwien.ac.at> wrote:
>  + - Consider checking your patches with checkpatch from the linux
>  +   kernel. It helps you to spot trivial formating errors.
>  +

Consider checking your spelling, too?  ;-)


Dave.

```

## Johannes Schindelin, 2008-02-27 09:43

Subject: Re: [PATCH] Document conding style
Message-ID: <alpine.LSU.1.00.0802270941040.22527@racer.site>
URL: https://gitlist.dev/e/alpine.LSU.1.00.0802270941040.22527%40racer.site
In-Reply-To: <12041000101604-git-send-email-mkoegler@auto.tuwien.ac.at>

```
Hi,

[it is "coding", not "conding", and technically, it is already documented]

Alternatively, we could repeat these lines from the existing 
CodingGuidelines 3 times:

> As for more concrete guidelines, just imitate the existing code
> (this is a good guideline, no matter which project you are
> contributing to).

And maybe hint at "git diff --check" _before_ committing?

Ciao,
Dscho

```

## Jean-Luc Herren, 2008-02-28 13:07

Subject: Re: [PATCH] Document conding style
Message-ID: <47C6B200.1080707@gmx.ch>
URL: https://gitlist.dev/e/47C6B200.1080707%40gmx.ch
In-Reply-To: <12041000101604-git-send-email-mkoegler@auto.tuwien.ac.at>

```
Martin Koegler wrote:
> + - Avoid trailing whitespaces
> +

Maybe it's worth mentioning that the default pre-commit hook does
that for you (among other things); you just need to enable it.

jlh

```
