12c593315Sopenharmony_ci#!/bin/sh -e 22c593315Sopenharmony_ci# 32c593315Sopenharmony_ci# An example hook script to verify what is about to be committed. 42c593315Sopenharmony_ci# Called by "git commit" with no arguments. The hook should 52c593315Sopenharmony_ci# exit with non-zero status after issuing an appropriate message if 62c593315Sopenharmony_ci# it wants to stop the commit. 72c593315Sopenharmony_ci# 82c593315Sopenharmony_ci 92c593315Sopenharmony_ciCLANGFORMATDIFF=`git config --get clangformatdiff.binary` 102c593315Sopenharmony_ci 112c593315Sopenharmony_ciif [ -z "$CLANGFORMATDIFF" ]; then 122c593315Sopenharmony_ci CLANGFORMATDIFF=clang-format-diff.py 132c593315Sopenharmony_cifi 142c593315Sopenharmony_ci 152c593315Sopenharmony_cierrors=`git diff-index --cached --diff-filter=ACMR -p HEAD lib src examples tests | $CLANGFORMATDIFF -p1` 162c593315Sopenharmony_ci 172c593315Sopenharmony_ciif [ -n "$errors" ]; then 182c593315Sopenharmony_ci echo "$errors" 192c593315Sopenharmony_ci echo "--" 202c593315Sopenharmony_ci echo "[ERROR] We have detected the difference between the code to commit" 212c593315Sopenharmony_ci echo "and clang-format style rules. Please fix this problem in either:" 222c593315Sopenharmony_ci echo "1) Apply patch above." 232c593315Sopenharmony_ci echo "2) Use clang-format to format lines." 242c593315Sopenharmony_ci echo "3) Reformat these lines manually." 252c593315Sopenharmony_ci echo "Aborting commit." 262c593315Sopenharmony_ci exit 1 272c593315Sopenharmony_cifi 28