-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle quotes and colon in filenames #173
Comments
Hi, I have done some testing and the problem is triggered by the presence of quote characters ( At multiple places in the Transcrypt script we use a command like this to find encrypted files (tracked files to which the git -c core.quotePath=false ls-files | git -c core.quotePath=false check-attr --stdin filter | awk 'BEGIN { FS = ":" }; /crypt$/{ print $1 }' These commands try to avoid problems with special/unusual characters in filenames by disabling Git's
Running the above command on a repo containing files with quote characters produces output like this:
It is because the ismdou… file gets quoted and quote-escaped in this way that follow-up commands fail. Specifically for your reported issue, the pre-commit hook is failing because it's passing the quoted file path/name to a command Although the pre-commit hook is the culprit it this case, the same problem manifests for the ./transcrypt --show-raw=*
==> "ismdou - Know the identifiers of the table \"FOO\".py.secret" <==
fatal: path '"ismdou - Know the identifiers of the table \"FOO\".py.secret"' does not exist in 'HEAD' So I can tell what the problem is, but how to fix it is less clear. We need to do one of:
I have experimented with using the
The trick will be figuring out how to string together the commands to work with NUL-delimited outputs, especially given that the command sequence relies on adding – then removing – the suffix So far I've gotten as far as the following, which avoids the unwanted filename quoting using git ls-files -z | awk 'BEGIN { RS = "\0" }; { print $0 }' | git check-attr --stdin filter I suspect a proper fix will require replacing the single-line piped commands with a function instead that will iterate over unquoted filenames (thanks to the |
- Add `_list_encrypted_files()` function that returns get un-quoted filenames for encrypted files by using the `-z` option to Git's `ls-files` command, with follow-on special handling - Use this function instead of long piped commands previously used to list encrypted filenames, which failed if these names contained double-quote characters due to the insufficient work-around of unsetting the `core.quotePath` config option.
I've started working towards a fix for this in PR #174 In my manual testing the PR works for most situations, but tests are failing for a few use-cases that have been broken by my changes. |
The potential fix on branch |
Somewhere we don't escape filenames properly, ending up with errors like
The first fatal is due to double quotes in the filename. The rest are due to colon in the filename (not visible, but right after the path in the error message; filename is truncated in the error message).
PS: The worst of it is that the commit goes through, so you end up with a commit that should have encrypted files, but instead files are in plain text.
The text was updated successfully, but these errors were encountered: