CLANG-FORMAT-DIFF.PY(1)

πŸ“¦
version 17.0.6 Β· 4 versions
, in debian trixie, ubuntu questing

πŸ’– CLANG-FORMAT-DIFF.PY πŸ’–

okay bestie, gather round, because this one is literally the manual page for clang-format-diff.py version 17 and it's about to make your diffs cute. πŸŽ€


✨ NAME ✨

clang-format-diff.py β€” the manual page for clang-format-diff.py 17, no cap πŸ’…


🌸 DESCRIPTION 🌸

here's the vibe check, the usage goes like this:

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 it DO? it reads input from a unified diff and reformats all the changed lines. that's the whole personality. πŸ¦‹

and it's lowkey iconic because it means you can reformat exactly the lines that a specific patch touched β€” not the whole file, just the glow-up zone. ✨

example usage for the 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, do NOT skip this part: the filename contained in the diff is used unmodified to figure out which source file to update. so if you're calling this script directly, be careful bestie β€” make sure the path in the diff is correct relative to the current working directory. fr fr, this is the part that bites people. πŸ’€

πŸŽ€ options: πŸŽ€

  • -h, --help β€” shows this help message and dips. bye πŸ‘‹
  • -i β€” apply the edits to the files instead of just showing you a diff. this is the "actually do it" button. πŸ”₯
  • -p NUM β€” strip the smallest prefix containing P slashes.
  • -regex PATTERN β€” your own custom pattern for picking which file paths get reformatted. it's case sensitive, and it overrides -iregex.
  • -iregex PATTERN β€” same deal, custom pattern for picking file paths to reformat, but case insensitive. heads up though: it gets overridden by -regex.
  • -sort-includes β€” lets clang-format sort the include blocks. organize, slay. πŸ“š
  • -v, --verbose β€” be more verbose. ngl it's ineffective without -i, so don't bother unless you're also applying edits.
  • -style STYLE β€” the 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 case clang-format gets invoked with -style=file, but can't find the .clang-format file to use. the backup bestie. 🫢
  • -binary BINARY β€” where the binary to use for clang-format lives. path goes here. πŸ“

that's the whole page, you're officially fluent now. 🌈

and a lil sign-off from me to you: this was clang-format-diff.py 17, dated June 2025 β€” go format something pretty, bestie. πŸ’œπŸ§šπŸ’–

πŸ“¦ where this page comes from