Skip to content

Commit e6895c3

Browse files
Dragan Simicgitster
authored andcommitted
config.txt: describe handling of whitespace further
Make it more clear what the whitespace characters are in the context of git configuration files, and significantly improve the description of the leading and trailing whitespace handling, especially how it works out together with the presence of inline comments. Helped-by: Junio C Hamano <[email protected]> Helped-by: Eric Sunshine <[email protected]> Signed-off-by: Dragan Simic <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d71bc1b commit e6895c3

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

Documentation/config.txt

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ multivalued.
2222
Syntax
2323
~~~~~~
2424

25-
The syntax is fairly flexible and permissive; whitespaces are mostly
26-
ignored. The '#' and ';' characters begin comments to the end of line,
27-
blank lines are ignored.
25+
The syntax is fairly flexible and permissive. Whitespace characters,
26+
which in this context are the space character (SP) and the horizontal
27+
tabulation (HT), are mostly ignored. The '#' and ';' characters begin
28+
comments to the end of line. Blank lines are ignored.
2829

2930
The file consists of sections and variables. A section begins with
3031
the name of the section in square brackets and continues until the next
@@ -63,16 +64,17 @@ the variable is the boolean "true").
6364
The variable names are case-insensitive, allow only alphanumeric characters
6465
and `-`, and must start with an alphabetic character.
6566

66-
A line that defines a value can be continued to the next line by
67-
ending it with a `\`; the backslash and the end-of-line are
68-
stripped. Leading whitespaces after 'name =', the remainder of the
69-
line after the first comment character '#' or ';', and trailing
70-
whitespaces of the line are discarded unless they are enclosed in
71-
double quotes. Internal whitespaces within the value are retained
72-
verbatim.
73-
74-
Inside double quotes, double quote `"` and backslash `\` characters
75-
must be escaped: use `\"` for `"` and `\\` for `\`.
67+
Whitespace characters surrounding `name`, `=` and `value` are discarded.
68+
Internal whitespace characters within 'value' are retained verbatim.
69+
Comments starting with either `#` or `;` and extending to the end of line
70+
are discarded. A line that defines a value can be continued to the next
71+
line by ending it with a backslash (`\`); the backslash and the end-of-line
72+
characters are discarded.
73+
74+
If `value` needs to contain leading or trailing whitespace characters,
75+
it must be enclosed in double quotation marks (`"`). Inside double quotation
76+
marks, double quote (`"`) and backslash (`\`) characters must be escaped:
77+
use `\"` for `"` and `\\` for `\`.
7678

7779
The following escape sequences (beside `\"` and `\\`) are recognized:
7880
`\n` for newline character (NL), `\t` for horizontal tabulation (HT, TAB)

0 commit comments

Comments
 (0)