CLANG-FORMAT-DIFF.PY(1)

πŸ“¦ version 11.1.0, in ubuntu jammy

πŸ’– NAME

clang-format-diff.py β€” bestie, it's literally the manual page for clang-format-diff.py 11 πŸŽ€


✨ DESCRIPTION

okay so first things first, here's how you even call this thing:

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

So what does it do? This script reads input from a unified diff and reformats all the changed lines. πŸ¦‹ Translation: it only touches the lines your patch actually messed with. That's the whole slay β€” if you've got a specific patch and you want just those lines looking pretty, this is your girl.

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, no cap: 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, be so careful that the path in the diff is correct relative to the current working directory. It's giving "trust me bro" energy and you should NOT trust it blindly. πŸ’€

🫢 options:

  • -h, --help β€” shows this help message and then dips. exit. gone. ✨
  • -i β€” actually applies the edits to your files instead of just showing you a diff. it's giving commitment. πŸ’…
  • -p NUM β€” strips the smallest prefix containing P slashes. yes, the number matters, don't skip it.
  • -regex PATTERN β€” a custom pattern that picks which file paths get reformatted. case sensitive, and it overrides -iregex. main character energy, honestly.
  • -iregex PATTERN β€” same deal, custom pattern selecting file paths to reformat, but case insensitive. and it gets overridden by -regex, so know your place bestie 😭
  • -sort-includes β€” lets clang-format sort the include blocks. go off, alphabetize. 🌸
  • -v, --verbose β€” be more verbose. lowkey useless without -i though, fr fr.
  • -style STYLE β€” the formatting style to apply. your options are LLVM, GNU, Google, Chromium, Microsoft, Mozilla, WebKit. pick your aesthetic πŸ’œ
  • -binary BINARY β€” where the binary you wanna use for clang-format lives. path goes here.

and that's the whole page, babe 🧚 this was clang-format-diff.py 11, dated January 2022 β€” go forth and format, you're gonna ate πŸ’–β­

πŸ“¦ where this page comes from