Skip to content

Commit 2291595

Browse files
thaliaarchigitster
authored andcommitted
fast-import: improve documentation for path quoting
It describes what characters cannot be in an unquoted path, but not their semantics. Reframe it as a definition of unquoted paths. From the perspective of the parser, whether it starts with `"` is what defines whether it will parse it as quoted or unquoted. The restrictions on characters in unquoted paths (with starting-", LF, and spaces) are explained in the quoted paragraph. Move it to the unquoted paragraph and reword. The restriction that the source paths of filecopy and filerename cannot contain SP is only stated in their respective sections. Restate it in the <path> section. Signed-off-by: Thalia Archibald <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 212ab23 commit 2291595

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

Documentation/git-fast-import.txt

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -630,18 +630,24 @@ in octal. Git only supports the following modes:
630630
In both formats `<path>` is the complete path of the file to be added
631631
(if not already existing) or modified (if already existing).
632632

633-
A `<path>` string must use UNIX-style directory separators (forward
634-
slash `/`), may contain any byte other than `LF`, and must not
635-
start with double quote (`"`).
636-
637-
A path can use C-style string quoting; this is accepted in all cases
638-
and mandatory if the filename starts with double quote or contains
639-
`LF`. In C-style quoting, the complete name should be surrounded with
640-
double quotes, and any `LF`, backslash, or double quote characters
641-
must be escaped by preceding them with a backslash (e.g.,
642-
`"path/with\n, \\ and \" in it"`).
643-
644-
The value of `<path>` must be in canonical form. That is it must not:
633+
A `<path>` can be written as unquoted bytes or a C-style quoted string.
634+
635+
When a `<path>` does not start with a double quote (`"`), it is an
636+
unquoted string and is parsed as literal bytes without any escape
637+
sequences. However, if the filename contains `LF` or starts with double
638+
quote, it cannot be represented as an unquoted string and must be
639+
quoted. Additionally, the source `<path>` in `filecopy` or `filerename`
640+
must be quoted if it contains SP.
641+
642+
When a `<path>` starts with a double quote (`"`), it is a C-style quoted
643+
string, where the complete filename is enclosed in a pair of double
644+
quotes and escape sequences are used. Certain characters must be escaped
645+
by preceding them with a backslash: `LF` is written as `\n`, backslash
646+
as `\\`, and double quote as `\"`. All filenames can be represented as
647+
quoted strings.
648+
649+
A `<path>` must use UNIX-style directory separators (forward slash `/`)
650+
and its value must be in canonical form. That is it must not:
645651

646652
* contain an empty directory component (e.g. `foo//bar` is invalid),
647653
* end with a directory separator (e.g. `foo/` is invalid),

0 commit comments

Comments
 (0)