CLANG-FORMAT-DIFF.PY(1)
β¨ clang-format-diff.py β¨
okay bestie, buckle up π this is the manual page for clang-format-diff.py β version 16, no cap. it's a User Command, it lives in section 1, and it's literally about to make your diffs cute.
πΈ DESCRIPTION πΈ
here's the usage, verbatim, don't @ me:
usage: clang-format-diff.py [-h] [-i] [-p NUM] [-regex PATTERN]
[-iregex PATTERN] [-sort-includes] [-v]
[-style STYLE] [-fallback-style FALLBACK_STYLE] [-binary BINARY]
so what does this lil script actually do? it reads input from a unified diff and reformats all the changed lines. that's it. that's the whole vibe. π«Ά it's highkey useful when you wanna reformat every single line that a specific patch touched and nothing else.
example usage for the git/svn girlies, copied exactly:
git diff -U0 --no-color --relative HEAD^ | clang-format-diff.py
-p1 -i svn diff --diff-cmd=diff -x-U0 | clang-format-diff.py -i
β οΈ okay this part is important, pay attention: the filename contained in the diff is used unmodified to determine the source file to update. so if you're calling this script directly, be careful β make sure the path in the diff is correct relative to the current working directory. like, actually correct. fr fr. π
π options: π
-h,--helpβ shows this help message and dips. classic. β¨-iβ applies the edits to the files instead of just displaying a diff. main character move π-p NUMβ strips the smallest prefix containingPslashes. (yes, that's literally what the page says, we don't make the rules π)-regex PATTERNβ a custom pattern that selects which file paths get reformatted. it's case sensitive, and it overrides-iregex. queen behavior.-iregex PATTERNβ a custom pattern that selects which file paths get reformatted, but case insensitive. it gets overridden by-regex, so know your place bestie π-sort-includesβ letsclang-formatsort include blocks. organize that friend group π-v,--verboseβ be more verbose. ngl though, it's ineffective without-i, so it's giving "talking but nobody's listening" π-style STYLEβ the formatting style to apply. your options areLLVM,GNU,Google,Chromium,Microsoft,Mozilla,WebKit. pick your fighter β-fallback-style FALLBACK_STYLEβ the name of the predefined style used as a fallback in caseclang-formatis invoked with-style=filebut can not find the.clang-formatfile to use. your emergency backup bestie π«Ά-binary BINARYβ the location of the binary to use forclang-format. tell it where your fave lives π¦
and that's the whole page, no notes π this was clang-format-diff.py 16, dated October 2023, straight out of User Commands. go forth and format, you iconic legend πβ¨
π¦ where this page comes from
- debian bookworm: clang-format-16 1:16.0.6-15~deb12u1 Β· APACHE-2-LLVM-EXCEPTIONS
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms