# [PATCH v2] Add line-wrapping guidelines to the coding style documentation

1 messages from 2007-11-14 to 2007-11-14. Participants: Wincent Colaiuta.
Thread: https://gitlist.dev/t/10866

## Wincent Colaiuta, 2007-11-14 11:32

Subject: [PATCH v2] Add line-wrapping guidelines to the coding style documentation
Message-ID: <1037166E-C1B1-43A9-9B12-5866632CADCC@wincent.com>
URL: https://gitlist.dev/e/1037166E-C1B1-43A9-9B12-5866632CADCC%40wincent.com
In-Reply-To: <A18FC90C-5874-445A-93CE-9E05D02C614F@wincent.com>

```
Help new contributors by providing some advice about line-wrapping; the
advice basically boils down to "use 80-characters minus some slop as a
rule of thumb", but also "use common sense", and "avoid gratuitous
rewrapping".

Signed-off-by: Wincent Colaiuta <win@wincent.com>
---

El 14/11/2007, a las 11:37, Junio C Hamano escribió:

> Wincent Colaiuta <win@wincent.com> writes:
>
>> A statistician could probably make some interesting comments about  
>> the
>> results, but the basic trend is that, while there are plenty of
>> examples of isolated long lines in the source tree (the longest is a
>> 287-character line in one of the perl scripts), the frequency starts
>> to drop off pretty rapidly once you pass 70 columns and start  
>> climbing
>> towards 80.
>
> Gaah.  287???

Actually, not true. The longest line in a perl script is 209 chars  
(217 columns if you expand the leading tab), in file git- 
cvsexportcommit.perl.

The 287-char line was actually in builtin-update-index.c; this and  
most of the other really huge lines are usage strings.

>> + - In the case of documentation, mixing excessively long and short
>> +   lines may make the AsciiDoc source harder to read, so try to
>> +   keep line lengths consistent.
>> +
>> + - When submitting patches use common sense to decide whether to
>> +   rewrap, avoiding gratuitous changes.
>
> Hmph.  The last item applies only to the documentation because
> it uses the word "rewrap", but otherwise applies equally well to
> the sources (re-indenting).  So probably "whether to rewrap or
> reindent" would be a good change there.

Updated patch follows.

Documentation/CodingGuidelines |   22 ++++++++++++++++++++++
1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/Documentation/CodingGuidelines b/Documentation/ 
CodingGuidelines
index 3b042db..3eecb64 100644
--- a/Documentation/CodingGuidelines
+++ b/Documentation/CodingGuidelines
@@ -110,3 +110,25 @@ 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).
+
+Line wrapping:
+
+ - While there are no official hard limits for line wrapping, we
+   generally try to keep shell scripts, C source files and AsciiDoc
+   documentation within the range of "80-characters minus some
+   slop".
+
+ - We assume that everyone has terminals that are at least 80
+   columns wide.
+
+ - In practice, we try to keep lines somewhat narrower than 80
+   columns to accommodate diff change marks [-+ ] and quoting ">> "
+   in emails.
+
+ - In the case of documentation, mixing excessively long and short
+   lines may make the AsciiDoc source harder to read, so try to
+   keep line lengths consistent.
+
+ - When submitting patches use common sense to decide whether to
+   rewrap (or reindent), avoiding gratuitous changes.
+
-- 
1.5.3.5

```
