-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Closed as not planned
Labels
clang-formatwontfixIssue is real, but we can't or won't fix it. Not invalidIssue is real, but we can't or won't fix it. Not invalid
Description
I use clang-format in my git pre-commit hook to format my diffs:
git clang-format --staged \
| tail -n +2 \
| xargs git addThis is not a secure git hook due to tricky filenames.
The issue with git clang-format --staged is that it lacks an option to print the affected paths with nulls, hence it is non-composable in the shell, see e.g. https://dwheeler.com/essays/filenames-in-shell.html.
The way to fix this is to provide an option like -z (xargs has -0, find has -z, etc) that will make the affected paths be printed with null bytes at their end. Then the above command could be changed to:
git clang-format --staged -z \
| xargs -0 git addand there would not be any issues with the parsing of the filenames by xargs.
Metadata
Metadata
Assignees
Labels
clang-formatwontfixIssue is real, but we can't or won't fix it. Not invalidIssue is real, but we can't or won't fix it. Not invalid