CLANG-FORMAT-DIFF.PY(1)
π NAME π
okay bestie, welcome to the manual for clang-format-diff.py β yes, the whole thing, section 1 of the manual, the CLANG-FORMAT-DIFF.PY(1) page. it's the script that reads a diff and reformats the changed lines. that's the vibe. that's the whole vibe. π¦
πΈ DESCRIPTION πΈ
so, usage, exactly as it is:
usage: clang-format-diff.py [-h] [-i] [-p NUM] [-regex PATTERN]
[-iregex PATTERN] [-sort-includes] [-v]
[-style STYLE] [-binary BINARY]
okay so what this script does: it reads input from a unified diff and reformats all the changed lines. that's it. that's the assignment. π it is useful to reformat all the lines touched by a specific patch β like, only the lines your patch actually touched, no stray edits anywhere else. periodt.
Example usage for git/svn users:
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 real talk, important caveat, no cap: 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 and make sure the path in the diff is correct relative to the current working directory. it does not do that for you. it trusts you. do not betray its trust. π
β¨ options: β¨
-h,--helpβ show this help message and exit. the classic. the icon. π«Ά-iβ apply edits to files instead of displaying a diff. this is the "actually do the thing" button, bestie. π-p NUMβ strip the smallest prefix containing P slashes. that's NUM slashes, mmkay? π-regex PATTERNβ custom pattern selecting file paths to reformat (case sensitive, and it overrides-iregex). the main character of the two. π-iregex PATTERNβ custom pattern selecting file paths to reformat (case insensitive, and it gets overridden by-regex). the soft launch version. π-sort-includesβ letclang-formatsort include blocks. yes queen, alphabetize those includes. β¨-v,--verboseβ be more verbose. lowkey ineffective without-ithough, so don't expect it to do anything if you're just printing a diff. π-style STYLEβ formatting style to apply. the options areLLVM,GNU,Google,Chromium,Microsoft,Mozilla,WebKit. pick your fighter. π₯-binary BINARYβ location of binary to use forclang-format. in case yourclang-formatis somewhere weird. we don't judge. π¦
and that's the whole page, bestie, you ate it. π this was clang-format-diff.py version 12, from February 2022 β go forth and reformat only the lines you actually touched. slay. π
β¨πΈπ«Ά
π¦ where this page comes from
- ubuntu jammy: clang-format-12 1:12.0.1-19ubuntu3 Β· APACHE-2-LLVM-EXCEPTIONS
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms