]> git.ipfire.org Git - thirdparty/git.git/commitdiff
fast-import: document C-style escapes for paths
authorThalia Archibald <thalia@archibald.dev>
Sun, 14 Apr 2024 01:12:12 +0000 (01:12 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 15 Apr 2024 17:06:18 +0000 (10:06 -0700)
Simply saying “C-style” string quoting is imprecise, as only a subset of
C escapes are supported. Document the exact escapes.

Signed-off-by: Thalia Archibald <thalia@archibald.dev>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-fast-import.txt
t/t9300-fast-import.sh

index 1882758b8ae66f8ceba6fc8ba17ac3e616e519cd..c6082c3b49715972c17be4f8a84692a58150e462 100644 (file)
@@ -643,7 +643,11 @@ When a `<path>` starts with a double quote (`"`), it is a C-style quoted
 string, where the complete filename is enclosed in a pair of double
 quotes and escape sequences are used. Certain characters must be escaped
 by preceding them with a backslash: `LF` is written as `\n`, backslash
-as `\\`, and double quote as `\"`. All filenames can be represented as
+as `\\`, and double quote as `\"`. Some characters may optionally be
+written with escape sequences: `\a` for bell, `\b` for backspace, `\f`
+for form feed, `\n` for line feed, `\r` for carriage return, `\t` for
+horizontal tab, and `\v` for vertical tab. Any byte can be written with
+3-digit octal codes (e.g., `\033`). All filenames can be represented as
 quoted strings.
 
 A `<path>` must use UNIX-style directory separators (forward slash `/`)
index 13f98e6688bc9ad2df5017180e6acb334d321e3d..5cde8f8d01c27bbb34073873494e35a0b98b0274 100755 (executable)
@@ -3189,8 +3189,9 @@ test_path_eol_success () {
        '
 }
 
-test_path_eol_success 'quoted spaces'   '" hello world.c "' ' hello world.c '
-test_path_eol_success 'unquoted spaces' ' hello world.c '   ' hello world.c '
+test_path_eol_success 'quoted spaces'   '" hello world.c "'  ' hello world.c '
+test_path_eol_success 'unquoted spaces' ' hello world.c '    ' hello world.c '
+test_path_eol_success 'octal escapes'   '"\150\151\056\143"' 'hi.c'
 
 #
 # Valid paths before a space: filecopy (source) and filerename (source).
@@ -3256,8 +3257,9 @@ test_path_space_success () {
        '
 }
 
-test_path_space_success 'quoted spaces'      '" hello world.c "' ' hello world.c '
-test_path_space_success 'no unquoted spaces' 'hello_world.c'     'hello_world.c'
+test_path_space_success 'quoted spaces'      '" hello world.c "'  ' hello world.c '
+test_path_space_success 'no unquoted spaces' 'hello_world.c'      'hello_world.c'
+test_path_space_success 'octal escapes'      '"\150\151\056\143"' 'hi.c'
 
 #
 # Test a single commit change with an invalid path. Run it with all occurrences