CLANG-FORMAT-DIFF.PY(1)

πŸ“¦
version 18.1.8 Β· 5 versions
, in debian trixie, ubuntu questing

✨ CLANG-FORMAT-DIFF.PY ✨

okay bestie, welcome to the clang-format-diff.py manual page πŸ’… this is the 18 edition, she's a User Command, and she is SO much cooler than her boring name suggests. buckle up πŸŽ€


🌸 NAME 🌸

clang-format-diff.py β€” manual page for clang-format-diff.py 18


πŸ¦‹ DESCRIPTION πŸ¦‹

here's the vibe, straight up:

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 like. this script reads input from a unified diff and reformats all the changed lines. that's it, that's the whole personality. and it's iconic because it means you can reformat literally just the lines that a specific patch touched β€” not the entire codebase, not the thousand-year-old code someone else wrote, just your little patch. main character energy, truly πŸ‘‘

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 bestie, listen 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, please please PLEASE make sure the path in the diff is actually correct relative to your current working directory. no cap. πŸ™ˆ

✨ options: ✨

  • -h, --help β€” show this help message and exit. the classic. the goat. 🫢
  • -i β€” apply edits to files instead of displaying a diff. (this is the one that actually changes things, so, y'know, be normal about it.)
  • -p NUM β€” strip the smallest prefix containing P slashes. very demure, very mindful βœ‚οΈ
  • -regex PATTERN β€” custom pattern selecting file paths to reformat. it's case sensitive, and it overrides -iregex. she does not share the spotlight πŸ’…
  • -iregex PATTERN β€” custom pattern selecting file paths to reformat, but case insensitive. and yeah, she gets overridden by -regex. sorry babe, it's giving second place 😭
  • -sort-includes β€” let clang-format sort include blocks. obsessed. the includes finally get the organization they deserve 🧚
  • -v, --verbose β€” be more verbose. and yes, lowkey, it is ineffective without -i, so don't come crying to me when it does nothing πŸ₯²
  • -style STYLE β€” 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. it's the safety net bestie, the emotional support style πŸŽ€
  • -binary BINARY β€” location of binary to use for clang-format. tell her where her clang-format lives 🏠

and that's the whole page, bestie!! this little icon is clang-format-diff.py 18, dated June 2025, and she ate, no crumbs. go forth and reformat only your own lines like the queen you are πŸ‘‘πŸ’–βœ¨

πŸ“¦ where this page comes from