CLANG-FORMAT-DIFF.PY(1)

πŸ“¦
version 21.1.8 Β· 3 versions
, in ubuntu stonking

πŸ’– NAME πŸ’–

okay bestie, listen up β€” this is the manual page for clang-format-diff.py version 21. that's it. that's the whole name. slay. ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

so like, the way this works is: it reads input from a unified diff and reformats all the changed lines. it's giving "glow-up but only for the lines your patch touched." πŸ’… super useful when you wanna reformat exactly the lines a specific patch messed with, and literally nothing else.

here's the usage situation, no cap:

clang-format-diff.py [-h] [-i] [-p NUM] [-regex PATTERN]
[-iregex PATTERN] [-sort-includes] [-v]
       [-style STYLE] [-fallback-style FALLBACK_STYLE] [-binary BINARY]

and here are the example usages for all my git/svn besties out there:

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 so this part is important, don't skip it: the filename contained in the diff is used unmodified to determine the source file to update. so if you're calling this script directly, you gotta be careful and make sure the path in the diff is correct relative to the current working directory. fr fr, do not sleep on this one. 😭

✨ options: ✨

  • -h, --help β€” shows this help message and then dips (exits). iconic behavior honestly 🫢
  • -i β€” applies the edits straight to the files instead of just showing you a diff. it's giving "we're actually doing this, not just talking about it." πŸ”₯
  • -p NUM β€” strips the smallest prefix that contains P slashes. buh-bye prefix πŸ‘‹
  • -regex PATTERN β€” your own custom pattern for picking which file paths get reformatted. case sensitive, and it overrides -iregex. it said "i'm the main character." πŸ‘‘
  • -iregex PATTERN β€” same deal, custom pattern for selecting file paths to reformat, but case insensitive. and heads up: it gets overridden by -regex. sorry babe, second place. πŸ™ˆ
  • -sort-includes β€” lets clang-format sort the include blocks. let it cook. πŸ“
  • -v, --verbose β€” be more verbose. just a lil heads up tho: it's ineffective without -i. so don't bother being chatty if you're not even applying edits, bestie πŸ’€
  • -style STYLE β€” the formatting style you wanna 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 case clang-format is invoked with -style=file, but can't find the .clang-format file to use. it's the backup bestie that shows up when the original cancels. 🧚
  • -binary BINARY β€” the location of the binary to use for clang-format. tell it where your little guy lives πŸ’œ

and that's the whole vibe check! this page is from clang-format-diff.py version 21, dated September 2026. periodt. πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈπŸ’…


πŸ“¦ where this page comes from