CLANG-FORMAT-DIFF.PY(1)

πŸ“¦
version 13.0.1 Β· 3 versions
, in ubuntu jammy

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

okay bestie, so we're looking at clang-format-diff.py β€” that's the manual page for clang-format-diff.py version 13, living in the User Commands corner of the manual. pull up a chair πŸŽ€


🌸 NAME 🌸

clang-format-diff.py β€” the manual page for clang-format-diff.py 13. that's it, that's the name, no notes πŸ’…


✨ DESCRIPTION ✨

so the usage line goes like this, no cap:

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

here's the tea πŸ“: this script reads input from a unified diff and reformats all the changed lines. it's lowkey perfect for when you want to reformat literally every line a specific patch touched. main character behaviour, honestly.

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 important heads-up: the filename inside the diff is used unmodified to figure out which source file to update. so if you're calling this script directly, be careful fr fr β€” make sure the path in the diff is actually correct relative to your current working directory. don't be sloppy, it's giving consequences 😭

🧚 options:

  • -h, --help β€” shows this help message and then dips. exit stage left. πŸ‘‹
  • -i β€” actually applies the edits to your files instead of just showing you a diff. it's the "do it, don't just talk about it" flag.
  • -p NUM β€” strips the smallest prefix that contains P slashes. bye bye path prefix πŸ¦‹
  • -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 this one is case insensitive. and heads up: it gets overridden by -regex. so -regex is the one holding the crown here πŸ’œ
  • -sort-includes β€” lets clang-format sort the include blocks. let it cook 🍳
  • -v, --verbose β€” be more verbose. lowkey useless without -i tho, just so you know πŸ’€
  • -style STYLE β€” the formatting style to apply. your options are LLVM, GNU, Google, Chromium, Microsoft, Mozilla, WebKit. pick your fighter ✨
  • -binary BINARY β€” the location of the binary to use for clang-format. point it at your fave 🫢

and that's the whole page bestie, you ate that πŸ’–

this was clang-format-diff.py version 13, and the page is dated July 2023 β€” consider this your little sign-off from the manpage girlies 🌸✨ slay, go reformat something, periodt πŸ’…

πŸ“¦ where this page comes from