CLANG-FORMAT-DIFF.PY(1)

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

✨ NAME ✨

clang-format-diff.py β€” the manual page for clang-format-diff.py 22, bestie πŸ’–


🌸 DESCRIPTION 🌸

okay so, usage first, because it's giving long :

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 little icon actually do? It reads input from a unified diff and reformats all the changed lines. That's the whole vibe. It's lowkey perfect when you wanna reformat every single line touched by a specific patch. πŸŽ€

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
⚠️ real talk though: the filename inside the diff is used unmodified to figure out which source file to update. So if you're calling this script directly, bestie, please be careful and make sure the path in the diff is correct relative to the current working directory. no cap, that part matters. πŸ’…

πŸ¦‹ options: πŸ¦‹

  • -h, --help β€” shows this help message and dips out ✌️
  • -i β€” apply the edits to the files instead of just showing you a diff
  • -p NUM β€” strip the smallest prefix that contains P slashes
  • -regex PATTERN β€” a custom pattern for picking which file paths get reformatted (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
  • -sort-includes β€” lets clang-format sort include blocks πŸ—‚οΈ
  • -v, --verbose β€” be more verbose. lowkey useless without -i though πŸ™ˆ
  • -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 when clang-format is invoked with -style=file but can't find the .clang-format file to use
  • -binary BINARY β€” the location of the binary to use for clang-format

πŸ’œ and that's the whole page, periodt. this was clang-format-diff.py 22, dated September 2026 β€” clang-format-diff.py 22, September 2026, that's the one and only CLANG-FORMAT-DIFF.PY(1). slay, go format something 🫢✨

πŸ“¦ where this page comes from