[clang] [clang-format] Add null-terminated path option (#123921) (PR #123926)
Owen Pan via cfe-commits
cfe-commits at lists.llvm.org
Sun Feb 9 21:36:59 PST 2025
owenca wrote:
> > It seems that `git-clang-format` was not designed for its output to be consumed by another utility as it prints everything to `stdout` instead of `stderr`. Adding an option like`--print0` (especially just for `--staged`) looks odd to me.
>
> No, the approach of printing to `stderr` for utilities is not accurate. I've heard of this before, even the claim that this is the original UNIX way, but it's not. I don't know the origin of this [cargo-culting](https://en.wikipedia.org/wiki/Cargo_cult) factoid but I assure you that it does not hold true. (The origin I suspect may be Microsoft with its Powershell, i.e. see [about_Output_Streams](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_output_streams?view=powershell-7.5))
Diagnostic output should go to stderr, but the informational output of git-clang-format is sent to stdout instead.
> There is a lot of value in `--null` since it allows `git clang-format` to be used in git hooks. Why would a Python script designed as a git subcommand not work well with git?
If you want to run `git add` in git-clang-format, we can add an option for that.
https://github.com/llvm/llvm-project/pull/123926
More information about the cfe-commits
mailing list