CLANG-FORMAT-DIFF.PY(1)
β¨ CLANG-FORMAT-DIFF.PY β¨
okay bestie, welcome to the clang-format-diff.py manual page π
this is the 18 edition, she's a User Command, and she is SO much cooler than her boring name suggests. buckle up π
πΈ NAME πΈ
clang-format-diff.py β manual page for clang-format-diff.py 18
π¦ DESCRIPTION π¦
here's the vibe, straight up:
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 like. this script reads input from a unified diff and reformats all the changed lines. that's it, that's the whole personality. and it's iconic because it means you can reformat literally just the lines that a specific patch touched β not the entire codebase, not the thousand-year-old code someone else wrote, just your little patch. main character energy, truly π
example usage for all my git/svn girlies:
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 important bestie, listen up: the filename inside the diff is used unmodified to figure out which source file to update. so if you're calling this script directly, please please PLEASE make sure the path in the diff is actually correct relative to your current working directory. no cap. π
β¨ options: β¨
-h,--helpβ show this help message and exit. the classic. the goat. π«Ά-iβ apply edits to files instead of displaying a diff. (this is the one that actually changes things, so, y'know, be normal about it.)-p NUMβ strip the smallest prefix containingPslashes. very demure, very mindful βοΈ-regex PATTERNβ custom pattern selecting file paths to reformat. it's case sensitive, and it overrides-iregex. she does not share the spotlight π-iregex PATTERNβ custom pattern selecting file paths to reformat, but case insensitive. and yeah, she gets overridden by-regex. sorry babe, it's giving second place π-sort-includesβ letclang-formatsort include blocks. obsessed. the includes finally get the organization they deserve π§-v,--verboseβ be more verbose. and yes, lowkey, it is ineffective without-i, so don't come crying to me when it does nothing π₯²-style STYLEβ formatting style to apply. your options are:LLVM,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=file, but can not find the.clang-formatfile to use. it's the safety net bestie, the emotional support style π-binary BINARYβ location of binary to use forclang-format. tell her where herclang-formatlives π
and that's the whole page, bestie!! this little icon is clang-format-diff.py 18, dated June 2025, and she ate, no crumbs. go forth and reformat only your own lines like the queen you are ππβ¨
π¦ where this page comes from
- debian trixie: clang-format-18 1:18.1.8-18+b1 Β· APACHE-2-LLVM-EXCEPTIONS
- ubuntu questing: clang-format-18 1:18.1.8-18ubuntu2
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms