format
Installation
SKILL.md
Tool Locations
- clang-format:
../../../prebuilts/clang/ohos/linux-x86_64/llvm/bin/clang-format - clang-format-diff.py:
../../../prebuilts/clang/ohos/linux-x86_64/llvm/share/clang/clang-format-diff.py
Approach
Use clang-format-diff.py which is designed specifically for this use case - it reads a diff from stdin and only applies formatting to lines that were changed.
Working Command
# Navigate to repo root and run:
git diff HEAD -- 'graphic_2d/**/*.cpp' 'graphic_2d/**/*.h' 2>/dev/null | \
python3 prebuilts/clang/ohos/linux-x86_64/llvm/share/clang/clang-format-diff.py \
-p1 -binary prebuilts/clang/ohos/linux-x86_64/llvm/bin/clang-format -i