X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=Documentation%2FCodingGuidelines;h=b8bf618a30fd32a014e41e1ba9914f5e652bdefd;hb=6096d7598058d920485d206477f4383ba1a862cb;hp=994eb9159a2b0e8a10f4f9510165d420004203bf;hpb=f23ffbe890d36e277f02d4a84c2b52de3a4e3173;p=git.git diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines index 994eb9159..b8bf618a3 100644 --- a/Documentation/CodingGuidelines +++ b/Documentation/CodingGuidelines @@ -21,8 +21,13 @@ code. For git in general, three rough rules are: As for more concrete guidelines, just imitate the existing code (this is a good guideline, no matter which project you are -contributing to). But if you must have a list of rules, -here they are. +contributing to). It is always preferable to match the _local_ +convention. New code added to git suite is expected to match +the overall style of existing code. Modifications to existing +code is expected to match the style the surrounding code already +uses (even if it doesn't match the overall style of existing code). + +But if you must have a list of rules, here they are. For shell scripts specifically (not exhaustive): @@ -89,6 +94,8 @@ For C programs: of "else if" statements, it can make sense to add braces to single line blocks. + - We try to avoid assignments inside if(). + - 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 @@ -103,7 +110,7 @@ For C programs: - Use the API. No, really. We have a strbuf (variable length string), several arrays with the ALLOC_GROW() macro, a - path_list for sorted string lists, a hash map (mapping struct + string_list for sorted string lists, a hash map (mapping struct objects) named "struct decorate", amongst other things. - When you come up with an API, document it. @@ -122,3 +129,6 @@ For C programs: used in the git core command set (unless your command is clearly separate from it, such as an importer to convert random-scm-X repositories to git). + + - When we pass pair to functions, we should try to + pass them in that order.