CLANG-FORMAT-DIFF.PY(1)

πŸ“¦
version 16.0.6 Β· 2 versions
, in debian bookworm

✨ clang-format-diff.py ✨

okay bestie, buckle up πŸ’– this is the manual page for clang-format-diff.py β€” version 16, no cap. it's a User Command, it lives in section 1, and it's literally about to make your diffs cute.


🌸 DESCRIPTION 🌸

here's the usage, verbatim, don't @ me:

usage: 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 actually do? it reads input from a unified diff and reformats all the changed lines. that's it. that's the whole vibe. 🫢 it's highkey useful when you wanna reformat every single line that a specific patch touched and nothing else.

example usage for the git/svn girlies, copied exactly:

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 this part is important, pay attention: the filename contained in the diff is used unmodified to determine the source file to update. so if you're calling this script directly, be careful β€” make sure the path in the diff is correct relative to the current working directory. like, actually correct. fr fr. πŸ™ˆ

πŸŽ€ options: πŸŽ€

  • -h, --help β€” shows this help message and dips. classic. ✨
  • -i β€” applies the edits to the files instead of just displaying a diff. main character move πŸ’…
  • -p NUM β€” strips the smallest prefix containing P slashes. (yes, that's literally what the page says, we don't make the rules πŸ‘‘)
  • -regex PATTERN β€” a custom pattern that selects which file paths get reformatted. it's case sensitive, and it overrides -iregex. queen behavior.
  • -iregex PATTERN β€” a custom pattern that selects which file paths get reformatted, but case insensitive. it gets overridden by -regex, so know your place bestie 😭
  • -sort-includes β€” lets clang-format sort include blocks. organize that friend group 🌈
  • -v, --verbose β€” be more verbose. ngl though, it's ineffective without -i, so it's giving "talking but nobody's listening" πŸ’€
  • -style STYLE β€” the formatting style to apply. your options are 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. your emergency backup bestie 🫢
  • -binary BINARY β€” the location of the binary to use for clang-format. tell it where your fave lives πŸ¦‹

and that's the whole page, no notes πŸ’– this was clang-format-diff.py 16, dated October 2023, straight out of User Commands. go forth and format, you iconic legend πŸ‘‘βœ¨

πŸ“¦ where this page comes from