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 <gitster@pobox.com>
Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Dragan Simic <dsimic@manjaro.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Dragan Simic
2024-03-21 07:06:08 +01:00
committed by Junio C Hamano
parent d71bc1b4a3
commit e6895c3f97

View File

@ -22,9 +22,10 @@ multivalued.
Syntax Syntax
~~~~~~ ~~~~~~
The syntax is fairly flexible and permissive; whitespaces are mostly The syntax is fairly flexible and permissive. Whitespace characters,
ignored. The '#' and ';' characters begin comments to the end of line, which in this context are the space character (SP) and the horizontal
blank lines are ignored. tabulation (HT), are mostly ignored. The '#' and ';' characters begin
comments to the end of line. Blank lines are ignored.
The file consists of sections and variables. A section begins with The file consists of sections and variables. A section begins with
the name of the section in square brackets and continues until the next the name of the section in square brackets and continues until the next
@ -63,16 +64,17 @@ the variable is the boolean "true").
The variable names are case-insensitive, allow only alphanumeric characters The variable names are case-insensitive, allow only alphanumeric characters
and `-`, and must start with an alphabetic character. and `-`, and must start with an alphabetic character.
A line that defines a value can be continued to the next line by Whitespace characters surrounding `name`, `=` and `value` are discarded.
ending it with a `\`; the backslash and the end-of-line are Internal whitespace characters within 'value' are retained verbatim.
stripped. Leading whitespaces after 'name =', the remainder of the Comments starting with either `#` or `;` and extending to the end of line
line after the first comment character '#' or ';', and trailing are discarded. A line that defines a value can be continued to the next
whitespaces of the line are discarded unless they are enclosed in line by ending it with a backslash (`\`); the backslash and the end-of-line
double quotes. Internal whitespaces within the value are retained characters are discarded.
verbatim.
Inside double quotes, double quote `"` and backslash `\` characters If `value` needs to contain leading or trailing whitespace characters,
must be escaped: use `\"` for `"` and `\\` for `\`. it must be enclosed in double quotation marks (`"`). Inside double quotation
marks, double quote (`"`) and backslash (`\`) characters must be escaped:
use `\"` for `"` and `\\` for `\`.
The following escape sequences (beside `\"` and `\\`) are recognized: The following escape sequences (beside `\"` and `\\`) are recognized:
`\n` for newline character (NL), `\t` for horizontal tabulation (HT, TAB) `\n` for newline character (NL), `\t` for horizontal tabulation (HT, TAB)