CLANG-FORMAT-DIFF.PY(1)

πŸ“¦
version 19.1.7 Β· 5 versions
, in debian bookworm, debian trixie

πŸ’– NAME πŸ’–

clang-format-diff.py β€” bestie, this is the manual page for clang-format-diff.py 19, and she is that girl πŸ’…


✨ DESCRIPTION ✨

okay so the vibe here is, the usage goes a little 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 she <em>do</em>?? This script reads input from a unified diff and reformats all the changed lines. Which is lowkey the most useful thing ever, because it means you can reformat literally every line touched by one specific patch and not one single line more. no cap. 🫢

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 bestie, important: the filename inside the diff is used unmodified to figure out which 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, check it. 😭

🌸 options: 🌸

  • -h, --help β€” show this help message and exit. the classic. the icon. πŸ‘‘
  • -i β€” apply edits to files instead of displaying a diff. this is the "no, actually change it" button πŸ’…
  • -p NUM β€” strip the smallest prefix containing P slashes
  • -regex PATTERN β€” custom pattern selecting file paths to reformat (case sensitive, overrides -iregex)
  • -iregex PATTERN β€” custom pattern selecting file paths to reformat (case insensitive, overridden by -regex)
  • -sort-includes β€” let clang-format sort include blocks πŸ—‚οΈβœ¨
  • -v, --verbose β€” be more verbose, ineffective without -i (so like, she's yapping but nobody's listening unless -i is on, iykyk)
  • -style STYLE β€” formatting style to apply (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 not find the .clang-format file to use.
  • -binary BINARY β€” location of binary to use for clang-format πŸ“

and that's the whole page, bestie!! this was clang-format-diff.py 19, dated June 2025, from the User Commands corner of the manual πŸ’œ go forth and reformat only the lines you touched, main character energy only βœ¨πŸ¦‹πŸŽ€

πŸ“¦ where this page comes from