Commit ccbc119
Apply suggestions from code review
The [Naming Files, Paths, and Namespaces](https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file) article does not state that control characters or non-printable characters are in general forbidden in filenames. Instead, it says that it is okay to
> Use any character in the current code page for a name, including Unicode characters and characters in the extended character set (128–255), except for the following:
and then lists various things that are not allowed, where the one that is relevant to control characters is:
> Characters whose integer representations are in the range from 1 through 31, except for alternate data streams where these characters are allowed. *[...]*
No mention is made of 127 (0x7F).
On Windows 10, I used PowerShell 7 for this experiment, which I believe would also work in PowerShell 6, but not Windows PowerShell, which doesn't support `` `u ``. First, as a baseline, I checked what happened if I tried to create a file whose name contained a low-numbered control character:
```text
C:\Users\ek\source\repos\unusual-filenames [main]> echo hello > a`u{8}b
Out-File: The filename, directory name, or volume label syntax is incorrect. : 'C:\Users\ek\source\repos\unusual-filenames\b'
C:\Users\ek\source\repos\unusual-filenames [main]> echo hello > a`u{08}b
Out-File: The filename, directory name, or volume label syntax is incorrect. : 'C:\Users\ek\source\repos\unusual-filenames\b'
```
I created a file whose name contained the `DEL` character, and even a file whose entire name is that character:
```text
C:\Users\ek\source\repos\unusual-filenames [main]> echo hello > a`u{7F}b
C:\Users\ek\source\repos\unusual-filenames [main +1 ~0 -0 !]> echo goodbye > `u{7F}
C:\Users\ek\source\repos\unusual-filenames [main +2 ~0 -0 !]> ls
Directory: C:\Users\ek\source\repos\unusual-filenames
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 5/20/2024 5:59 PM 9
-a--- 5/20/2024 5:59 PM 7 ab
```
Thus this appears to work fine on Windows, and it seems fine that Git permits it:
```text
C:\Users\ek\source\repos\unusual-filenames [main +2 ~0 -0 !]> git status
On branch main
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
"a\177b"
"\177"
nothing added to commit but untracked files present (use "git add" to track)
C:\Users\ek\source\repos\unusual-filenames [main +2 ~0 -0 !]> git add .
C:\Users\ek\source\repos\unusual-filenames [main +2 ~0 -0 ~]> git commit -m 'Initial commit'
[main (root-commit) 543ccd5] Initial commit
2 files changed, 2 insertions(+)
create mode 100644 "a\177b"
create mode 100644 "\177"
```
Thus, gitoxide should probably permit it too.
To be sure, I also tried creating such a file in Python 3.12 on the same system, by calling the `touch` method on a `Path` object. That worked, too.
Co-authored-by: Eliah Kagan <degeneracypressure@gmail.com>1 parent fcc3b69 commit ccbc119
2 files changed
+8
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
| 61 | + | |
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
| 77 | + | |
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
| 87 | + | |
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
104 | | - | |
| 104 | + | |
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
115 | | - | |
| 115 | + | |
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
| |||
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
153 | | - | |
| 153 | + | |
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
| |||
160 | 160 | | |
161 | 161 | | |
162 | 162 | | |
163 | | - | |
| 163 | + | |
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
160 | 160 | | |
161 | 161 | | |
162 | 162 | | |
163 | | - | |
| 163 | + | |
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
| |||
0 commit comments