CLANG-FORMAT-DIFF.PY(1)

πŸ“¦
version 20.1.8 Β· 4 versions
, in ubuntu stonking

πŸ’– NAME πŸ’–

clang-format-diff.py β€” it's the manual page for clang-format-diff.py 20, bestie, and it's literally gonna be your new fave ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so here's the whole vibe. The usage goes a lil something 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 this lil script do, you ask? Obsessed that you asked. It reads input from a unified diff and reformats all the changed lines. Basically it's the glow-up for every line that a specific patch touched. No cap, it's genuinely so useful. 🌸

Here's the 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 real talk, this part matters: the filename contained in the diff gets used unmodified to figure out which source file to update. So if you're calling this script directly, you need to be careful and make sure the path in the diff is correct relative to the current working directory. It's giving "trust me bro" energy and you should not. πŸ™ˆ

✨ options ✨

  • -h, --help β€” shows this help message and dips. iconic behavior honestly πŸ‘‘
  • -i β€” actually applies the edits to your files instead of just displaying a diff. main character move πŸ’…
  • -p NUM β€” strips the smallest prefix that contains P slashes
  • -regex PATTERN β€” your own custom pattern for picking which file paths to reformat (case sensitive, and it overrides -iregex) πŸ”₯
  • -iregex PATTERN β€” same deal, custom pattern for picking file paths to reformat, but case insensitive (and it gets overridden by -regex, so know your hierarchy bestie) 🫢
  • -sort-includes β€” lets clang-format sort the include blocks. organized queen 🌈
  • -v, --verbose β€” be more verbose, but lowkey it does nothing without -i 😭
  • -style STYLE β€” the formatting style to apply: LLVM, GNU, Google, Chromium, Microsoft, Mozilla, WebKit ⭐
  • -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 not find the .clang-format file to use. it's giving backup plan, we love to see it πŸŽ€
  • -binary BINARY β€” location of the binary to use for clang-format 🧚

and that's the whole page bestie!! this was clang-format-diff.py version 20, dated September 2026. go reformat something cute, ily, mwah πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from