@@ -372,6 +372,46 @@ Example invocations:
372372 # Run with parallel execution (uses all CPU cores by default)
373373 $ run-clang-tidy.py -j 4
374374
375+ Running Clang-Tidy on Diff
376+ ---------------------------
377+
378+ The :program: `clang-tidy-diff.py ` script allows you to run :program: `clang-tidy `
379+ only on the lines that have been modified in your working directory or in a
380+ specific diff. This is particularly useful for code reviews and continuous
381+ integration, as it focuses analysis on the changed code rather than the entire
382+ codebase.
383+
384+ The script can work with various diff sources:
385+
386+ * Git working directory changes
387+ * Output from ``git diff ``
388+ * Output from ``svn diff ``
389+ * Patch files
390+
391+ Example invocations:
392+
393+ .. code-block :: console
394+
395+ # Run clang-tidy on all changes in the working directory
396+ $ git diff -U0 --no-color HEAD^ | clang-tidy-diff.py -p1
397+
398+ # Run with specific checks and apply fixes
399+ $ git diff -U0 --no-color HEAD^ | clang-tidy-diff.py -p1 -fix -checks=-*,readability-*
400+
401+ # Run on staged changes
402+ $ git diff -U0 --no-color --cached | clang-tidy-diff.py -p1
403+
404+ # Run on changes between two commits
405+ $ git diff -U0 --no-color HEAD~2 HEAD | clang-tidy-diff.py -p1
406+
407+ # Run on a patch file
408+ $ clang-tidy-diff.py -p1 < changes.patch
409+
410+ The ``-p1 `` option tells the script to strip one level of path prefix from the
411+ diff, which is typically needed for Git diffs. The script supports most of the
412+ same options as :program: `clang-tidy ` itself, including ``-checks= ``, ``-fix ``,
413+ ``-header-filter= ``, and configuration options.
414+
375415.. _clang-tidy-nolint :
376416
377417Suppressing Undesired Diagnostics
0 commit comments