CLANG-FORMAT-DIFF.PY(1)

πŸ“¦
version 14.0.6 Β· 5 versions
, in ubuntu questing

πŸ’– CLANG-FORMAT-DIFF.PY(1) πŸ’–

okay bestie, welcome to the manual page for clang-format-diff.py (the one and only, version 14, living in the User Commands section like the icon it is) ✨


🌸 NAME 🌸

clang-format-diff.py β€” the manual page for clang-format-diff.py 14, no cap πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so like, here's how you're supposed to call her:

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

okay so what does this lil script actually DO? she reads input from a unified diff and reformats all the changed lines. that's it, that's the vibe πŸŽ€

and it's lowkey so useful when you wanna reformat, like, only the lines that a specific patch touched. no sweeping the whole file, just the glow-up zone ✨

here's the 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
⚠️ ok important warning time, listen up bestie: the filename contained in the diff is used unmodified to figure out which source file to update. so if you're calling this script directly, pls be careful and make sure the path in the diff is correct relative to the current working directory. fr fr, do a vibe check on your paths first πŸ™ˆ

✨ options: ✨

  • -h, --help β€” show this help message and exit. the classic. she's giving "help me help you" 🫢
  • -i β€” apply the edits to the files instead of just displaying a diff. this is the one that actually does the thing πŸ’…
  • -p NUM β€” strip the smallest prefix containing P slashes. yes bestie, that NUM is a number, and yes it matters 🌈
  • -regex PATTERN β€” a custom pattern that picks which file paths get reformatted. she's case sensitive, and she overrides -iregex πŸ‘‘
  • -iregex PATTERN β€” a custom pattern that picks which file paths get reformatted, but make it case insensitive. lowkey she gets overridden by -regex though, so know your hierarchy πŸ₯²
  • -sort-includes β€” let clang-format sort the include blocks. organizing? we love to see it πŸŽ€
  • -v, --verbose β€” be more verbose. that's it. but heads up: she's ineffective without -i, so if you're not applying edits, the yapping does nothing πŸ’€
  • -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. she's the backup plan, the safety net, the ride-or-die πŸ¦‹
  • -binary BINARY β€” the location of the binary to use for clang-format. point her at your fave πŸ“

and that's the whole page, bestie!! this was clang-format-diff.py 14, dated May 2025, straight out of the User Commands section πŸ’– go reformat something and slay, ily, bye!! πŸ‘‘πŸŒΈβœ¨

πŸ“¦ where this page comes from