You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 <[email protected]>
0 commit comments